reserve i,j,n,k,m for Nat,
     a,b,x,y,z for object,
     F,G for FinSequence-yielding FinSequence,
     f,g,p,q for FinSequence,
     X,Y for set,
     D for non empty set;

theorem Th39:
 m<>0 implies  bool(Seg (m+2)\{1}) =
    Ext(bool(Seg (m+1)\{1}),1+m,2+m)\/
    swap(bool(Seg (m+1)\{1}),1+m,2+m)
proof
  assume
A1: m<>0;
  set s=Seg (m+1)\{1}, F = bool(s),F1 = bool(Seg (m+2)\{1}),
  E=Ext(F,1+m,2+m), S=swap(F,1+m,2+m);
  1+m+1 > m+1 by NAT_1:13;
  then not m+2 in Seg (m+1) by FINSEQ_1:1;
  then
A2: not 2+m in union F by ZFMISC_1:56;
  then
A3: card S = card F = card E by Th10,Th11;
A4: 2 * card F = card bool (Seg (1+(m+1))\{1}) by Th9
  .= card F1;
  1+m<>2+m;
  then
A5: card (E\/S) = card F+card F by Th22,A2,A3,CARD_2:40
  .= card F1 by A4;
A6: Seg(m+1+1)= Seg(m+1)\/{m+2} & Seg(m+1) = Seg m \/{m+1} by FINSEQ_1:9;
  then Seg(m+1+1)\{1} = s \/({m+2} \{1}) & 1<>m+2 by A1,XBOOLE_1:42;
  then
A7: Seg(m+1+1)\{1} = s \/{m+2} by ZFMISC_1:14;
  m+1 <>1 by A1;
  then
  {m+1} c= Seg(m+1) & not 1 in {m+1} by A6,XBOOLE_1:7,TARSKI:def 1;
  then
A8: Seg(m+1+1)\{1} = s \/ {m+1} \/{m+2} =s\/{m+2}
  by A7,XBOOLE_1:12,ZFMISC_1:34;
A9: S c= F1
  proof
    let x;
    assume
A10:  x in S;
    reconsider x as set by TARSKI:1;
    per cases by A10,XBOOLE_0:def 3;
    suppose x in {(A\{m+1})\/{m+2} where A is Element of F: m+1 in A};
      then consider A be Element of F such that
A11:  x=(A\{m+1})\/{m+2} & m+1 in A;
      x c= s\/{m+2} by A11,XBOOLE_1:13;
      hence thesis by A7;
    end;
    suppose x in {A\/{m+1} where A is Element of F: not m+1 in A & A in F};
      then consider A be Element of F such that
A12:  x = A\/{m+1} & not m+1 in A & A in F;
      x c= s\/{m+1} by A12,XBOOLE_1:13;
      then x c= Seg(m+1+1)\{1} by A8,XBOOLE_1:10;
      hence thesis;
    end;
  end;
  E c= F1
  proof
    let x;
    assume
A13:  x in E;
    reconsider x as set by TARSKI:1;
    per cases by A13,XBOOLE_0:def 3;
    suppose x in {A\/{m+2} where A is Element of F: m+1 in A};
      then consider A be Element of F such that
A14:    x= A\/{m+2} & m+1 in A;
      x c= s \/{m+2} by A14,XBOOLE_1:13;
      hence thesis by A7;
    end;
    suppose x in {A where A is Element of F: not m+1 in A & A in F};
      then consider A be Element of F such that
A15:    x= A & not m+1 in A & A in F;
      x c= s\/{m+2} by A15,XBOOLE_1:10;
      hence thesis by A7;
    end;
  end;
  hence thesis by A5,CARD_2:102,A9,XBOOLE_1:8;
end;
