reserve X for set;
reserve k,m,n for Nat;
reserve i for Integer;
reserve a,b,c,d,e,g,p,r,x,y for Real;
reserve z for Complex;

theorem
  Sum sqr cot x_r-seq(m) <= Sum ((sqr x_r-seq(m))")
  proof
    set f = x_r-seq(m);
    set f1 = sqr cot f;
    set f2 = (sqr f)";
A1: len f = m by Th19;
A2: len cot f = len f by Lm14;
A3: len sqr f = len f by RVSUM_1:143;
    now
      let n;
      assume n in Seg m;
      then
A4:   1 <= n & n <= m by FINSEQ_1:1;
      then
A5:   n in dom f by A1,FINSEQ_3:25;
A6:   f1.n = ((cot f).n)^2 by VALUED_1:11;
A7:   (cot f).n = cot(f.n) by A5,Def3;
A8:   f2.n = ((sqr f).n)" by VALUED_1:10;
A9:   (sqr f).n = (f.n)^2 by VALUED_1:11;
A10:  (tan(f.n))" = cot(f.n) by Th15;
A11:  f.n < PI/2 by A4,Th21;
A12:  0 < f.n by A4,Th21;
      then
A13:  f.n in ]. -PI/2+PI*0,PI/2+PI*0 .[ by A11,XXREAL_1:4;
      ]. -PI/2+PI*0,PI/2+PI*0 .[
      in the set of all ]. -PI/2+PI*i,PI/2+PI*i .[ where i is Integer;
      then f.n in dom tan by A13,Th16,TARSKI:def 4;
      then tan.(f.n) = tan(f.n) by RFUNCT_1:def 1;
      then
A14:  ((tan.(f.n))^2)" = (cot(f.n))^2 by A10,XCMPLX_1:204;
      f.n <= tan.(f.n) by A4,A12,Th18,Th21;
      then (f.n)^2 <= (tan.(f.n))^2 by A12,XREAL_1:66;
      hence f1.n <= f2.n by A6,A7,A8,A9,A12,A14,XREAL_1:85;
    end;
    hence thesis by A1,A2,A3,RVSUM_1:82;
  end;
