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

theorem Th79:
  for A being LinearOrder, B being finite Subset of A,
    s being FinSequence of A holds
      s is B-asc_ordering iff s = SgmX(the InternalRel of A, B)
proof
  let A be LinearOrder, B be finite Subset of A;
  let s be FinSequence of A;
  thus s is B-asc_ordering implies s = SgmX(the InternalRel of A, B)
  proof
    assume A1: s is B-asc_ordering;
    for n,m being Nat st n in dom s & m in dom s & n < m holds
      s/.n <> s/.m & [s/.n,s/.m] in the InternalRel of A
    proof
      let n, m be Nat;
      assume A2: n in dom s & m in dom s & n < m;
      then reconsider x = s.n, y = s.m as Element of A by PARTFUN1:4;
      A3: x = s/.n & y = s/.m by A2, PARTFUN1:def 6;
      A4: x < y by A1, A2, A3, Def19;
      hence s/.n <> s/.m by A3;
      thus [s/.n,s/.m] in the InternalRel of A
        by A3, A4, ORDERS_2:def 6, ORDERS_2:def 5;
    end;
    hence thesis by A1, PRE_POLY:9;
  end;
  A5: the InternalRel of A linearly_orders B by Th37, ORDERS_1:38;
  assume A6: s = SgmX(the InternalRel of A, B);
  then A7: rng s = B by A5, PRE_POLY:def 2;
  A8: s is one-to-one by A5, A6, PRE_POLY:10;
  for n, m being Nat st n in dom s & m in dom s & n < m holds
    s/.n < s/.m
  proof
    let n, m be Nat such that
    A9: n in dom s & m in dom s and
    A10: n < m;
    [s/.n, s/.m] in the InternalRel of A by A5, A6, A9, A10, PRE_POLY:def 2;
    then A11: s/.n <= s/.m by ORDERS_2:def 5;
    s/.n <> s/.m
    proof
      assume A12: s/.n = s/.m;
      s/.n = s.n & s/.m = s.m by A9, PARTFUN1:def 6;
      then n = m by A8, A9, FUNCT_1:def 4, A12;
      hence contradiction by A10;
    end;
    hence thesis by A11, ORDERS_2:def 6;
  end;
  then s is ascending;
  hence s is B-asc_ordering by A7;
end;
