
theorem :: triangle inequality
for R being preordered domRing,
    P being Preordering of R,
    a,b being P-ordered Element of R holds abs(P,a+b) <=P, abs(P,a) + abs(P,b)
proof
let R be preordered domRing, P be Preordering of R,
      a,b be P-ordered Element of R;
A1: 0.R <=P, abs(P,b) by av0;
0.R + abs(P,b) <=P, abs(P,a) + abs(P,b) by c4,av0;
then A: 0.R <=P, abs(P,a) + abs(P,b) by c3,A1;
per cases;
suppose a+b is non P-ordered;
  then not(a+b in P) & not(a+b) in -P by XBOOLE_0:def 3;
  then B: abs(P,a+b) = -1.R by defa;
  -1.R <P, 0.R by c20;
  hence thesis by B,A,c3;
  end;
suppose AS1: a + b is P-ordered;
now assume abs(P,a) + abs(P,b) is P-negative;
  then -0.R <P, -(abs(P,a) + abs(P,b)) by x2,c10;
  then 0.R + (abs(P,a) + abs(P,b)) <P,
             -(abs(P,a) + abs(P,b)) + (abs(P,a) + abs(P,b)) by c4,RLVECT_1:8;
  then 0.R + 0.R <P, abs(P,a) + abs(P,b) + -(abs(P,a) + abs(P,b)) by A,c2,c3;
  hence contradiction by RLVECT_1:5;
  end;
then A1: abs(P,a) + abs(P,b) is P-ordered non P-negative by A,XBOOLE_0:def 3;
B: -(abs(P,a) + abs(P,b)) <=P, a + b
   proof
   -abs(P,a) <=P, a by ineq2;
   then -abs(P,a) + -abs(P,b) <=P, a + -abs(P,b) by c4;
   then B1: -(abs(P,a) + abs(P,b)) <=P, a + -abs(P,b) by RLVECT_1:31;
   -abs(P,b) <=P, b by ineq2;
   then a + -abs(P,b) <=P, a + b by c4;
   hence thesis by B1,c3;
   end;
B1: a + abs(P,b) <=P, abs(P,a) + abs(P,b) by c4,ineq2;
   a + b <=P, (abs(P,a) + abs(P,b))
   proof
     a + b <=P, abs(P,b) + a by c4,ineq2;
     hence thesis by B1,c3;
   end;
hence thesis by AS1,A1,B,ineq1;
end;
end;
