theorem Th31:
  p in T implies T with-replacement (p,T1) =
  { t1 where t1 is Element of T : not p is_a_proper_prefix_of t1 } \/
  the set of all p^s where s is Element of T1
proof
  assume
A1: p in T;
  thus
  T with-replacement (p,T1) c= { t : not p is_a_proper_prefix_of t } \/
  the set of all p^s where s is Element of T1
  proof
    let x be object;
    assume
A2: x in T with-replacement (p,T1);
    then reconsider q = x as FinSequence of NAT by Th18;
A3: (ex r st r in T1 & q = p^r) implies
    x in the set of all p^s where s is Element of T1;
 q in T & not p is_a_proper_prefix_of q implies
    x in { t : not p is_a_proper_prefix_of t };
    hence thesis by A1,A2,A3,Def9,XBOOLE_0:def 3;
  end;
  let x be object such that
A4: x in { t : not p is_a_proper_prefix_of t } \/
  the set of all p^s where s is Element of T1;
A5: now
    assume x in the set of all p^s where s is Element of T1;
then  ex s being Element of T1 st x = p^s;
    hence thesis by A1,Def9;
  end;
 now
    assume x in { t : not p is_a_proper_prefix_of t };
then  ex t st x = t & not p is_a_proper_prefix_of t;
    hence thesis by A1,Def9;
  end;
  hence thesis by A4,A5,XBOOLE_0:def 3;
end;
