 reserve x,y for object, X,Y,Z for set;
 reserve GF for commutative
     Abelian add-associative right_zeroed right_complementable
     associative well-unital distributive non empty doubleLoopStr;
 reserve a,b for Element of GF;
 reserve V for scalar-distributive vector-distributive
   scalar-associative scalar-unital add-associative right_zeroed
     right_complementable Abelian non empty ModuleStr over GF;
 reserve v,v1,v2,u for Vector of V;
 reserve A,B,C for Subset of V;
 reserve T for finite Subset of V;
 reserve l for Linear_Combination of A;
 reserve f,g for Function of V, GF;
 reserve GF for commutative non degenerated almost_left_invertible
     Abelian add-associative right_zeroed right_complementable
     associative well-unital distributive non empty doubleLoopStr;
 reserve a,b for Element of GF;
 reserve V for scalar-distributive vector-distributive
   scalar-associative scalar-unital add-associative right_zeroed
     right_complementable Abelian non empty ModuleStr over GF;
 reserve v,v1,v2,u for Vector of V;
 reserve A,B,C for Subset of V;
 reserve T for finite Subset of V;
 reserve l for Linear_Combination of A;
 reserve f,g for Function of V, GF;
reserve l0 for Linear_Combination of {}(the carrier of V);

theorem Th18:
  Lin(A) = V implies ex B st B c= A & B is linearly-independent & Lin B = V
proof
  assume
A1: Lin(A) = V;
  defpred P[set] means ex B st B = $1 & B c= A & B is linearly-independent;
  consider Q being set such that
A2: for Z holds Z in Q iff Z in bool(the carrier of V) & P[Z]
    from XFAMILY:sch 1;
A3: now
    let Z;
    assume that
    Z <> {} and
A4: Z c= Q and
A5: Z is c=-linear;
    set W = union Z;
    W c= the carrier of V
    proof
      let x be object;
      assume x in W;
      then consider X such that
A6:   x in X and
A7:   X in Z by TARSKI:def 4;
      X in bool(the carrier of V) by A2,A4,A7;
      hence thesis by A6;
    end;
    then reconsider W as Subset of V;
A8: W is linearly-independent
    proof
      deffunc F(object) = {C : $1 in C & C in Z};
      let l be Linear_Combination of W;
      assume that
A9:   Sum(l) = 0.V and
A10:  Carrier(l) <> {};
      consider f being Function such that
A11:  dom f = Carrier(l) and
A12:  for x being object st x in Carrier(l) holds f.x = F(x)
        from FUNCT_1:sch 3;
      reconsider M = rng f as non empty set by A10,A11,RELAT_1:42;
      set F = the Choice_Function of M;
      set S = rng F;
A13:  now
        assume {} in M;
        then consider x being object such that
A14:    x in dom f and
A15:    f.x = {} by FUNCT_1:def 3;
        Carrier(l) c= W by VECTSP_6:def 4;
        then consider X such that
A16:    x in X and
A17:    X in Z by A11,A14,TARSKI:def 4;
        reconsider X as Subset of V by A2,A4,A17;
        X in {C : x in C & C in Z} by A16,A17;
        hence contradiction by A11,A12,A14,A15;
      end;
      then
A18:  dom F = M by RLVECT_3:28;
      then dom F is finite by A11,FINSET_1:8;
      then
A19:  S is finite by FINSET_1:8;
A20:  now
        let X;
        assume X in S;
        then consider x being object such that
A21:    x in dom F and
A22:    F.x = X by FUNCT_1:def 3;
        consider y being object such that
A23:    y in dom f & f.y = x by A18,A21,FUNCT_1:def 3;
A24:    x = {C : y in C & C in Z} by A11,A12,A23;
        reconsider x as set by TARSKI:1;
        X in x by A13,A18,A21,A22,ORDERS_1:89;
        then ex C st C = X & y in C & C in Z by A24;
        hence X in Z;
      end;
A25:  now
        let X,Y;
        assume X in S & Y in S;
        then X in Z & Y in Z by A20;
        then X,Y are_c=-comparable by A5,ORDINAL1:def 8;
        hence X c= Y or Y c= X;
      end;
      S <> {} by A18,RELAT_1:42;
      then union S in S by A25,A19,CARD_2:62;
      then union S in Z by A20;
      then consider B such that
A26:  B = union S and
      B c= A and
A27:  B is linearly-independent by A2,A4;
      Carrier(l) c= union S
      proof
        let x be object;
        set X = f.x;
        assume
A28:    x in Carrier(l);
        then
A29:    f.x = {C : x in C & C in Z} by A12;
A30:    f.x in M by A11,A28,FUNCT_1:def 3;
        then F.X in X by A13,ORDERS_1:89;
        then
A31:    ex C st F.X = C & x in C & C in Z by A29;
        F.X in S by A18,A30,FUNCT_1:def 3;
        hence thesis by A31,TARSKI:def 4;
      end;
      then l is Linear_Combination of B by A26,VECTSP_6:def 4;
      hence thesis by A9,A10,A27;
    end;
    W c= A
    proof
      let x be object;
      assume x in W;
      then consider X such that
A32:  x in X and
A33:  X in Z by TARSKI:def 4;
      ex B st B = X & B c= A & B is linearly-independent by A2,A4,A33;
      hence thesis by A32;
    end;
    hence union Z in Q by A2,A8;
  end;
  {}(the carrier of V) c= A;
  then Q <> {} by A2;
  then consider X such that
A34: X in Q and
A35: for Z st Z in Q & Z <> X holds not X c= Z by A3,ORDERS_1:67;
  consider B such that
A36: B = X and
A37: B c= A and
A38: B is linearly-independent by A2,A34;
  take B;
  thus B c= A & B is linearly-independent by A37,A38;
  assume
A39: Lin(B) <> V;
  now
    assume
A40: for v st v in A holds v in Lin(B);
    now
      reconsider F = the carrier of Lin(B) as Subset of V by VECTSP_4:def 2;
      let v;
      assume v in Lin(A);
      then consider l such that
A41:  v = Sum(l) by Th7;
      Carrier(l) c= the carrier of Lin(B)
      proof
        let x be object;
        assume
A42:    x in Carrier(l);
        then reconsider a = x as Vector of V;
        Carrier(l) c= A by VECTSP_6:def 4;
        then a in Lin(B) by A40,A42;
        hence thesis by STRUCT_0:def 5;
      end;
      then reconsider l as Linear_Combination of F by VECTSP_6:def 4;
      Sum(l) = v by A41;
      then v in Lin(F) by Th7;
      hence v in Lin(B) by Th11;
    end;
    then Lin(A) is Subspace of Lin(B) by VECTSP_4:28;
    hence contradiction by A1,A39,VECTSP_4:25;
  end;
  then consider v such that
A43: v in A and
A44: not v in Lin(B);
A45: B \/ {v} is linearly-independent
  proof
    let l be Linear_Combination of B \/ {v};
    assume
A46: Sum(l) = 0.V;
    now
      per cases;
      suppose
        v in Carrier(l);
        then l.v <> 0.GF by VECTSP_6:2;
        then
A47:    - l.v <> 0.GF by VECTSP_2:3;
        deffunc G(Vector of V) = 0.GF;
        deffunc F(Vector of V) = l.$1;
        consider f such that
A48:    f.v = 0.GF and
A49:    for u st u <> v holds f.u = F(u) from FUNCT_2:sch 6;
        reconsider f as Element of Funcs(the carrier of V, the carrier of GF)
        by FUNCT_2:8;
        now
          let u;
          assume not u in Carrier(l) \ {v};
          then not u in Carrier(l) or u in {v} by XBOOLE_0:def 5;
          then l.u = 0.GF & u <> v or u = v by TARSKI:def 1;
          hence f.u = 0.GF by A48,A49;
        end;
        then reconsider f as Linear_Combination of V by VECTSP_6:def 1;
        Carrier(f) c= B
        proof
          let x be object;
A50:      Carrier(l) c= B \/ {v} by VECTSP_6:def 4;
          assume x in Carrier(f);
          then consider u such that
A51:      u = x and
A52:      f.u <> 0.GF;
          f.u = l.u by A48,A49,A52;
          then u in Carrier(l) by A52;
          then u in B or u in {v} by A50,XBOOLE_0:def 3;
          hence thesis by A48,A51,A52,TARSKI:def 1;
        end;
        then reconsider f as Linear_Combination of B by VECTSP_6:def 4;
        consider g such that
A53:    g.v = - l.v and
A54:    for u st u <> v holds g.u = G(u) from FUNCT_2:sch 6;
        reconsider g as Element of Funcs(the carrier of V, the carrier of GF)
        by FUNCT_2:8;
        now
          let u;
          assume not u in {v};
          then u <> v by TARSKI:def 1;
          hence g.u = 0.GF by A54;
        end;
        then reconsider g as Linear_Combination of V by VECTSP_6:def 1;
        Carrier(g) c= {v}
        proof
          let x be object;
          assume x in Carrier(g);
          then ex u st x = u & g.u <> 0.GF;
          then x = v by A54;
          hence thesis by TARSKI:def 1;
        end;
        then reconsider g as Linear_Combination of {v} by VECTSP_6:def 4;
A55:    Sum(g) = (- l.v) * v by A53,VECTSP_6:17;
        f - g = l
        proof
          let u;
          now
            per cases;
            suppose
A56:          v = u;
              thus (f - g).u = f.u - g.u by VECTSP_6:40
                .= 0.GF + (- (- l.v)) by A48,A53,A56,RLVECT_1:def 11
                .= l.v + 0.GF by RLVECT_1:17
                .= l.u by A56,RLVECT_1:4;
            end;
            suppose
A57:          v <> u;
              thus (f - g).u = f.u - g.u by VECTSP_6:40
                .= l.u - g.u by A49,A57
                .= l.u - 0.GF by A54,A57
                .= l.u by RLVECT_1:13;
            end;
          end;
          hence thesis;
        end;
        then 0.V = Sum(f) - Sum(g) by A46,VECTSP_6:47;
        then Sum(f) = 0.V + Sum(g) by VECTSP_2:2
          .= (- l.v) * v by A55,RLVECT_1:4;
        then
A58:    (- l.v) * v in Lin(B) by Th7;
        (- l.v)" * ((- l.v) * v) = (- l.v)" * (- l.v) * v by VECTSP_1:def 16
          .= 1_GF * v by A47,VECTSP_1:def 10
          .= v;
        hence thesis by A44,A58,VECTSP_4:21;
      end;
      suppose
A59:    not v in Carrier(l);
        Carrier(l) c= B
        proof
          let x be object;
          assume
A60:      x in Carrier(l);
          Carrier(l) c= B \/ {v} by VECTSP_6:def 4;
          then x in B or x in {v} by A60,XBOOLE_0:def 3;
          hence thesis by A59,A60,TARSKI:def 1;
        end;
        then l is Linear_Combination of B by VECTSP_6:def 4;
        hence thesis by A38,A46;
      end;
    end;
    hence thesis;
  end;
  {v} c= A by A43,ZFMISC_1:31;
  then B \/ {v} c= A by A37,XBOOLE_1:8;
  then
A61: B \/ {v} in Q by A2,A45;
  v in {v} by TARSKI:def 1;
  then
A62: v in B \/ {v} by XBOOLE_0:def 3;
  not v in B by A44,Th8;
  hence contradiction by A35,A36,A62,A61,XBOOLE_1:7;
end;
