
theorem
  for o being Ordinal holds GrInvLexOrder o is well-ordering
proof
  let o be Ordinal;
  set gilo = GrInvLexOrder o, ilo = InvLexOrder o;
A1: gilo is_strongly_connected_in Bags o by Def5;
A2: field gilo = Bags o by ORDERS_1:12;
  then
A3: gilo is_reflexive_in Bags o by RELAT_2:def 9;
A4: gilo is_transitive_in Bags o by A2,RELAT_2:def 16;
A5: gilo is_antisymmetric_in Bags o by A2,RELAT_2:def 12;
A6: gilo is_connected_in field gilo by A1,A2;
A7: for a,b,c being bag of o st [a,b] in ilo holds [a+c, b+c] in ilo by Def5;
  now
    let Y be set such that
A8: Y c= field gilo and
A9: Y <> {};
    set TD = {TotDegree y where y is Element of Bags o : y in Y};
    consider x being object such that
A10: x in Y by A9,XBOOLE_0:def 1;
    reconsider x as Element of Bags o by A8,A10,ORDERS_1:12;
A11: TotDegree x in TD by A10;
    TD c= NAT
    proof
      let x be object;
      assume x in TD;
      then ex y being Element of Bags o st ( x = TotDegree y)&( y in Y);
      hence thesis by ORDINAL1:def 12;
    end;
    then reconsider TD as non empty Subset of NAT by A11;
    set mTD ={y where y is Element of Bags o:y in Y & TotDegree y= min TD};
A12: mTD c= field(gilo)
    proof
      let x be object;
      assume x in mTD;
      then ex y being Element of Bags o st ( x = y)&( y in Y)&(
      TotDegree y = min TD);
      hence thesis by A2;
    end;
    min TD in TD by XXREAL_2:def 7;
    then consider y being Element of Bags o such that
A13: TotDegree y = min TD and
A14: y in Y;
A15: y in mTD by A13,A14;
A16: field ilo = Bags o by ORDERS_1:12;
    ilo is well-ordering by Th22;
    then ilo well_orders field ilo by WELLORD1:4;
    then ilo is_well_founded_in field ilo by WELLORD1:def 5;
    then consider a being object such that
A17: a in mTD and
A18: ilo-Seg(a) misses mTD by A2,A12,A15,A16,WELLORD1:def 3;
A19: ilo-Seg(a) /\ mTD = {} by A18,XBOOLE_0:def 7;
A20: ex a9 being Element of Bags o st ( a9 = a)&( a9 in Y)&(
    TotDegree a9 = min TD) by A17;
    take a;
    thus a in Y by A20;
    now
      assume gilo-Seg(a) /\ Y <> {};
      then consider z being object such that
A21:  z in gilo-Seg(a) /\ Y by XBOOLE_0:def 1;
A22:  z in gilo-Seg(a) by A21,XBOOLE_0:def 4;
A23:  z in Y by A21,XBOOLE_0:def 4;
A24:  z <> a by A22,WELLORD1:1;
A25:  [z,a] in gilo by A22,WELLORD1:1;
      reconsider a, z as Element of Bags o by A8,A20,A23,ORDERS_1:12;
      per cases by XXREAL_0:1;
      suppose
A26:    TotDegree z < TotDegree a;
        TotDegree z in TD by A23;
        hence contradiction by A20,A26,XXREAL_2:def 7;
      end;
      suppose
A27:    TotDegree z = TotDegree a;
        then [z,a] in ilo by A7,A25,Def7;
        then
A28:    z in ilo-Seg(a) by A24,WELLORD1:1;
        z in mTD by A20,A23,A27;
        hence contradiction by A19,A28,XBOOLE_0:def 4;
      end;
      suppose TotDegree z > TotDegree a;
        hence contradiction by A7,A25,Def7;
      end;
    end;
    hence gilo-Seg(a) misses Y by XBOOLE_0:def 7;
  end;
  then gilo is_well_founded_in field gilo by WELLORD1:def 3;
  then gilo well_orders field gilo by A2,A3,A4,A5,A6,WELLORD1:def 5;
  hence thesis by WELLORD1:4;
end;
