
theorem ::T_4_62: :: Theorem 4.62
  for n being Nat, o be TermOrder of n st o is admissible
  holds the InternalRel of NaivelyOrderedBags n c= o & o is well-ordering
proof
  let n be Nat, o be TermOrder of n such that
A1: o is admissible;
   reconsider n0=n as Element of NAT by ORDINAL1:def 12;
  set IRN = the InternalRel of NaivelyOrderedBags n;
  now
    let a,b be object such that
A2: [a,b] in IRN;
A3: a in dom IRN by A2,XTUPLE_0:def 12;
    b in rng IRN by A2,XTUPLE_0:def 13;
    then reconsider a1 = a, b1 = b as Element of Bags n by A3,Def11;
A4: a1 divides b1 by A2,Def11;
    set l = b1 -' a1;
    now
      let i be object such that i in n;
A5:   (l+a1).i = l.i+a1.i by PRE_POLY:def 5
        .= b1.i -' a1.i + a1.i by PRE_POLY:def 6;
      a1.i <= b1.i by A4,PRE_POLY:def 11;
      then a1.i-a1.i <= b1.i-a1.i by XREAL_1:9;
      hence (l+a1).i = (b1.i + (-a1.i)) + a1.i by A5,XREAL_0:def 2
        .= b1.i;
    end;
    then
A6: l + a1 = b1 by PBOOLE:3;
    [EmptyBag n, l] in o by A1;
    then [(EmptyBag n)+a1, l+a1] in o by A1;
    hence [a,b] in o by A6,PRE_POLY:53;
  end;
  hence
A7: the InternalRel of NaivelyOrderedBags n c= o by RELAT_1:def 3;
  set R = product(n0 --> OrderedNAT), S = RelStr(# Bags n, o #);
A8: S is quasi_ordered by DICKSON:def 3;
A9: the InternalRel of R c= the InternalRel of S by A7,Th30;
  the carrier of R = the carrier of S by Th29;
  then
A10: S\~ is well_founded by A8,A9,DICKSON:49;
  o is_strongly_connected_in Bags n by A1;
  then
A11: o is_connected_in Bags n;
A12: field o = Bags n by ORDERS_1:12;
  S is well_founded by A10,DICKSON:16;
  then
A13: o is_well_founded_in field o by A12;
A14: o is connected by A11,A12;
  o is well_founded by A13,WELLORD1:3;
  hence thesis by A14;
end;
