reserve p,q,r for FinSequence;
reserve u,v,x,y,y1,y2,z for object, A,D,X,Y for set;
reserve i,j,k,l,m,n for Nat;

theorem Th55:
  card((p ^ q) " A) = card(p " A) + card(q " A)
proof
  set X = (p ^ q) " A;
  set B = {len p + n where n is Element of NAT : n in q " A};
  defpred P[object,object] means ex i st $1 = i & $2 = len p + i;
A1: X = p " A \/ B
  proof
    thus X c= p " A \/ B
    proof
      let x be object;
      assume
A2:   x in X;
      then
A3:   x in dom(p ^ q) by FUNCT_1:def 7;
      then reconsider k = x as Element of NAT;
      now
        per cases by A3,FINSEQ_1:25;
        suppose
A4:       k in dom p;
          then (p ^ q).k = p.k by FINSEQ_1:def 7;
          then p.k in A by A2,FUNCT_1:def 7;
          then k in p " A by A4,FUNCT_1:def 7;
          hence thesis by XBOOLE_0:def 3;
        end;
        suppose
          ex m being Nat st m in dom q & k = len p + m;
          then consider m being Nat such that
A5:       m in dom q and
A6:       k = len p + m;
          q.m = (p ^ q).k by A5,A6,FINSEQ_1:def 7;
          then q.m in A by A2,FUNCT_1:def 7;
          then
A7:       m in q " A by A5,FUNCT_1:def 7;
          m in NAT by ORDINAL1:def 12;
          then k in B by A6,A7;
          hence thesis by XBOOLE_0:def 3;
        end;
      end;
      hence thesis;
    end;
    let x be object;
    assume
A8: x in p " A \/ B;
    now
      per cases by A8,XBOOLE_0:def 3;
      suppose
A9:     x in p " A;
        then
A10:    x in dom p by FUNCT_1:def 7;
        then reconsider k = x as Element of NAT;
        (p ^ q).k = p.k by A10,FINSEQ_1:def 7;
        then
A11:    (p ^ q).x in A by A9,FUNCT_1:def 7;
        x in dom(p ^ q) by A10,Th22;
        hence thesis by A11,FUNCT_1:def 7;
      end;
      suppose
        x in B;
        then consider n being Element of NAT such that
A12:    x = len p + n and
A13:    n in q " A;
A14:    n in dom q by A13,FUNCT_1:def 7;
        then (p ^ q).(len p + n) = q.n by FINSEQ_1:def 7;
        then
A15:    (p ^ q).x in A by A12,A13,FUNCT_1:def 7;
        x in dom(p ^ q) by A12,A14,FINSEQ_1:28;
        hence thesis by A15,FUNCT_1:def 7;
      end;
    end;
    hence thesis;
  end;
  p " A /\ B = {}
  proof
    set x = the Element of p " A /\ B;
    assume
A16: not thesis;
    then x in B by XBOOLE_0:def 4;
    then consider n being Element of NAT such that
A17: x = len p + n and
A18: n in q " A;
    len p + n in p " A by A16,A17,XBOOLE_0:def 4;
    then len p + n in dom p by FUNCT_1:def 7;
    then len p + n <= len p + 0 by Th25;
    then
A19: n = 0 by XREAL_1:6;
    n in dom q by A18,FUNCT_1:def 7;
    hence thesis by A19,Th24;
  end;
  then
A20: p " A misses B;
  reconsider B as finite set by A1,FINSET_1:1,XBOOLE_1:7;
A21: card X = card(p " A) + card B by A1,A20,CARD_2:40;
A22: for x being object st x in q " A ex y being object st P[x,y]
  proof
    let x be object;
    assume x in q " A;
    then x in dom q by FUNCT_1:def 7;
    then reconsider i = x as Element of NAT;
    reconsider y = len p + i as set;
    take y;
    take i;
    thus thesis;
  end;
  consider f being Function such that
A23: dom f = q " A and
A24: for x being object st x in q " A holds P[x,f.x] from CLASSES1:sch 1(A22);
A25: rng f = B
  proof
    thus rng f c= B
    proof
      let x be object;
      assume x in rng f;
      then consider y being object such that
A26:  y in dom f and
A27:  f.y = x by FUNCT_1:def 3;
      consider i such that
A28:  y = i and
A29:  f.y = len p + i by A23,A24,A26;
      i is Element of NAT by ORDINAL1:def 12;
      hence thesis by A23,A26,A27,A28,A29;
    end;
    let x be object;
    assume x in B;
    then consider n being Element of NAT such that
A30: x = len p + n and
A31: n in q " A;
    ex i st n = i & f.n = len p + i by A24,A31;
    hence thesis by A23,A30,A31,FUNCT_1:def 3;
  end;
  f is one-to-one
  proof
    let x,y be object;
    assume that
A32: x in dom f and
A33: y in dom f and
A34: f.x = f.y;
A35: ex j st y = j & f.y = len p + j by A23,A24,A33;
    ex i st x = i & f.x = len p + i by A23,A24,A32;
    hence thesis by A34,A35;
  end;
  then q " A,B are_equipotent by A23,A25;
  hence thesis by A21,CARD_1:5;
end;
