reserve X,Z for set;
reserve x,y,z for object;
reserve A,B,C for Subset of X;

theorem Th85:
  for A being transitive RelStr, B, C being Subset of A,
    s1 being FinSequence of A, x being Element of A
  st
    s1 is C-asc_ordering & not x in C & B = C \/ {x} &
      for y being Element of A st y in C holds x <= y
  holds
    ex s2 being FinSequence of A st
      s2 = <*x*> ^ s1 & s2 is B-asc_ordering
proof
  let A be transitive RelStr;
  let B,C be Subset of A;
  let s1 be FinSequence of A;
  let x be Element of A;
  assume that
    A1: s1 is C-asc_ordering and
    A2: not x in C and
    A3: B = C \/ {x} and
    A4: for y being Element of A st y in C holds x <= y;
  A5: s1 is weakly-ascending by A1;
  set sx = <*x*>;
  B is non empty by A3;
  then reconsider sx as FinSequence of the carrier of A by FINSEQ_1:74;
  set s2 = sx ^ s1;
  take s2;
  thus s2 = <*x*> ^ s1;
  A6: rng s2 = rng sx \/ rng s1 by FINSEQ_1:31
    .= B by A3, A1, FINSEQ_1:38;
  {x} misses C by A2, ZFMISC_1:50;
  then rng sx misses rng s1 by A1, FINSEQ_1:38;
  then A7: s2 is one-to-one by A1, FINSEQ_3:91;
  for n,m being Nat st n in dom s2 & m in dom s2 & n < m holds
    s2/.n <= s2/.m
  proof
    let n, m be Nat such that
      A8: n in dom s2 and
      A9: m in dom s2 and
      A10: n < m;
    per cases by A8, FINSEQ_1:25;
    suppose n in dom sx;
      then n in Seg 1 by FINSEQ_1:38;
      then A11: n = 1 by FINSEQ_1:2, TARSKI:def 1;
      then s2.n = x by FINSEQ_1:41;
      then A12: s2/.n = x by A8, PARTFUN1:def 6;
      s2/.m in C
      proof
        m in Seg len s2 by A9, FINSEQ_1:def 3;
        then A13: m <= len s2 by FINSEQ_1:1;
        A14: len sx < m by A10, A11, FINSEQ_1:40;
        s2.m = s1.(m-len sx) by A13, A14, FINSEQ_1:24;
        then A15: s2.m = s1.(m-1) by FINSEQ_1:40;
        len sx + len s1 = len s2 by FINSEQ_1:22;
        then 1 + len s1 = len s2 by FINSEQ_1:40;
        then len s1 = len s2 - 1;
        then A16: m-1 <= len s1 by A13, XREAL_1:9;
        m is non zero by A10;
        then reconsider m1 = m-1 as Nat by CHORD:1;
        1 < m1 + 1 by A10, A11;
        then 1 <= m1 by NAT_1:8;
        then m1 in Seg len s1 by A16, FINSEQ_1:1;
        then m1 in dom s1 by FINSEQ_1:def 3;
        then s2.m in rng s1 by A15, FUNCT_1:3;
        hence s2/.m in C by A1, A9, PARTFUN1:def 6;
      end;
      hence s2/.n <= s2/.m by A12, A4;
    end;
    suppose ex k being Nat st k in dom s1 & n=len sx + k;
      then consider k being Nat such that A17: k in dom s1 & n=len sx + k;
      s2.n = s1.k by A17, FINSEQ_1:def 7;
      then s2/.n = s1.k by A8, PARTFUN1:def 6;
      then A18: s2/.n = s1/.k by A17, PARTFUN1:def 6;
      A19: m in dom sx or ex l being Nat st l in dom s1 & m=len sx + l
        by A9, FINSEQ_1:25;
      not m in dom sx
      proof
        assume m in dom sx;
        then m in Seg len sx by FINSEQ_1:def 3;
        then m in Seg 1 by FINSEQ_1:40;
        then A20: m = 1 by FINSEQ_1:2, TARSKI:def 1;
        k in Seg len s1 by A17, FINSEQ_1:def 3;
        then 1 <= k by FINSEQ_1:1;
        then 1 < k + 1 by NAT_1:13;
        hence contradiction by A20, A10, A17, FINSEQ_1:40;
      end;
      then consider l being Nat such that
        A21: l in dom s1 & m=len sx + l by A19;
      s2.m = s1.l by A21, FINSEQ_1:def 7;
      then s2/.m = s1.l by A9, PARTFUN1:def 6;
      then A22: s2/.m = s1/.l by A21, PARTFUN1:def 6;
      k < l by A17, A21, A10, XREAL_1:6;
      then s1/.k <= s1/.l by A17, A21, A5;
      hence s2/.n <= s2/.m by A18, A22;
    end;
  end;
  then s2 is weakly-ascending;
  hence thesis by A6, A7;
end;
