27
Synthesis, Analysis, and Verification Lecture 03b Lectures: Viktor Kuncak More Hoare Logic. Building Formulas Substitutions

Synthesis, Analysis, and Verification Lecture 03b

  • Upload
    juana

  • View
    32

  • Download
    0

Embed Size (px)

DESCRIPTION

Synthesis, Analysis, and Verification Lecture 03b. More Hoare Logic. Building Formulas Substitutions. Lectures: Viktor Kuncak. Programs, Relations, Formulas. Forms of Hoare Triple. Transitivity Rule. Expanding Paths. Transitive Closure. More on Hoare Logic. see wiki. - PowerPoint PPT Presentation

Citation preview

Page 1: Synthesis, Analysis, and Verification Lecture  03b

Synthesis, Analysis, and VerificationLecture 03b

Lectures: Viktor Kuncak

More Hoare Logic. Building FormulasSubstitutions

Page 2: Synthesis, Analysis, and Verification Lecture  03b

Programs, Relations, Formulas

Page 3: Synthesis, Analysis, and Verification Lecture  03b

Forms of Hoare Triple

Page 4: Synthesis, Analysis, and Verification Lecture  03b

Transitivity Rule

Page 5: Synthesis, Analysis, and Verification Lecture  03b

Expanding Paths

Page 6: Synthesis, Analysis, and Verification Lecture  03b

Transitive Closure

Page 7: Synthesis, Analysis, and Verification Lecture  03b

More on Hoare Logic

• see wiki

Page 8: Synthesis, Analysis, and Verification Lecture  03b

Programs, Relations, Formulas

Page 9: Synthesis, Analysis, and Verification Lecture  03b

Programs to Formulas (VCG)

Three methods• compositionally compute formulas for

relations– then compare them to spec

• forward propagation – compute sp of pre• backward propagation – compute wp of post

Page 10: Synthesis, Analysis, and Verification Lecture  03b

From Programs to Formulas(compositional way)

Given – guarded program p with set of variables V,

Compute– formula F – whose free variables can be x and x’ , for all x in V

such that F holds iff program starting in state given by unprimed variables can end up in state given by primed variables

we should already know the answer

Page 11: Synthesis, Analysis, and Verification Lecture  03b

Construct formulas recursively

Guarded program given by treeLeaves: x=E, assume(P)

assume(P)

x=E

Page 12: Synthesis, Analysis, and Verification Lecture  03b

Tree nodes (recursion)

Non-deterministic choice []

Sequential composition ;

Page 13: Synthesis, Analysis, and Verification Lecture  03b

Consequences

assume(P); c

c; assume(P)

Page 14: Synthesis, Analysis, and Verification Lecture  03b

About One-Point Rules

Which formula simplifications are correct?

For each either– find counterexample, or– prove equivalence (how?)

Page 15: Synthesis, Analysis, and Verification Lecture  03b
Page 16: Synthesis, Analysis, and Verification Lecture  03b
Page 17: Synthesis, Analysis, and Verification Lecture  03b

Definition of Formulas

Page 18: Synthesis, Analysis, and Verification Lecture  03b

Definition of Substitution

Page 19: Synthesis, Analysis, and Verification Lecture  03b

Semantics: Formula Set of states

Page 20: Synthesis, Analysis, and Verification Lecture  03b

formula semantics

Page 21: Synthesis, Analysis, and Verification Lecture  03b

Formula(‘) Set of Pairs of States

Formulas with primed and unprimed variables

Page 22: Synthesis, Analysis, and Verification Lecture  03b

Pairs of Disjoint Functions

Let f1 , f2 - partial functions with disjoint domainThen (f1 , f2) can be represented with (f1 U f2)

Given semantics for sets of partial functions, we also know how to give semantics for relations on such states

Page 23: Synthesis, Analysis, and Verification Lecture  03b

Programs, Relations, Formulas

Page 24: Synthesis, Analysis, and Verification Lecture  03b

Lemma for One-Point Rule

Page 25: Synthesis, Analysis, and Verification Lecture  03b

One Point Rule Proved

Page 26: Synthesis, Analysis, and Verification Lecture  03b

Programs to Formulas (VCG)

Page 27: Synthesis, Analysis, and Verification Lecture  03b

Further Reading

• C A R Hoare and He Jifeng. Unifying Theories of Programming. Prentice Hall, 1998

• Semantics-based Program Analysis via Symbolic Composition of Transfer Relations, PhD dissertation by Christopher Colby, 1996