vendredi 8 octobre 2021

how to compute weakest condition?

if(x < y) 
     x = x + 1
    else
     x = 3 * x 
    {x < 0}

my answer :

 x+1<0 --> x<-1

 x*3<0 --> x<0

so weakest condition is (x<-1) ∩ (x<0) = x<-1 However, the answer sheet says that x<0 is the answer. How can I get the weakest condition?

Aucun commentaire:

Enregistrer un commentaire