14.09.2014 Views

Sémantique Axiomatique ou Logique de Hoare - Ensiie

Sémantique Axiomatique ou Logique de Hoare - Ensiie

Sémantique Axiomatique ou Logique de Hoare - Ensiie

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Exemple : ret<strong>ou</strong>r sur le programme fact<br />

On prend p<strong>ou</strong>r invariant <strong>de</strong> b<strong>ou</strong>cle l’assertion<br />

y ∗ x! = n! ∧ n > 0 ∧ x > 0. Elle est notée Inv ci-<strong>de</strong>ss<strong>ou</strong>s.<br />

VC’({x = n ∧ n > 0} Fact {y=n ! ∧n > 0})=<br />

x=n ∧ n>0 ⇒ VC(y :=1 ;while ..., y=n ! ∧n > 0) =<br />

x=n ∧ n>0 ⇒ VC(y :=1, VC(while ..., y=n ! ∧n > 0)) =<br />

x=n ∧ n>0 ⇒ VC(y :=1 ; Inv ∧ (∀ x, y. Inv ∧ not(x=1) ⇒ y*x*(x-1) !=n ! ∧ x-1>0<br />

∧ n>0) ∧ (¬not(x=1) ∧ Inv ⇒ y=n ! ∧ n>0)=<br />

x=n ∧ n>0 ⇒ (Inv[y ← 1] ∧ (∀ x, y. Inv ∧ not(x=1) ⇒ y*x*(x-1) !=n ! ∧ x-1>0 ∧<br />

n>0) ∧ (¬ not(x=1) ∧ Inv ⇒ y=n ! ∧ n>0)[y← 1]) =<br />

x=n ∧ n>0 ⇒ ((1*x !=n ! ∧ x>0 ∧ n>0) ∧ (∀ x, y. Inv ∧ not(x=1) ⇒<br />

y*x*(x-1) !=n ! ∧ x-1>0 ∧ n>0) ∧ (¬not(x=1) ∧ 1*x !=n ! ∧ x>0 ∧ n>0 ⇒ 1=n !<br />

∧ n>0))<br />

La formule est grosse mais elle se décompose en petits morceaux qui<br />

peuvent se démontrer séparément.<br />

(ENSIIE) <strong>Hoare</strong> 40 / 52

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!