 reserve a,Z1,Z2,Z3 for set,
         x,y,z for object,
         k for Nat;
 reserve S for RelStr;
 reserve P,Q for non empty flat Poset;
 reserve p,p1,p2 for Element of P;
 reserve K for non empty Chain of P;
 reserve X,Y for non empty set;
 reserve D for Subset of X;
 reserve I for Function of X,Y;
 reserve J for Function of [:X,Y:], Y;
 reserve E for Function of X,X;
 reserve D for Subset of X;
 reserve I,I1,I2 for Function of X,Y;
 reserve J,J1,J2 for Function of [:X,Y,Y:], Y;
 reserve E1,E2 for Function of X,X;

theorem
  for f1,g1,f2,g2 being Function of X,Y holds
    E1,E2 is_well_founded_with_minimal_set D &
    (for x being Element of X holds
         (x in D implies f1.x = I1.x & g1.x = I2.x) &
         (not x in D implies f1.x = J1.[x,f1.(E1.x),g1.(E2.x)] &
                             g1.x = J2.[x,f1.(E1.x),g1.(E2.x)]) ) &
    (for x being Element of X holds
         (x in D implies f2.x = I1.x & g2.x = I2.x) &
         (not x in D implies f2.x = J1.[x,f2.(E1.x),g2.(E2.x)] &
                             g2.x = J2.[x,f2.(E1.x),g2.(E2.x)]) )
         implies f1 = f2 & g1 = g2
  proof
    let f1,g1,f2,g2 be Function of X,Y;
    assume
A0: E1,E2 is_well_founded_with_minimal_set D &
    (for x being Element of X holds
         (x in D implies f1.x = I1.x & g1.x = I2.x) &
         (not x in D implies f1.x = J1.[x,f1.(E1.x),g1.(E2.x)] &
                             g1.x = J2.[x,f1.(E1.x),g1.(E2.x)]) ) &
    (for x being Element of X holds
         (x in D implies f2.x = I1.x & g2.x = I2.x) &
         (not x in D implies f2.x = J1.[x,f2.(E1.x),g2.(E2.x)] &
                             g2.x = J2.[x,f2.(E1.x),g2.(E2.x)]) ); then
    consider l be Function of X,NAT such that
A1: for x being Element of X holds
     (l.x <= 0 implies x in D ) &
     (not x in D implies l.(E1.x) < l.x & l.(E2.x) < l.x);
    defpred P[Nat] means
       for x being Element of X st l.x<=$1 holds f1.x = f2.x & g1.x = g2.x;
A2: P[0]
    proof
      let x be Element of X;
      assume l.x <= 0; then
B1:   x in D by A1;
B2:   f1.x = I1.x by A0,B1
          .= f2.x by A0,B1;
      g1.x = I2.x by A0,B1
          .= g2.x by A0,B1;
      hence thesis by B2;
    end;
A3: for k st P[k] holds P[k + 1]
    proof
      let k;
      assume
B0:   P[k];
      let x be Element of X;
      assume
B1:   l.x <= k+1;
      per cases;
        suppose
C0:         x in D;
C1:         f1.x = I1.x by A0,C0
              .= f2.x by A0,C0;
          g1.x = I2.x by A0,C0
              .= g2.x by A0,C0;
          hence thesis by C1;
          end;
        suppose
C0:       not x in D;
          reconsider x1=E1.x,x2=E2.x as Element of X;
          l.x1 + 1 <= l.x & l.x2 + 1 <= l.x by NAT_1:13,A1,C0;
          then l.x1 + 1 <= k + 1 & l.x2 + 1 <= k + 1 by B1,XXREAL_0:2;
          then
          l.x1 <= k & l.x2 <= k by XREAL_1:8;
          then C1:f1.x1 = f2.x1 & g1.x2 = g2.x2 by B0;
C2:         f1.x = J1.[x,f2.x1,g2.x2] by A0,C0,C1
              .= f2.x by A0,C0;
          g1.x = J2.[x,f2.x1,g2.x2] by A0,C0,C1
              .= g2.x by A0,C0;
          hence thesis by C2;
        end;
      end;
A4: for k being Nat holds P[k] from NAT_1:sch 2(A2,A3);
    for x being Element of X holds f1.x = f2.x & g1.x = g2.x
    proof
      let x be Element of X;
      reconsider k = l.x as Nat;
      l.x <= k;
      hence thesis by A4;
    end;
    hence thesis;
  end;
