reserve x,y for object,
  R for Ring,
  V for LeftMod of R,
  L for Linear_Combination of V,
  a for Scalar of R,
  v,u for Vector of V,
  F,G for FinSequence of the carrier of V,
  C for finite Subset of V;
reserve X,Y,Z for set,
  A,B for Subset of V,
  T for finite Subset of V,
  l for Linear_Combination of A,
  f,g for Function of the carrier of V,the carrier of R;
reserve R for Skew-Field;
reserve a,b for Scalar of R;
reserve V for LeftMod of R;
reserve v,v1,v2,u for Vector of V;
reserve f for Function of the carrier of V, the carrier of R;

theorem Th18:
  for V being LeftMod of R for A being Subset of V st
  A is linearly-independent holds
  ex B being Subset of V st A c= B & B is base
proof
  let V be LeftMod of R;
  let A be Subset of V;
  defpred P[set] means (ex B being Subset of V st B = $1 & A c= B & B is
  linearly-independent);
  consider Q being set such that
A1: for Z holds Z in Q iff Z in bool(the carrier of V) & P[Z] from
  XFAMILY:sch 1;
A2: now
    let Z;
    assume that
A3: 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 A1,A4,A7;
      hence thesis by A6;
    end;
    then reconsider W as Subset of V;
A8: W is linearly-independent
    proof
      deffunc F(object)={C where C is Subset of V : $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 A1,A4,A17;
        X in {C where C is Subset of V : 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 where C is Subset of V: 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 being Subset of V 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 being Subset of V such that
A26:  B = union S and
      A c= B and
A27:  B is linearly-independent by A1,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 where C is Subset of V : 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 being Subset of V 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;
    set x = the Element of Z;
    x in Q by A3,A4;
    then
A32: ex B being Subset of V st B = x & A c= B & B is linearly-independent
    by A1;
    x c= W by A3,ZFMISC_1:74;
    then A c= W by A32;
    hence union Z in Q by A1,A8;
  end;
  assume A is linearly-independent;
  then Q <> {} by A1;
  then consider X such that
A33: X in Q and
A34: for Z st Z in Q & Z <> X holds not X c= Z by A2,ORDERS_1:67;
  consider B being Subset of V such that
A35: B = X and
A36: A c= B and
A37: B is linearly-independent by A1,A33;
  take B;
  thus A c= B & B is linearly-independent by A36,A37;
  assume Lin(B) <> the ModuleStr of V;
  then consider v being Vector of V such that
A38: not (v in Lin(B) iff v in (Omega).V) by VECTSP_4:30;
A39: B \/ {v} is linearly-independent
  proof
    let l be Linear_Combination of B \/ {v};
    assume
A40: Sum(l) = 0.V;
    now
      per cases;
      suppose
        v in Carrier(l);
        then l.v <> 0.R by VECTSP_6:2;
        then - l.v <> 0.R by Lm1;
        then
A41:    (- l.v)" * ((- l.v) * v) = 1.R * v by Lm2
          .= v;
        deffunc F(Vector of V) = l.$1;
        consider f being Function of the carrier of V, the carrier of R such
        that
A42:    f.v = 0.R and
A43:    for u being Vector of V 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 R)
        by FUNCT_2:8;
        now
          let u be Vector of V;
          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.R & u <> v or u = v by TARSKI:def 1;
          hence f.u = 0.R by A42,A43;
        end;
        then reconsider f as Linear_Combination of V by VECTSP_6:def 1;
        Carrier(f) c= B
        proof
          let x be object;
A44:      Carrier(l) c= B \/ {v} by VECTSP_6:def 4;
          assume x in Carrier(f);
          then consider u being Vector of V such that
A45:      u = x and
A46:      f.u <> 0.R;
          f.u = l.u by A42,A43,A46;
          then u in Carrier(l) by A46;
          then u in B or u in {v} by A44,XBOOLE_0:def 3;
          hence thesis by A42,A45,A46,TARSKI:def 1;
        end;
        then reconsider f as Linear_Combination of B by VECTSP_6:def 4;
        deffunc F(Vector of V)=0.R;
        consider g being Function of the carrier of V, the carrier of R such
        that
A47:    g.v = - l.v and
A48:    for u being Vector of V st u <> v holds g.u = F(u) from
        FUNCT_2:sch 6;
        reconsider g as Element of Funcs(the carrier of V, the carrier of R)
        by FUNCT_2:8;
        now
          let u be Vector of V;
          assume not u in {v};
          then u <> v by TARSKI:def 1;
          hence g.u = 0.R by A48;
        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 being Vector of V st x = u & g.u <> 0.R;
          then x = v by A48;
          hence thesis by TARSKI:def 1;
        end;
        then reconsider g as Linear_Combination of {v} by VECTSP_6:def 4;
        f - g = l
        proof
          let u be Vector of V;
          now
            per cases;
            suppose
A49:          v = u;
              thus (f - g).u = f.u - g.u by VECTSP_6:40
                .= 0.R + (- (- l.v)) by A42,A47,A49,RLVECT_1:def 11
                .= l.v + 0.R by RLVECT_1:17
                .= l.u by A49,RLVECT_1:4;
            end;
            suppose
A50:          v <> u;
              thus (f - g).u = f.u - g.u by VECTSP_6:40
                .= l.u - g.u by A43,A50
                .= l.u - 0.R by A48,A50
                .= l.u by RLVECT_1:13;
            end;
          end;
          hence thesis;
        end;
        then
A51:    0.V = Sum(f) - Sum(g) by A40,VECTSP_6:47;
        Sum(g) = (- l.v) * v by A47,VECTSP_6:17;
        then Sum(f) = (- l.v) * v by A51,VECTSP_1:19;
        then (- l.v) * v in Lin(B) by Th4;
        hence thesis by A38,A41,STRUCT_0:def 5,VECTSP_4:21;
      end;
      suppose
A52:    not v in Carrier(l);
        Carrier(l) c= B
        proof
          let x be object;
          assume
A53:      x in Carrier(l);
          Carrier(l) c= B \/ {v} by VECTSP_6:def 4;
          then x in B or x in {v} by A53,XBOOLE_0:def 3;
          hence thesis by A52,A53,TARSKI:def 1;
        end;
        then l is Linear_Combination of B by VECTSP_6:def 4;
        hence thesis by A37,A40;
      end;
    end;
    hence thesis;
  end;
  v in {v} by TARSKI:def 1;
  then
A54: v in B \/ {v} by XBOOLE_0:def 3;
A55: not v in B by A38,Th5,STRUCT_0:def 5;
  B c= B \/ {v} by XBOOLE_1:7;
  then A c= B \/ {v} by A36;
  then B \/ {v} in Q by A1,A39;
  hence contradiction by A34,A35,A54,A55,XBOOLE_1:7;
end;
