
theorem :: Artin-Schreier
for F being Field holds
F is formally_real iff
for f being quadratic non empty FinSequence of F
                                     st Sum f = 0.F holds f is trivial
proof
let F be Field;
hereby assume AS: F is formally_real;
  now assume not(for f being quadratic non empty FinSequence of F
                 st Sum f = 0.F holds f is trivial);
    then consider f being quadratic non empty FinSequence of F such that
    H1: Sum f = 0.F & f is non trivial;
    consider i being Element of dom f such that H2: f.i <> 0.F by H1;
    H7: len Swap(f,i,len f) = len f by FINSEQ_7:18;
    then reconsider g = Swap(f,i,len f) as non empty FinSequence of F;
    reconsider m = len f - 1 as Nat;
    reconsider p = g|(Seg m) as FinSequence of F by FINSEQ_1:18;
    p ^ <*f.i*> = g
       proof
       m + 1 = len g by FINSEQ_7:18;
       then m <= len g by NAT_1:13;
       then X2: len p = m & dom p = Seg m by FINSEQ_1:17;
       X1: len(p ^ <*f.i*>) = len p + len<*f.i*> by FINSEQ_1:22
                           .= m + 1 by X2,FINSEQ_1:40
                           .= len g by FINSEQ_7:18;
       now let k be Nat;
         assume X3: 1 <= k & k <= len g;
         then per cases by XXREAL_0:1;
         suppose X4: k = len g;
           then len p + 1 = k by X2,FINSEQ_7:18;
           then X5: len p < k by NAT_1:13;
           X7: 1 <= i <= len f & 1 <= len f by FINSEQ_1:20,FINSEQ_3:25;
           thus (p ^ <*f.i*>).k = <*f.i*>.(k - len p) by X1,X4,X5,FINSEQ_1:24
                               .= f.i by X2,X4,H7
                               .= f/.i by X7,FINSEQ_4:15
                               .= g/.(len f) by X7,FINSEQ_7:31
                               .= g.k by X7,X4,H7,FINSEQ_4:15;
           end;
         suppose k < len g;
           then k + 1 <= len g by NAT_1:13;
           then (k + 1) - 1 <= len g - 1 by XREAL_1:9;
           then X4: k <= m by FINSEQ_7:18;
           then k in dom p by X2,X3,FINSEQ_1:1;
           hence (p ^ <*f.i*>).k = p.k by FINSEQ_1:def 7
                                .= g.k by X2,X3,X4,FUNCT_1:47,FINSEQ_1:1;
           end;
         end;
       hence thesis by X1,FINSEQ_1:14;
       end;
    then Sum p + Sum <*f.i*> = Sum g by RLVECT_1:41 .= 0.F by H1,GROEB_2:2;
    then H4: Sum p * Sum<*f.i*>" = (-Sum<*f.i*>) * Sum<*f.i*>" by RLVECT_1:6
                                .= -(Sum<*f.i*> * Sum<*f.i*>") by VECTSP_1:9
                                .= -(Sum<*f.i*> * (f.i)") by RLVECT_1:44
                                .= -(f.i * (f.i)") by RLVECT_1:44
                                .= - 1.F by H2,VECTSP_1:def 10;
    H5: Sum p in QS F
        proof
        now let j be Nat;
          assume I0: j in dom p;
          ex k being Element of dom f st p.j = f.k
             proof
             I2: dom p c= dom g by RELAT_1:60;
             p.j = g.j by I0,FUNCT_1:47;
             then I1: p.j in rng g by I0,I2,FUNCT_1:def 3;
             p.j in rng f by I1,FINSEQ_7:22;
             then ex x being object st
             x in dom f & p.j = f.x by FUNCT_1:def 3;
             hence thesis;
             end;
          then consider k being Element of dom f such that I1: p.j = f.k;
          f.k is square by dq;
          hence ex a being Element of F st p.j = a^2 by I1;
          end;
        then Sum p is sum_of_squares;
        hence thesis;
        end;
    H6: Sum<*f.i*>" in QS F
        proof
        f.i is square by dq;
        then consider a being Element of F such that I1: f.i = a^2;
        I0: a <> 0.F by I1,H2;
        (a")|^2 = a" * a" by RING_5:3
               .= (f.i)" by I1,VECTSP_2:11,I0;
        then (f.i)" in QS F;
        hence thesis by RLVECT_1:44;
        end;
    QS F is mult-closed;
    hence contradiction by AS,H4,H5,H6;
    end;
  hence for f being quadratic non empty FinSequence of F
                                  st Sum f = 0.F holds f is trivial;
  end;
  assume AS: for f being quadratic non empty FinSequence of F
                  st Sum f = 0.F holds f is trivial;
   now assume -1.F in QS F;
     then consider e being Element of F such that
     H1: e = -1.F & e is sum_of_squares;
     consider f being FinSequence of F such that
     H2: Sum f = -1.F &
         for i being Nat st i in dom f ex a being Element of F st f.i = a^2
         by H1;
     set g = f ^ <*(1.F)*>;
     H3: Sum g = Sum f + Sum<*(1.F)*> by RLVECT_1:41
              .= -1.F + 1.F by H2,RLVECT_1:44
              .= 0.F by RLVECT_1:5;
     H5b: len g = len f + len<*(1.F)*> by FINSEQ_1:22
               .= len f + 1 by FINSEQ_1:39;
     then len f < len g by NAT_1:19;
     then H5: g.(len g) = <*(1.F)*>.(len g - len f) by FINSEQ_1:24
                       .= 1.F by H5b;
     H5a: 1 <= len g by H5b,NAT_1:11;
     H4: g is quadratic
         proof
         now let i be Element of dom g;
           I1: 1 <= i <= len g by FINSEQ_3:25;
           per cases;
           suppose i = len g;
             hence g.i is square by H5;
             end;
           suppose i <> len g;
             then i < ((len g) - 1) + 1 by I1,XXREAL_0:1;
             then i2: i <= len f by H5b,NAT_1:13;
             then i in dom f by I1,FINSEQ_3:25;
             then g.i = f.i by FINSEQ_1:def 7;
             hence g.i is square by i2,H2,I1,FINSEQ_3:25;
             end;
           end;
         hence thesis;
         end;
     g is non trivial by H5,H5a,FINSEQ_3:25;
     hence contradiction by H3,H4,AS;
     end;
     hence F is formally_real;
end;
