reserve x,x1,x2,y,y9,y1,y2,z,z1,z2 for object,P,X,X1,X2,Y,Y1,Y2,V,Z for set;

theorem Th68:
  for f,g being PartFunc of X,Y st (Y = {} implies X = {}) & f
  tolerates g ex h being PartFunc of X,Y st h is total & f tolerates h & g
  tolerates h
proof
  let f,g be PartFunc of X,Y such that
A1: Y = {} implies X = {} and
A2: f tolerates g;
  now
    per cases;
    suppose
A3:   Y = {};
      then f tolerates <:{},X,Y:> & g tolerates <:{},X,Y:>;
      hence thesis by A1,A3;
    end;
    suppose
A4:   Y <> {};
      set y = the Element of Y;
      defpred P[object,object] means
      ($1 in dom f implies $2 = f.$1) & ($1 in dom g
      implies $2 = g.$1) & (not $1 in dom f & not $1 in dom g implies $2 = y);
A5:   for x being object st x in X ex y9 being object st P[x,y9]
      proof
        let x be object such that
        x in X;
          per cases;
          suppose
A6:         x in dom f & x in dom g;
            take y9 = f.x;
            thus x in dom f implies y9 = f.x;
            x in dom f /\ dom g by A6,XBOOLE_0:def 4;
            hence x in dom g implies y9 = g.x by A2;
            thus not x in dom f & not x in dom g implies y9 = y by A6;
          end;
          suppose
A7:         x in dom f & not x in dom g;
            take y9 = f.x;
            thus (x in dom f implies y9 = f.x) & (x in dom g implies y9 = g.x)
            & (not x in dom f & not x in dom g implies y9 = y) by A7;
          end;
          suppose
A8:         not x in dom f & x in dom g;
            take y9 = g.x;
            thus (x in dom f implies y9 = f.x) & (x in dom g implies y9 = g.x)
            & (not x in dom f & not x in dom g implies y9 = y) by A8;
          end;
          suppose
            not x in dom f & not x in dom g;
            hence thesis;
          end;
      end;
A9:   for x,y1,y2 being object st x in X & P[x,y1] & P[x,y2] holds y1 = y2;
      consider h being Function such that
A10:  dom h = X and
A11:  for x being object st x in X holds P[x,h.x] from FUNCT_1:sch 2(A9,A5);
      rng h c= Y
      proof
        let z be object;
        assume z in rng h;
        then consider x being object such that
A12:    x in dom h and
A13:    z = h.x by FUNCT_1:def 3;
        per cases;
        suppose
A14:      x in dom f & x in dom g;
          then z = f.x by A11,A13;
          hence thesis by A14,Th4;
        end;
        suppose
A15:      x in dom f & not x in dom g;
          then z = f.x by A11,A13;
          hence thesis by A15,Th4;
        end;
        suppose
A16:      not x in dom f & x in dom g;
          then z = g.x by A11,A13;
          hence thesis by A16,Th4;
        end;
        suppose
          not x in dom f & not x in dom g;
          then z = y by A10,A11,A12,A13;
          hence thesis by A4;
        end;
      end;
      then reconsider h9 = h as PartFunc of X,Y by A10,RELSET_1:4;
A17:  f tolerates h
      proof
        let x be object;
        assume x in dom f /\ dom h;
        then x in dom f by XBOOLE_0:def 4;
        hence thesis by A11;
      end;
A18:  g tolerates h
      proof
        let x be object;
        assume x in dom g /\ dom h;
        then x in dom g by XBOOLE_0:def 4;
        hence thesis by A11;
      end;
      h9 is total by A10;
      hence thesis by A17,A18;
    end;
  end;
  hence thesis;
end;
