
theorem
  for R being non empty RelStr holds R is well_founded iff not ex f
  being sequence of R st f is descending
proof
  let R be non empty RelStr;
  set c = the carrier of R, r = the InternalRel of R;
  hereby
    assume R is well_founded;
    then
A1: r is_well_founded_in c;
    given f being sequence of R such that
A2: f is descending;
A3: dom f = NAT by FUNCT_2:def 1;
    then rng f <> {} by RELAT_1:42;
    then consider a being object such that
A4: a in rng f and
A5: r-Seg(a) misses rng f by A1;
    consider n being object such that
A6: n in dom f and
A7: a = f.n by A4,FUNCT_1:def 3;
    reconsider n as Element of NAT by A6;
    f.(n+1)<>f.n & [f.(n+1),f.n] in the InternalRel of R by A2;
    then
A8: f.(n+1) in r-Seg(f.n) by WELLORD1:1;
    f.(n+1) in rng f by A3,FUNCT_1:def 3;
    hence contradiction by A5,A7,A8,XBOOLE_0:3;
  end;
  assume
A9: not ex f being sequence of R st f is descending;
  assume not R is well_founded;
  then not r is_well_founded_in c;
  then consider Y being set such that
A10: Y c= c and
A11: Y <> {} and
A12: for a being object holds not a in Y or r-Seg(a) meets Y;
  deffunc G(set,set) = the Element of r-Seg($2) /\ Y;
  consider f being Function such that
A13: dom f = NAT and
A14: f.0 = the Element of Y and
A15: for n being Nat holds f.(n+1) = G(n,f.n) from NAT_1:sch 11;
  defpred P[Nat] means f.$1 in Y;
A16: now
    let n be Nat;
    assume P[n];
    then r-Seg(f.n) meets Y by A12;
    then
A17: r-Seg(f.n) /\ Y <> {};
    f.(n+1) = the Element of r-Seg(f.n) /\ Y by A15;
    hence P[n+1] by A17,XBOOLE_0:def 4;
  end;
A18: P[0] by A11,A14;
A19: for n being Nat holds P[n] from NAT_1:sch 2(A18, A16);
  rng f c= c
  proof
    let y be object;
    assume y in rng f;
    then consider x being object such that
A20: x in dom f and
A21: y = f.x by FUNCT_1:def 3;
    reconsider n = x as Element of NAT by A13,A20;
    f.n in Y by A19;
    hence thesis by A10,A21;
  end;
  then reconsider f as sequence of R by A13,FUNCT_2:2;
  now
    let n be Nat;
    r-Seg(f.n) meets Y by A12,A19;
    then
A22: r-Seg(f.n) /\ Y <> {};
    f.(n+1) = the Element of r-Seg(f.n) /\ Y by A15;
    then f.(n+1) in r-Seg(f.n) by A22,XBOOLE_0:def 4;
    hence f.(n+1) <> f.n & [f.(n+1), f.n] in r by WELLORD1:1;
  end;
  then f is descending;
  hence contradiction by A9;
end;
