Tous les livres

Professionnel

Applis À propos Coach Connexion Commencer la lecture

Computer Science · Glossaire

Qu'est-ce que « Hoare triple, Hoare logic, assignment axiom, rule of consequence » ?

Aussi appelé : Hoare triple · Hoare logic · assignment axiom · rule of consequence

Definition 20.1 University Computer Science — Year 3 · Chapitre 20 — Program Verification: Hoare Logic and Model Checking

A Hoare triple {P} S {Q}\{P\}\,S\,\{Q\} is valid when every run of SS from a state satisfying PP that terminates ends in a state satisfying QQ. Hoare logic derives triples by the rules below, where Q[e/x]Q[e/x] is QQ with ee substituted for xx.

  • The assignment axiom: {Q[e/x]}  x=e  {Q}\{Q[e/x]\}\; x = e\; \{Q\}.
  • Sequence: from {P} S1 {R}\{P\}\,S_1\,\{R\} and {R} S2 {Q}\{R\}\,S_2\,\{Q\}, derive {P} S1;S2 {Q}\{P\}\,S_1; S_2\,\{Q\}.
  • If: from {P∧b} S1 {Q}\{P \wedge b\}\,S_1\,\{Q\} and {P∧¬b} S2 {Q}\{P \wedge \neg b\}\,S_2\,\{Q\}, derive {P}\{P\} if b: S1 else: S2 {Q}\{Q\}.
  • While: from {I∧b} S {I}\{I \wedge b\}\,S\,\{I\}, derive {I}\{I\} while b: S {I∧¬b}\{I \wedge \neg b\}.
  • The rule of consequence: from P⇒P′P \Rightarrow P', {P′} S {Q′}\{P'\}\,S\,\{Q'\} and Q′⇒QQ' \Rightarrow Q, derive {P} S {Q}\{P\}\,S\,\{Q\}.
A derivation as a proof tree: each line follows from the one above the bar by the rule named on its right. The two consequence steps need x 10 x < 10 ℝightarrow x + 1 10, which holds for 8-bit integers since x < 10 rules out the wrap, and x 10 (x < 10) ℝightarrow x = 10.
A derivation as a proof tree: each line follows from the one above the bar by the rule named on its right. The two consequence steps need x≤10∧x<10⇒x+1≤10x \le 10 \wedge x < 10 \Rightarrow x + 1 \le 10, which holds for 8-bit integers since x<10x < 10 rules out the wrap, and x≤10∧¬(x<10)⇒x=10x \le 10 \wedge \neg (x < 10) \Rightarrow x = 10.
Lire dans le chapitre →