reserve m,n for Element of NAT,
  i,j for Instruction of SCMPDS,
  I for Program
  of SCMPDS,
  a for Int_position;

theorem Th2:
  for a,b be Int_position holds
   ex f be Function of product the_Values_of SCMPDS,NAT
    st for s being State of SCMPDS holds (s.a = s.b
  implies f.s =0) & (s.a <> s.b implies f.s=max(|.s.a.|,|.s.b.|))
proof
  let a,b be Int_position;
  defpred P[set,set] means ex t be State of SCMPDS st t=$1 & (t.a = t.b
  implies $2 =0) & (t.a <> t.b implies $2=max(|.t.a.|,|.t.b.|));
A1: now
    let s be Element of product the_Values_of SCMPDS;
    per cases;
    suppose
A2:   s.a = s.b;
      reconsider y=0 as Element of NAT;
      take y;
      thus P[s,y] by A2;
    end;
    suppose
A3:   s.a <> s.b;
      set mm=max(|.s.a.|,|.s.b.|);
      reconsider y=mm as Element of NAT by XXREAL_0:16;
      take y;
      thus P[s,y] by A3;
    end;
  end;
  consider f be Function of product the_Values_of SCMPDS, NAT such that
A4: for s be Element of product the_Values_of SCMPDS holds P[s,f.s]
       from FUNCT_2:sch 3(A1);
A5: for s being State of SCMPDS holds P[s,f.s]
   proof
    let s be State of SCMPDS;
    reconsider s as Element of product the_Values_of SCMPDS by CARD_3:107;
    P[s,f.s] by A4;
    hence thesis;
   end;
  take f;
  hereby
    let s be State of SCMPDS;
    P[s,f.s] by A5;
    hence
    (s.a = s.b implies f.s =0) & (s.a <> s.b implies f.s=max(|.s.a.|,
    |.s.b.|));
  end;
end;
