reserve PM for MetrStruct;
reserve x,y for Element of PM;
reserve r,p,q,s,t for Real;
reserve T for TopSpace;
reserve A for Subset of T;
reserve T for non empty TopSpace;
reserve x for Point of T;
reserve Z,X,V,W,Y,Q for Subset of T;
reserve FX for Subset-Family of T;
reserve a for set;
reserve x,y for Point of T;
reserve A,B for Subset of T;
reserve FX,GX for Subset-Family of T;
reserve x,y,z for Element of PM;
reserve V,W,Y for Subset of PM;

theorem Th35:
  for D being set,f being Function of [:D,D:],REAL holds f
  is_metric_of D iff MetrStruct (#D,f#) is MetrSpace
proof
  let D be set,f be Function of [:D,D:],REAL;
  set DF = MetrStruct (#D,f#);
A1: DF is MetrSpace implies f is_metric_of D
  proof
    assume DF is MetrSpace;
    then reconsider DF as MetrSpace;
    for a,b,c be Element of DF holds ((the distance of DF).(a,b) = 0 iff
a=b) & (the distance of DF).(a,b) = (the distance of DF).(b,a) & (the distance
    of DF).(a,c)<= (the distance of DF).(a,b)+ (the distance of DF).(b,c)
    proof
      let a,b,c be Element of DF;
A2:   (the distance of DF).(a,b) = dist(a,b) by METRIC_1:def 1;
      hence (the distance of DF).(a,b) = 0 iff a=b by METRIC_1:1,2;
      (the distance of DF).(b,a) = dist(b,a) by METRIC_1:def 1;
      hence (the distance of DF).(a,b) = (the distance of DF).(b,a) by A2;
      (the distance of DF).(a,c) = dist(a,c) & (the distance of DF).(b,c)
      = dist(b,c) by METRIC_1:def 1;
      hence thesis by A2,METRIC_1:4;
    end;
    hence thesis;
  end;
  f is_metric_of D implies DF is MetrSpace
  proof
    assume
A3: f is_metric_of D;
    for a,b,c be Element of DF holds (dist(a,b) = 0 iff a=b) & dist(a,b) =
    dist(b,a) & dist(a,c)<=dist(a,b)+dist(b,c)
    proof
      let a,b,c be Element of DF;
A4:   (the distance of DF).(a,b) = dist(a,b) by METRIC_1:def 1;
      hence dist(a,b) = 0 iff a=b by A3;
      (the distance of DF).(b,a) = dist(b,a) by METRIC_1:def 1;
      hence dist(a,b) = dist(b,a) by A3,A4;
      (the distance of DF).(a,c) = dist(a,c) & (the distance of DF).(b,c)
      = dist(b,c) by METRIC_1:def 1;
      hence thesis by A3,A4;
    end;
    hence thesis by METRIC_1:6;
  end;
  hence thesis by A1;
end;
