Zulip Chat Archive

Stream: maths

Topic: Commuting sum sigmas with a sum of sum of sum


Mark Andrew Gerads (Oct 17 2022 at 19:57):

image.png
I have a triple sum I need to rearrange:

 (x : ) in
  range n,
   (x_1 : ) in
    range n,
     (x_2 : ) in
      range n,
      ruesDiff n x_1 z₀ * ruesDiff n x_2 z₁ * exp (2 * real.pi * (x / n) * I) ^ (-↑x_1 + -↑x_2)

needs to become

 (x_1 : ) in
  range n,
   (x_2 : ) in
    range n,
     (x : ) in
      range n,
      ruesDiff n x_1 z₀ * ruesDiff n x_2 z₁ * exp (2 * real.pi * (x / n) * I) ^ (-↑x_1 + -↑x_2)

docs#finset.sum_comm seems to be the key, yet I do not know how to use it to rewrite only the part needed to be rewritten.
Here is my #MWE, where I am working on ruesArgumentSumRule:

import analysis.special_functions.trigonometric.basic
import analysis.special_functions.exponential
import analysis.special_functions.complex.log
import algebra.group_with_zero.defs
import algebra.big_operators.basic

open classical complex asymptotics real normed_space
open_locale classical big_operators nat

-- rues is the Root of Unity Exponential Sum function
-- inspired by the relationship between exp and cosh
noncomputable
def rues (n:) (z:) :  :=
  tsum (λ (k:), z ^ (n*k) / (n*k).factorial)

def ruesDiff (n : ) (m : ) :    := sorry

lemma rouNot0 (n:) (h₀:0<n) (rou:) (h₁:rou ^ n = 1) : rou  0 := sorry

lemma ruesDiffRotationallySymmetric (n:) (h₀:0<n) (m:) (z rou:) (h₁:rou ^ n = 1) : ruesDiff n m (z * rou) = rou ^ -m * ruesDiff n m z :=
  sorry

open finset

lemma ruesNEqExpSum (n:) (h:0<n) (z:) :
    rues n z = ( m in range n, exp (z * exp (2 * real.pi * (m / n) * I)))/n := sorry

lemma expSumOfRuesDiff (k:) (h:0<k) (z:) : exp z =  k₀ in range k, ruesDiff k k₀ z:= sorry

lemma ruesArgumentSumRule (n:) (h:0<n) (z₀ z₁:) :
        rues n (z₀ + z₁) =  k in range n, (ruesDiff n k z₀ * ruesDiff n (n - k) z₁) :=
begin
  rw ruesNEqExpSum n h _,
  have h0 :  (m : ), (z₀ + z₁) * exp (2 * real.pi * (m / n) * I) =
    z₀ * exp (2 * real.pi * (m / n) * I) +
    z₁ * exp (2 * real.pi * (m / n) * I),
  {
    intros m,
    ring_nf,
  },
  simp_rw h0,
  clear h0,
  simp_rw complex.exp_add,
  have h1 :  (x : ), exp (z₀ * exp (2 * real.pi * (x / n) * I)) =
     (k₀ : ) in range n, ruesDiff n k₀ (z₀ * exp (2 * real.pi * (x / n) * I)),
  {
    intros x,
    exact expSumOfRuesDiff n h (z₀ * complex.exp ((2:) * (real.pi:) * ((x:) / (n:)) * I)),
  },
  simp_rw h1,
  clear h1,
  have h2 :  (x : ), exp (z₁ * exp (2 * real.pi * (x / n) * I)) =
     (k₀ : ) in range n, ruesDiff n k₀ (z₁ * exp (2 * real.pi * (x / n) * I)),
  {
    intros x,
    exact expSumOfRuesDiff n h (z₁ * complex.exp ((2:) * (real.pi:) * ((x:) / (n:)) * I)),
  },
  simp_rw h2,
  clear h2,
  have h3 :  (x:), exp (2 * real.pi * (x / n) * I) ^ n = 1,
  {
    intros x,
    rw (complex.exp_nat_mul _ n).symm,
    rw complex.exp_eq_one_iff,
    use (x:),
    have h4 : 0  n,
    exact ne_of_lt h,
    have h5 : (n:)  0,
    exact_mod_cast h4.symm,
    field_simp,
    ring_nf,
  },
  have h6 :  (k₀ x : ) (z : ), ruesDiff n k₀ (z * exp (2 * real.pi * (x / n) * I)) =
    exp (2 * real.pi * (x / n) * I) ^ -↑k₀ * ruesDiff n k₀ z,
  {
    intros k₀ x z,
    exact ruesDiffRotationallySymmetric n h k₀ z (exp (2 * real.pi * (x / n) * I)) (h3 x),
  },
  simp_rw h6 _ _ _,
  clear h6,
  simp_rw [finset.sum_mul, finset.mul_sum],
  have h7 :  (x x_1 x_2 : ), exp (2 * real.pi * ((x:) / (n:)) * I) ^ -(x_1:) * ruesDiff n x_1 z₀ *
  (exp (2 * real.pi * ((x:) / (n:)) * I) ^ -(x_2:) * ruesDiff n x_2 z₁) =
  ruesDiff n x_1 z₀ * ruesDiff n x_2 z₁ * (exp (2 * real.pi * ((x:) / (n:)) * I) ^ -(x_1:) *
  exp (2 * real.pi * ((x:) / (n:)) * I) ^ -(x_2:)),
  {
    intros x x_1 x_2,
    ring_nf,
  },
  simp_rw h7,
  clear h7,
  have h8 :  (x x_1 x_2 : ), exp (2 * real.pi * ((x:) / (n:)) * I) ^ -(x_1:) * exp (2 * real.pi * ((x:) / (n:)) * I) ^ -(x_2:) =
  exp (2 * real.pi * ((x:) / (n:)) * I) ^ (-(x_1:) + -(x_2:)),
  {
    intros x x_1 x_2,
    have h9 : exp (2 * real.pi * ((x:) / (n:)) * I)  0,
    {
      exact rouNot0 n h (exp (2 * real.pi * (x / n) * I)) (h3 x),
    },
    exact (zpow_add₀ h9 (-(x_1:)) (-(x_2:))).symm,
  },
  simp_rw h8,
  clear h8,
  -- simp_rw finset.sum_comm, -- seems to be stuck in an infinite loop? Taking way to long.
  sorry,
end

Mark Andrew Gerads (Oct 17 2022 at 20:02):

I was thinking this would be easy if I had a command like simp_rw_nth with would act like simp_rw, except it only rewrites the nth rewritable term.

Kevin Buzzard (Oct 17 2022 at 20:22):

This proof takes a really long time to compile. Lean likes you much better if you refactor out as much as you can -- many small lemmas is much much better than one big theorem. For example it's quite bad style to do things like proving h3 in the middle of your proof -- this is just an independent result which could be factored out, you shouldn't be proving it in the middle of some other proof just because you realised you needed it in the middle of the other proof.

Kevin Buzzard (Oct 17 2022 at 20:25):

To do the targetted rewrite you can do simp_rw @finset.sum_comm _ _ _ _ _ _ (λ g a, ...) (sorry, need to go, the art is to fill in the ...)

Eric Wieser (Oct 17 2022 at 21:14):

I think it's pretty clear that finset.sum_comm should be changed to take explicit arguments...


Last updated: Dec 20 2023 at 11:08 UTC