reserve X,x for set;
reserve k,m,n for Element of NAT,
  p,q,r,s,r9,s9 for Element of HP-WFF,
  T1,T2 for Tree;
reserve T1,T2 for DecoratedTree;
reserve t,t1 for FinSequence;

theorem Th17:
  p = q^t implies p = q
proof
  defpred P[Nat] means for p,q,t st len p = $1 & p = q^t holds p = q;
A1: for n be Nat st for k being Nat st k < n holds P[k] holds P[n]
  proof
    let n be Nat such that
A2: for k being Nat st k < n holds for p,q,t st len p = k & p = q^t
    holds p = q;
    let p,q,t such that
A3: len p = n and
A4: p = q^t;
    len q >= 1 by Th10;
    then
A5: p.1 = q.1 by A4,FINSEQ_1:64;
    per cases by Th9;
    suppose
      p is conjunctive;
      then consider r,s such that
A6:   p = r '&' s;
      q.1 = (<*2*>^(r^s)).1 by A5,A6,FINSEQ_1:32
        .= 2 by FINSEQ_1:41;
      then q is conjunctive by Th12;
      then consider r9,s9 such that
A7:   q = r9 '&' s9;
      <*2*>^(r9^s9^t) = <*2*>^(r9^s9)^t by FINSEQ_1:32
        .= <*2*>^r^s by A4,A6,A7,FINSEQ_1:32
        .= <*2*>^(r^s) by FINSEQ_1:32;
      then r9^s9^t = r^s by Th2;
      then
A8:   r9^(s9^t) = r^s by FINSEQ_1:32;
      now
        per cases;
        suppose
A9:       len r <= len r9;
          n = len q + len t by A3,A4,FINSEQ_1:22;
          then len q <= n by NAT_1:11;
          then
A10:      len r9 < n by A7,Th15,XXREAL_0:2;
          ex t1 st r^t1 = r9 by A8,A9,FINSEQ_1:47;
          then r = r9 by A2,A10;
          then
A11:      s9^t = s by A8,FINSEQ_1:33;
          len s < n by A3,A6,Th15;
          then s9 = s by A2,A11;
          then t = {} by A11,FINSEQ_1:87;
          hence thesis by A4,FINSEQ_1:34;
        end;
        suppose
          len r >= len r9;
          then
A12:      ex t1 st r9^t1 = r by A8,FINSEQ_1:47;
          len r < n by A3,A6,Th15;
          then r = r9 by A2,A12;
          then
A13:      s9^t = s by A8,FINSEQ_1:33;
          len s < n by A3,A6,Th15;
          then s9 = s by A2,A13;
          then t = {} by A13,FINSEQ_1:87;
          hence thesis by A4,FINSEQ_1:34;
        end;
      end;
      hence thesis;
    end;
    suppose
      p is conditional;
      then consider r,s such that
A14:  p = r => s;
      q.1 = (<*1*>^(r^s)).1 by A5,A14,FINSEQ_1:32
        .= 1 by FINSEQ_1:41;
      then q is conditional by Th11;
      then consider r9,s9 such that
A15:  q = r9 => s9;
      <*1*>^(r9^s9^t) = <*1*>^(r9^s9)^t by FINSEQ_1:32
        .= <*1*>^r^s by A4,A14,A15,FINSEQ_1:32
        .= <*1*>^(r^s) by FINSEQ_1:32;
      then r9^s9^t = r^s by Th2;
      then
A16:  r9^(s9^t) = r^s by FINSEQ_1:32;
      now
        per cases;
        suppose
A17:      len r <= len r9;
          n = len q + len t by A3,A4,FINSEQ_1:22;
          then len q <= n by NAT_1:11;
          then
A18:      len r9 < n by A15,Th16,XXREAL_0:2;
          ex t1 st r^t1 = r9 by A16,A17,FINSEQ_1:47;
          then r = r9 by A2,A18;
          then
A19:      s9^t = s by A16,FINSEQ_1:33;
          len s < n by A3,A14,Th16;
          then s9 = s by A2,A19;
          then t = {} by A19,FINSEQ_1:87;
          hence thesis by A4,FINSEQ_1:34;
        end;
        suppose
          len r >= len r9;
          then
A20:      ex t1 st r9^t1 = r by A16,FINSEQ_1:47;
          len r < n by A3,A14,Th16;
          then r = r9 by A2,A20;
          then
A21:      s9^t = s by A16,FINSEQ_1:33;
          len s < n by A3,A14,Th16;
          then s9 = s by A2,A21;
          then t = {} by A21,FINSEQ_1:87;
          hence thesis by A4,FINSEQ_1:34;
        end;
      end;
      hence thesis;
    end;
    suppose
A22:  p is simple;
A23:  q <> {} by Th10,CARD_1:27;
      ex n st p = prop n by A22;
      hence thesis by A4,A23,FINSEQ_1:88;
    end;
    suppose
A24:  p = VERUM;
      q <> {} by Th10,CARD_1:27;
      hence thesis by A4,A24,FINSEQ_1:88;
    end;
  end;
A25: for n being Nat holds P[n] from NAT_1:sch 4(A1);
  len p = len p;
  hence thesis by A25;
end;
