SlideShare una empresa de Scribd logo
1 de 41
Descargar para leer sin conexión
Verification Conditions for Single-assignment
                  Programs

Daniela da Cruz, Maria João Frade, and Jorge Sousa Pinto

                  Departamento de Informática
                    Universidade do Minho

                          SAC-SVT 2012


                       March 30, 2012




             Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
Context




The generation of verification conditions (VCs) from imperative
code is a well-known problem, with standard solutions.
But surprisingly some aspects of each major approach are still not
very clear: weakest precondition and bounded model checking.




                  Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
Motivation


Our goal is to:
    Use single-assignment (SA) as a vehicle for program
    verification;
    Show how the calculation of efficient WPs can be seen as
    generating verification conditions from path formulas in the
    CFG of the program;
    Give an account of BMC as an efficient method for VC
    generation
    Compare VC generation by symbolic execution, weakest
    precondition and bounded-model checking.




                  Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
Outline


1   Setting

2   Encoding Programs as Formulas using SA

3   VCs with Symbolic Execution

4   VCs with Weakest Preconditions

5   VCs with Bounded Model Checking

6   Conclusions



                  Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
Setting (1)




        C ::= skip | x := e | if b then S else S | assert ψ
         S ::= C | C ; S


A program is correct if for every execution, whenever a command
assert ψ is met, the assertion ψ is satisfied by the current state.
The command assert ψ fails when it is executed in a state that
does not satisfy ψ.




                  Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
Setting (2)



Definition (Verification Conditions)
A set F of assertions is a set of verification conditions for a
command block S whenever |= F implies that S is correct.


Remarks:
     It is indifferent to use one or another set of VCs to establish
     the correctness of a program, but this does not mean that the
     effort involved in automatically proving them is the same.
     We write VCs in a normalized form, as implicative formulas
     γ → ψ.




                   Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
Setting (3)




Criteria comparison:
  1   The size of generated VCs, in terms of the size of the input
      program.
  2   How closely the VCs are related to execution paths.




                    Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
Setting (4)




VC methods differ with respect to the structure of the formulas,
but also the usage of assert commands:
  1   “Lemma” usage: in addition, each assert provides information
      that is added to the context (hypotheses) available to prove
      subsequent asserts.
  2   “Proof-Goal”-usage: asserts simply provide proof goals (but of
      course methods are static and exhaustive);




                    Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
Outline


1   Setting

2   Encoding Programs as Formulas using SA

3   VCs with Symbolic Execution

4   VCs with Weakest Preconditions

5   VCs with Bounded Model Checking

6   Conclusions



                  Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
Encoding Programs as Formulas using SA (1)




The key to verification condition generation is the encoding of the
behavior of programs as logical formulas.
Consider the assignment x := x + 10.
Writing it directly as a formula leads to x = x + 10, which is a
contradiction: there is no state of the program that satisfies it.
The logical value of an equality (or boolean expression) changes
with the execution of a subsequent command.




                   Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
Encoding Programs as Formulas using SA (2)


For programs without loops, one way to solve this problem is by
first converting them into a single-assignment form in which
multiple indexed versions of each variable are used - a new version
is introduced with each assignment made to the original variable.
The program

                 x := x + y ; y := 10; x := x − 10
would have the SA form:

              x1 := x0 + y 0; y 1 := 10; x2 := x1 − 10




                  Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
Encoding Programs as Formulas using SA (3)



Single-assignment programs have the following fundamental
property:
once a variable has been used (either assigned or read as part of a
program expression), it will surely not be assigned again.

Crucially, if an assert command fails in the original program, it will
fail in the single-assignment form.
It is sound thus to check correctness of a program by
checking a single-assignment form of it.




                   Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
Example DSA




         Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
Outline


1   Setting

2   Encoding Programs as Formulas using SA

3   VCs with Symbolic Execution

4   VCs with Weakest Preconditions

5   VCs with Bounded Model Checking

6   Conclusions



                  Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
VCs with Symbolic Execution (1)




Given a single-assignment command block S, let P be the set of
execution paths of its control-flow graph, from START to END, and
Ψ(p) denote the set of assert formulas in a path p ∈ P. The set of
symbolic execution verification conditions of S is defined as follows:

     VCse (S) =      Fe(assert ψ, p) → ψ | for all occurrences
                    of assert ψ in p, p ∈ P and ψ ∈ Ψ(p)




                  Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
VCs with Symbolic Execution (2)


Given an execution path p in the control-flow graph of a program,
its path formula Fe(p) is the conjunctive formula obtained by
traversing the path from START to END and combining:
    for every assignment x := e, the formula x = e;
    for every conditional if b then S t else S f , if the corresponding
    branching node is crossed towards the then branch (resp. else
    branch), the formula b (resp. ¬b);
    for skip and assert φ commands, the formula true.

Fe(C , p) denotes the formula obtained by traversing the prefix of
path p between START and C (exclusive of C ).




                  Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
VCs with Symbolic Execution (3)




Clearly the validity of all VCs implies that a particular command
assert ψ will be executed (in any path containing it) only in states
that satisfy ψ, thus VCse (S) indeed constitutes a set of verification
conditions for the program.




                   Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
VCs with Symbolic Execution (3)



Remarks:
    There is potentially an exponential number of paths, thus an
    exponential number of VCs will be generated in the worst case.
    VCse can be modified to avoid exponential explosion of the
    size of the generated formulas, but the assertions need to be
    added to crucial points of the programs (e.g. SPARK tool).
    The one-to-one association between execution paths and VCs
    is advantageous for debugging.




                 Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
VCs with Symbolic Execution - Example


1.   x0 < 0 ∧ x1 = −x0 ∧ x2 = x1 ∧ y3 = y0 ∧ c0 > 0∧
     c1 = c0 − 1 ∧ c2 = c1                                          → x2 ≥ 0
2.   x0 < 0 ∧ x1 = −x0 ∧ x2 = x1 ∧ y3 = y0 ∧ ¬c0 > 0
     ∧ c2 = c0                                                      → x2 ≥ 0
3.   ¬x0 < 0 ∧ y0 < 0 ∧ y1 = −y0 ∧ y2 = y1 ∧ x2 = x0
     ∧ y 3 = y 2 ∧ c0 > 0 ∧ c1 = c0 − 1 ∧ c2 = c1                   → x2 ≥ 0
4.   ¬x0 < 0 ∧ y0 < 0 ∧ y1 = −y0 ∧ y2 = y1 ∧ x2 = x0 ∧
     y3 = y2 ∧ ¬c0 > 0 ∧ c2 = c0                                    → x2 ≥ 0
5.   ¬x0 < 0 ∧ ¬y0 < 0 ∧ y2 = y0 ∧ x2 = x0 ∧ y3 = y2 ∧
     c0 > 0 ∧ c1 = c0 − 1 ∧ c2 = c1                                 → x2 ≥ 0
6.   ¬x0 < 0 ∧ ¬y0 < 0 ∧ y2 = y0 ∧ x2 = x0 ∧ y3 = y2 ∧
     ¬c0 > 0 ∧ c2 = c0                                              → x2 ≥ 0




                 Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
Outline


1   Setting

2   Encoding Programs as Formulas using SA

3   VCs with Symbolic Execution

4   VCs with Weakest Preconditions

5   VCs with Bounded Model Checking

6   Conclusions



                  Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
VCs with Weakest Preconditions (1)

Given an assertion φ, the weakest precondition of a program with
respect to φ is defined as follows:



                       wp(skip, φ) = φ
                    wp(x := e, φ) = φ[e/x]
      wp(if b then S t else S f , φ) = (b → wp(S t , φ))
                                             ∧ (¬b → wp(S f , φ))
                       wp(C ; S, φ) = wp(C , wp(S, φ))
                  wp(assert ψ, φ) = ψ ∧ φ

This notion of weakest precondition is conservative.
The assertion wp(S, true) is a verification condition for the
program block S, since it ensures that no assert fails.

                  Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
VCs with Weakest Preconditions (2)


Remarks:
    Produces a single VC, but its size is in the worst case
    exponential in the size of the program.

                         wp(Swc ; assert ψ, true)
    where


                         t       f                       t       f
       Swc = if b1 then S1 else S1 ; . . . ; if bn then Sn else Sn

    This method has the advantage of not requiring conversion to
    single assignment form.



                  Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
VCs with Weakest Preconditions (3) - Example




       wp(ABS, true)
       = wp(C1 ; C2 , x ≥ 0)
       = wp(C1 , (c > 0 → x ≥ 0) ∧ (¬c > 0 → x ≥ 0))
       = (x < 0 → (c > 0 → −x ≥ 0) ∧ (¬c > 0 → −x ≥ 0))
          ∧ (¬x < 0 → wp(if y < 0 then y := −y else skip,
                               (c > 0 → x ≥ 0) ∧ (¬c > 0 → x ≥ 0)))
       = (x < 0 → (c > 0 → −x ≥ 0) ∧ (¬c > 0 → −x ≥ 0))
          ∧ (¬x < 0 → (y < 0 → (c > 0 → x ≥ 0) ∧ (¬c > 0 → x ≥ 0))
                   ∧ (¬y < 0 → (c > 0 → x ≥ 0) ∧ (¬c > 0 → x ≥ 0)))



Normalizing, by applying distributivity yields...



                       Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
VCs with Weakest Preconditions (4) - Example



                 1.     x < 0 → c > 0 → −x ≥ 0
                 2.     x < 0 → ¬c > 0 → −x ≥ 0
                 3.     ¬x < 0 → y < 0 → c > 0 → x ≥ 0
                 4.     ¬x < 0 → y < 0 → ¬c > 0 → x ≥ 0
                 5.     ¬x < 0 → ¬y < 0 → c > 0 → x ≥ 0
                 6.     ¬x < 0 → ¬y < 0 → ¬c > 0 → x ≥ 0



In this normalized form it becomes obvious that the effort of
discharging the proof obligations is basically the same as for path
analysis by symbolic execution.




                      Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
VCs with Efficient Weakest Preconditions (1)



An alternative notion to the conservative weakest precondition is
that of weakest liberal precondition wlp(S, φ): the postcondition is
only required to be satisfied if the program terminates correctly.
For programs without iteration, the weakest liberal precondition is
defined in the same way as the conservative weakest precondition,
except for the assert command:

                     wlp(assert ψ, φ) = ψ → φ




                   Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
VCs with Efficient Weakest Preconditions (2)


The relation between both notions is well-known:
Lemma
For any command block S and assertion φ,

              wp(S, φ) ≡ wlp(S, φ) ∧ wp(S, true)

The relevance of this notion is that the weakest liberal precondition
of a single-assignment program S with respect to φ can be
computed from the linear size formula F(S) of the program without
requiring further traversals of S, so there are no opportunities for
duplicating φ.




                   Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
VCs with Efficient Weakest Preconditions (3)




                          F(skip) = true
                      F(x := e) = x = e
        F(if b then S else S f ) = (b ∧ F(S t )) ∨ (¬b ∧ F(S f ))
                      t

                          F(C ; S) = F(C ) ∧ F(S)
                    F(assert ψ) = ψ



Let S be a single-assignment command block. Then for any
assertion φ, wlp(S, φ) ≡ F(S) → φ.




                   Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
VCs with Efficient Weakest Preconditions (4) —
    Example



         wp(ABSSA, true)
         = wp(C1 ; C2 ; assert x2 ≥ 0, true)
         = F(C1 ; C2 ) → x2 ≥ 0
         = ((x0 < 0 ∧ x1 = −x0 ∧ x2 = x1 ∧ y3 = y0 )∨
            (¬x0 < 0 ∧ ((y0 < 0 ∧ y1 = −y0 ∧ y2 = y1 )∨
            (¬y0 < 0 ∧ y2 = y0 )) ∧ x2 = x0 ∧ y3 = y2 ))
            ∧ ((c0 > 0 ∧ c1 = c0 − 1 ∧ c2 = c1 )
            ∨ (¬c0 > 0 ∧ c2 = c0 ))          → x2 ≥ 0

But what does the VC look like in general?

                  Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
VCs with Efficient Weakest Preconditions (5)



The set of efficient weakest precondition verification conditions of S
is defined as follows:
    VCwp (S) =      Fp(assert ψ, S) → ψ | for all assertions ψ
                     and all occurrences of assert ψ in S

The path formula Fp(C , S) of C in S describes the entire set of
paths from START to a specific command, at a concrete point of
the program.




                  Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
VCs with Efficient Weakest Preconditions (6)


Remarks:
    Unlike with symbolic execution, there is no direct association
    between a single invalid VC and an error path, which is the
    price to pay for efficiency.
    We avoid exponential explosion: in general, the size of each
    VC is worst-case linear in the size n of the program, and there
    are k VCs, with k the number of assert commands, which is
    also linear in n in the worst-case. So overall VCwc is of
    quadratic size in n.
    “Lemma-usage” of asserts: Fp includes assert information.




                  Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
Outline


1   Setting

2   Encoding Programs as Formulas using SA

3   VCs with Symbolic Execution

4   VCs with Weakest Preconditions

5   VCs with Bounded Model Checking

6   Conclusions



                  Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
VCs with Bounded Model Checking (1)


From a program S we extract two sets of formulas, such that:
P is a logical consequence of C (the entailment C |= P holds), if
and only if no assert command fails in any execution of S.
C describes logically the operational contents of the program, and
P is extracted from the assert formulas that can be found in it.
This technique explicitly assumes that a satisfiability-based tool is
used to find models corresponding to an execution of the program
that violates at least one assert command:

                               C ∪ {¬      P}




                   Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
VCs with Bounded Model Checking (2)



To see that this can be formulated in terms of verification
conditions, it suffices to observe that for finite C the semantic
entailment problem
                             C |=    P
is equivalent to the validity problem

                             |=      C→        P




                   Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
VCs with Bounded Model Checking (3)


For our programs without loops the method applies the following
steps:
  1   The program is converted into single-assignment form;
  2   The resulting program is then converted into a sequence of
      commands on the form if b then Ca else skip, with Ca an
      atomic command.
  3   Extract the model from the Conditional Normal Form.
          For every command if b then x := e else skip in the program,
          C includes the formula b → x = e;
          For every command if b then assert ψ else skip in the
          program, P includes the formula b → ψ.
  4   Generate VC:      C→         P.



                     Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
VCs with Bounded Model Checking (3) - Example



ABSCNF : if   x0 < 0 then x1 := −x0 else skip ;
         if   x0 < 0 then x2 := x1 else skip ;
         if   x0 < 0 then y3 := y0 else skip ;
         if   ¬(x0 < 0) ∧ y0 < 0 then y1 := −y0 else skip ;
         if   ¬(x0 < 0) ∧ y0 < 0 then y2 := y1 else skip ;
         if   ¬(x0 < 0) ∧ ¬(y0 < 0) then y2 := y0 else skip ;
         if   ¬(x0 < 0) then x2 := x0 else skip ;
         if   ¬(x0 < 0) then y3 := y2 else skip ;
         if   c0 > 0 then c1 := c0 − 1 else skip ;
         if   c0 > 0 then c2 := c1 else skip ;
         if   ¬(c0 > 0) then c2 := c0 else skip ;
         if   true then assert x2 ≥ 0 else skip



              Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
VCs with Bounded Model Checking (4) - Example


      C : 1.      x0 < 0 → x1 = −x0
          2.      x0 < 0 → x2 = x1
          3.      x0 < 0 → y3 = y0
          4.      ¬(x0 < 0) ∧ y0 < 0 → y1 = −y0
          5.      ¬(x0 < 0) ∧ y0 < 0 → y2 = y1
          6.      ¬(x0 < 0) ∧ ¬(y0 < 0) → y2 = y0
          7.      ¬(x0 < 0) → x2 = x0
          8.      ¬(x0 < 0) → y3 = y2
          9.      c0 > 0 → c1 = c0 − 1
        10.       c0 > 0 → c2 = c1
        11.       ¬(c0 > 0) → c2 = c0
      P : 1.      true → x2 ≥ 0



               Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
VCs with Bounded Model Checking (4)


  C can then be written as Fbmc(S), where:
     S denotes the program that results from replacing every
     command assert ψ in S by skip.
     Fbmc(S) is a variant of F(S);

P on the other hand can be written as follows:
               Fb(assert ψ, S) → ψ | for all assertions ψ
                  and all occurrences of assert ψ in S

Fb(C,S) captures only the branching information that enables the
execution of the command C .




                   Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
VCs with Bounded Model Checking (5)



The verification condition C → P can now be split using basic
equivalences to obtain a set of normalized VCs:
Given a single-assignment command block S, the set of bounded
model checking verification conditions of S is defined as follows:

    VCbmc (S) =       Fbmc(S) ∧ Fb(assert ψ, S) → ψ | for
         all assertions ψ and all occurrences of assert ψ in S




                  Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
Outline


1   Setting

2   Encoding Programs as Formulas using SA

3   VCs with Symbolic Execution

4   VCs with Weakest Preconditions

5   VCs with Bounded Model Checking

6   Conclusions



                  Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
Conclusions



In BMC, the formulas occurring as antecedents of VCs do not
include assert formulas, whereas in the efficient WP method it
does, which allows them to be used as lemmas.
The size of VCs is in both cases linear for programs with a
single postcondition assert command; for programs with an
arbitrary number of such commands both have a quadratic
bound.
Symbolic execution generates VCs of exponential-size in the
worst-case, but offers a one-to-one association between VCs
and execution paths, valuable for error-tracing.




             Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs
Conclusions



None of the methods can be said to always generate smaller
VCs than the other.
Since it is difficult to judge the performance of automatic
provers (and the effect of operations like splitting, which
increase the size of formulas but not necessarily make proofs
harder), an empirical comparison seems to be required.
Build a VCGen based on the BMC technique for Boogie
programs.
Include the iteration.




              Cruz, Frade & Pinto   Verification Conditions for Single-assignment Programs

Más contenido relacionado

Destacado

Life in Extreme
Life in ExtremeLife in Extreme
Life in ExtremeMihex
 
NNDKP_Viata privata in social media
NNDKP_Viata privata in social mediaNNDKP_Viata privata in social media
NNDKP_Viata privata in social mediaNestor_Nestor
 
Quiz zathon mains with ans
Quiz zathon mains with ansQuiz zathon mains with ans
Quiz zathon mains with ansDevesh Pandey
 
Thoda Automatic Wala - Auto Finals
Thoda Automatic Wala - Auto FinalsThoda Automatic Wala - Auto Finals
Thoda Automatic Wala - Auto FinalsDevesh Pandey
 
ABIERTO PEDIDO CATALOGO RESTYLE
ABIERTO PEDIDO CATALOGO RESTYLEABIERTO PEDIDO CATALOGO RESTYLE
ABIERTO PEDIDO CATALOGO RESTYLEKasi Radikal
 
디컨특강과제
디컨특강과제디컨특강과제
디컨특강과제Park SooJin
 
Novikova ev presentaciya
Novikova ev presentaciyaNovikova ev presentaciya
Novikova ev presentaciyakravhenko
 
Operation Pillar of Defese
Operation Pillar of DefeseOperation Pillar of Defese
Operation Pillar of DefeseMihex
 
Another lost flight - The disappearance of Malaysia Airlines Flight 370 remin...
Another lost flight - The disappearance of Malaysia Airlines Flight 370 remin...Another lost flight - The disappearance of Malaysia Airlines Flight 370 remin...
Another lost flight - The disappearance of Malaysia Airlines Flight 370 remin...Richard Kelley
 
Immochan allasborze 2011_krepelka
Immochan allasborze 2011_krepelkaImmochan allasborze 2011_krepelka
Immochan allasborze 2011_krepelkaborze
 
Day 6 recycle grey water
Day 6 recycle grey water Day 6 recycle grey water
Day 6 recycle grey water vigyanashram
 
EEZI Benefits For Employers
EEZI Benefits For EmployersEEZI Benefits For Employers
EEZI Benefits For Employerspthealth
 
Looping presentation
Looping presentationLooping presentation
Looping presentationcandicenovak
 
100 of the worlds tallest buildings , libro de arquitectura, los 100 edifici...
100 of the worlds tallest buildings  , libro de arquitectura, los 100 edifici...100 of the worlds tallest buildings  , libro de arquitectura, los 100 edifici...
100 of the worlds tallest buildings , libro de arquitectura, los 100 edifici...Andrea Valdivia Salinas
 
Victorious christian living
Victorious christian livingVictorious christian living
Victorious christian livingerythraea
 

Destacado (20)

Life in Extreme
Life in ExtremeLife in Extreme
Life in Extreme
 
NNDKP_Viata privata in social media
NNDKP_Viata privata in social mediaNNDKP_Viata privata in social media
NNDKP_Viata privata in social media
 
Quiz zathon mains with ans
Quiz zathon mains with ansQuiz zathon mains with ans
Quiz zathon mains with ans
 
Thoda Automatic Wala - Auto Finals
Thoda Automatic Wala - Auto FinalsThoda Automatic Wala - Auto Finals
Thoda Automatic Wala - Auto Finals
 
ABIERTO PEDIDO CATALOGO RESTYLE
ABIERTO PEDIDO CATALOGO RESTYLEABIERTO PEDIDO CATALOGO RESTYLE
ABIERTO PEDIDO CATALOGO RESTYLE
 
디컨특강과제
디컨특강과제디컨특강과제
디컨특강과제
 
Novikova ev presentaciya
Novikova ev presentaciyaNovikova ev presentaciya
Novikova ev presentaciya
 
Operation Pillar of Defese
Operation Pillar of DefeseOperation Pillar of Defese
Operation Pillar of Defese
 
Session2 bahan presentasi ministry of transport
Session2 bahan presentasi ministry of transportSession2 bahan presentasi ministry of transport
Session2 bahan presentasi ministry of transport
 
Deck
DeckDeck
Deck
 
Another lost flight - The disappearance of Malaysia Airlines Flight 370 remin...
Another lost flight - The disappearance of Malaysia Airlines Flight 370 remin...Another lost flight - The disappearance of Malaysia Airlines Flight 370 remin...
Another lost flight - The disappearance of Malaysia Airlines Flight 370 remin...
 
Work book5
Work book5Work book5
Work book5
 
Immochan allasborze 2011_krepelka
Immochan allasborze 2011_krepelkaImmochan allasborze 2011_krepelka
Immochan allasborze 2011_krepelka
 
Ppd ssf open access mar13
Ppd ssf open access mar13Ppd ssf open access mar13
Ppd ssf open access mar13
 
Day 6 recycle grey water
Day 6 recycle grey water Day 6 recycle grey water
Day 6 recycle grey water
 
EEZI Benefits For Employers
EEZI Benefits For EmployersEEZI Benefits For Employers
EEZI Benefits For Employers
 
Looping presentation
Looping presentationLooping presentation
Looping presentation
 
100 of the worlds tallest buildings , libro de arquitectura, los 100 edifici...
100 of the worlds tallest buildings  , libro de arquitectura, los 100 edifici...100 of the worlds tallest buildings  , libro de arquitectura, los 100 edifici...
100 of the worlds tallest buildings , libro de arquitectura, los 100 edifici...
 
Victorious christian living
Victorious christian livingVictorious christian living
Victorious christian living
 
Jasmin anguiano
Jasmin anguianoJasmin anguiano
Jasmin anguiano
 

Similar a Verification Conditions for Single-Assignment Programs

Verification, Slicing and Visualization of Programs with Contracts
Verification, Slicing and Visualization of Programs with ContractsVerification, Slicing and Visualization of Programs with Contracts
Verification, Slicing and Visualization of Programs with Contractspinker
 
Interactive Verification of Safety-Critical Systems
Interactive Verification of Safety-Critical SystemsInteractive Verification of Safety-Critical Systems
Interactive Verification of Safety-Critical SystemsDaniela Da Cruz
 
Staroletov Design by Contract, verification of Cyber-physical systems
Staroletov Design by Contract, verification of Cyber-physical systemsStaroletov Design by Contract, verification of Cyber-physical systems
Staroletov Design by Contract, verification of Cyber-physical systemsSergey Staroletov
 
A Comparative Analysis of Slicing for Structured Programs
A Comparative Analysis of Slicing for Structured ProgramsA Comparative Analysis of Slicing for Structured Programs
A Comparative Analysis of Slicing for Structured ProgramsEditor IJCATR
 
3 chapter three - part 1.pdf
3 chapter three - part 1.pdf3 chapter three - part 1.pdf
3 chapter three - part 1.pdfAbenezerAsefa1
 
Source code of WPF samples by Microsoft was checked
Source code of WPF samples by Microsoft was checkedSource code of WPF samples by Microsoft was checked
Source code of WPF samples by Microsoft was checkedPVS-Studio
 
TOWARDS PARSIMONIOUS RESOURCE ALLOCATION IN CONTEXT-AWARE N-VERSION PROGRAMMING
TOWARDS PARSIMONIOUS RESOURCE ALLOCATION IN CONTEXT-AWARE N-VERSION PROGRAMMINGTOWARDS PARSIMONIOUS RESOURCE ALLOCATION IN CONTEXT-AWARE N-VERSION PROGRAMMING
TOWARDS PARSIMONIOUS RESOURCE ALLOCATION IN CONTEXT-AWARE N-VERSION PROGRAMMINGVincenzo De Florio
 
Software testing ari force institute of tech.
Software testing ari force institute of tech.Software testing ari force institute of tech.
Software testing ari force institute of tech.Sanjith Ml
 
System Verilog 2009 & 2012 enhancements
System Verilog 2009 & 2012 enhancementsSystem Verilog 2009 & 2012 enhancements
System Verilog 2009 & 2012 enhancementsSubash John
 
Hello, Is That FreeSWITCH? Then We're Coming to Check You!
Hello, Is That FreeSWITCH? Then We're Coming to Check You!Hello, Is That FreeSWITCH? Then We're Coming to Check You!
Hello, Is That FreeSWITCH? Then We're Coming to Check You!PVS-Studio
 
Automated Program Repair Keynote talk
Automated Program Repair Keynote talkAutomated Program Repair Keynote talk
Automated Program Repair Keynote talkAbhik Roychoudhury
 
Net practicals lab mannual
Net practicals lab mannualNet practicals lab mannual
Net practicals lab mannualAbhishek Pathak
 
Using adaptive cursor sharing (acs) to produce multiple optimal plans v2
Using adaptive cursor sharing (acs) to produce multiple optimal plans v2Using adaptive cursor sharing (acs) to produce multiple optimal plans v2
Using adaptive cursor sharing (acs) to produce multiple optimal plans v2Enkitec
 
7-White Box Testing.ppt
7-White Box Testing.ppt7-White Box Testing.ppt
7-White Box Testing.pptHirenderPal
 

Similar a Verification Conditions for Single-Assignment Programs (20)

Verification, Slicing and Visualization of Programs with Contracts
Verification, Slicing and Visualization of Programs with ContractsVerification, Slicing and Visualization of Programs with Contracts
Verification, Slicing and Visualization of Programs with Contracts
 
Interactive Verification of Safety-Critical Systems
Interactive Verification of Safety-Critical SystemsInteractive Verification of Safety-Critical Systems
Interactive Verification of Safety-Critical Systems
 
Static Analysis and Verification of C Programs
Static Analysis and Verification of C ProgramsStatic Analysis and Verification of C Programs
Static Analysis and Verification of C Programs
 
APSEC2020 Keynote
APSEC2020 KeynoteAPSEC2020 Keynote
APSEC2020 Keynote
 
Staroletov Design by Contract, verification of Cyber-physical systems
Staroletov Design by Contract, verification of Cyber-physical systemsStaroletov Design by Contract, verification of Cyber-physical systems
Staroletov Design by Contract, verification of Cyber-physical systems
 
A Comparative Analysis of Slicing for Structured Programs
A Comparative Analysis of Slicing for Structured ProgramsA Comparative Analysis of Slicing for Structured Programs
A Comparative Analysis of Slicing for Structured Programs
 
3 chapter three - part 1.pdf
3 chapter three - part 1.pdf3 chapter three - part 1.pdf
3 chapter three - part 1.pdf
 
white box testing.ppt
white box testing.pptwhite box testing.ppt
white box testing.ppt
 
Source code of WPF samples by Microsoft was checked
Source code of WPF samples by Microsoft was checkedSource code of WPF samples by Microsoft was checked
Source code of WPF samples by Microsoft was checked
 
TOWARDS PARSIMONIOUS RESOURCE ALLOCATION IN CONTEXT-AWARE N-VERSION PROGRAMMING
TOWARDS PARSIMONIOUS RESOURCE ALLOCATION IN CONTEXT-AWARE N-VERSION PROGRAMMINGTOWARDS PARSIMONIOUS RESOURCE ALLOCATION IN CONTEXT-AWARE N-VERSION PROGRAMMING
TOWARDS PARSIMONIOUS RESOURCE ALLOCATION IN CONTEXT-AWARE N-VERSION PROGRAMMING
 
Software testing ari force institute of tech.
Software testing ari force institute of tech.Software testing ari force institute of tech.
Software testing ari force institute of tech.
 
System Verilog 2009 & 2012 enhancements
System Verilog 2009 & 2012 enhancementsSystem Verilog 2009 & 2012 enhancements
System Verilog 2009 & 2012 enhancements
 
Hello, Is That FreeSWITCH? Then We're Coming to Check You!
Hello, Is That FreeSWITCH? Then We're Coming to Check You!Hello, Is That FreeSWITCH? Then We're Coming to Check You!
Hello, Is That FreeSWITCH? Then We're Coming to Check You!
 
Automated Program Repair Keynote talk
Automated Program Repair Keynote talkAutomated Program Repair Keynote talk
Automated Program Repair Keynote talk
 
CP Handout#4
CP Handout#4CP Handout#4
CP Handout#4
 
Net practicals lab mannual
Net practicals lab mannualNet practicals lab mannual
Net practicals lab mannual
 
Java chapter 5
Java chapter 5Java chapter 5
Java chapter 5
 
Using adaptive cursor sharing (acs) to produce multiple optimal plans v2
Using adaptive cursor sharing (acs) to produce multiple optimal plans v2Using adaptive cursor sharing (acs) to produce multiple optimal plans v2
Using adaptive cursor sharing (acs) to produce multiple optimal plans v2
 
random test
random testrandom test
random test
 
7-White Box Testing.ppt
7-White Box Testing.ppt7-White Box Testing.ppt
7-White Box Testing.ppt
 

Último

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 

Último (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Verification Conditions for Single-Assignment Programs

  • 1. Verification Conditions for Single-assignment Programs Daniela da Cruz, Maria João Frade, and Jorge Sousa Pinto Departamento de Informática Universidade do Minho SAC-SVT 2012 March 30, 2012 Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 2. Context The generation of verification conditions (VCs) from imperative code is a well-known problem, with standard solutions. But surprisingly some aspects of each major approach are still not very clear: weakest precondition and bounded model checking. Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 3. Motivation Our goal is to: Use single-assignment (SA) as a vehicle for program verification; Show how the calculation of efficient WPs can be seen as generating verification conditions from path formulas in the CFG of the program; Give an account of BMC as an efficient method for VC generation Compare VC generation by symbolic execution, weakest precondition and bounded-model checking. Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 4. Outline 1 Setting 2 Encoding Programs as Formulas using SA 3 VCs with Symbolic Execution 4 VCs with Weakest Preconditions 5 VCs with Bounded Model Checking 6 Conclusions Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 5. Setting (1) C ::= skip | x := e | if b then S else S | assert ψ S ::= C | C ; S A program is correct if for every execution, whenever a command assert ψ is met, the assertion ψ is satisfied by the current state. The command assert ψ fails when it is executed in a state that does not satisfy ψ. Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 6. Setting (2) Definition (Verification Conditions) A set F of assertions is a set of verification conditions for a command block S whenever |= F implies that S is correct. Remarks: It is indifferent to use one or another set of VCs to establish the correctness of a program, but this does not mean that the effort involved in automatically proving them is the same. We write VCs in a normalized form, as implicative formulas γ → ψ. Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 7. Setting (3) Criteria comparison: 1 The size of generated VCs, in terms of the size of the input program. 2 How closely the VCs are related to execution paths. Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 8. Setting (4) VC methods differ with respect to the structure of the formulas, but also the usage of assert commands: 1 “Lemma” usage: in addition, each assert provides information that is added to the context (hypotheses) available to prove subsequent asserts. 2 “Proof-Goal”-usage: asserts simply provide proof goals (but of course methods are static and exhaustive); Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 9. Outline 1 Setting 2 Encoding Programs as Formulas using SA 3 VCs with Symbolic Execution 4 VCs with Weakest Preconditions 5 VCs with Bounded Model Checking 6 Conclusions Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 10. Encoding Programs as Formulas using SA (1) The key to verification condition generation is the encoding of the behavior of programs as logical formulas. Consider the assignment x := x + 10. Writing it directly as a formula leads to x = x + 10, which is a contradiction: there is no state of the program that satisfies it. The logical value of an equality (or boolean expression) changes with the execution of a subsequent command. Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 11. Encoding Programs as Formulas using SA (2) For programs without loops, one way to solve this problem is by first converting them into a single-assignment form in which multiple indexed versions of each variable are used - a new version is introduced with each assignment made to the original variable. The program x := x + y ; y := 10; x := x − 10 would have the SA form: x1 := x0 + y 0; y 1 := 10; x2 := x1 − 10 Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 12. Encoding Programs as Formulas using SA (3) Single-assignment programs have the following fundamental property: once a variable has been used (either assigned or read as part of a program expression), it will surely not be assigned again. Crucially, if an assert command fails in the original program, it will fail in the single-assignment form. It is sound thus to check correctness of a program by checking a single-assignment form of it. Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 13. Example DSA Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 14. Outline 1 Setting 2 Encoding Programs as Formulas using SA 3 VCs with Symbolic Execution 4 VCs with Weakest Preconditions 5 VCs with Bounded Model Checking 6 Conclusions Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 15. VCs with Symbolic Execution (1) Given a single-assignment command block S, let P be the set of execution paths of its control-flow graph, from START to END, and Ψ(p) denote the set of assert formulas in a path p ∈ P. The set of symbolic execution verification conditions of S is defined as follows: VCse (S) = Fe(assert ψ, p) → ψ | for all occurrences of assert ψ in p, p ∈ P and ψ ∈ Ψ(p) Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 16. VCs with Symbolic Execution (2) Given an execution path p in the control-flow graph of a program, its path formula Fe(p) is the conjunctive formula obtained by traversing the path from START to END and combining: for every assignment x := e, the formula x = e; for every conditional if b then S t else S f , if the corresponding branching node is crossed towards the then branch (resp. else branch), the formula b (resp. ¬b); for skip and assert φ commands, the formula true. Fe(C , p) denotes the formula obtained by traversing the prefix of path p between START and C (exclusive of C ). Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 17. VCs with Symbolic Execution (3) Clearly the validity of all VCs implies that a particular command assert ψ will be executed (in any path containing it) only in states that satisfy ψ, thus VCse (S) indeed constitutes a set of verification conditions for the program. Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 18. VCs with Symbolic Execution (3) Remarks: There is potentially an exponential number of paths, thus an exponential number of VCs will be generated in the worst case. VCse can be modified to avoid exponential explosion of the size of the generated formulas, but the assertions need to be added to crucial points of the programs (e.g. SPARK tool). The one-to-one association between execution paths and VCs is advantageous for debugging. Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 19. VCs with Symbolic Execution - Example 1. x0 < 0 ∧ x1 = −x0 ∧ x2 = x1 ∧ y3 = y0 ∧ c0 > 0∧ c1 = c0 − 1 ∧ c2 = c1 → x2 ≥ 0 2. x0 < 0 ∧ x1 = −x0 ∧ x2 = x1 ∧ y3 = y0 ∧ ¬c0 > 0 ∧ c2 = c0 → x2 ≥ 0 3. ¬x0 < 0 ∧ y0 < 0 ∧ y1 = −y0 ∧ y2 = y1 ∧ x2 = x0 ∧ y 3 = y 2 ∧ c0 > 0 ∧ c1 = c0 − 1 ∧ c2 = c1 → x2 ≥ 0 4. ¬x0 < 0 ∧ y0 < 0 ∧ y1 = −y0 ∧ y2 = y1 ∧ x2 = x0 ∧ y3 = y2 ∧ ¬c0 > 0 ∧ c2 = c0 → x2 ≥ 0 5. ¬x0 < 0 ∧ ¬y0 < 0 ∧ y2 = y0 ∧ x2 = x0 ∧ y3 = y2 ∧ c0 > 0 ∧ c1 = c0 − 1 ∧ c2 = c1 → x2 ≥ 0 6. ¬x0 < 0 ∧ ¬y0 < 0 ∧ y2 = y0 ∧ x2 = x0 ∧ y3 = y2 ∧ ¬c0 > 0 ∧ c2 = c0 → x2 ≥ 0 Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 20. Outline 1 Setting 2 Encoding Programs as Formulas using SA 3 VCs with Symbolic Execution 4 VCs with Weakest Preconditions 5 VCs with Bounded Model Checking 6 Conclusions Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 21. VCs with Weakest Preconditions (1) Given an assertion φ, the weakest precondition of a program with respect to φ is defined as follows: wp(skip, φ) = φ wp(x := e, φ) = φ[e/x] wp(if b then S t else S f , φ) = (b → wp(S t , φ)) ∧ (¬b → wp(S f , φ)) wp(C ; S, φ) = wp(C , wp(S, φ)) wp(assert ψ, φ) = ψ ∧ φ This notion of weakest precondition is conservative. The assertion wp(S, true) is a verification condition for the program block S, since it ensures that no assert fails. Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 22. VCs with Weakest Preconditions (2) Remarks: Produces a single VC, but its size is in the worst case exponential in the size of the program. wp(Swc ; assert ψ, true) where t f t f Swc = if b1 then S1 else S1 ; . . . ; if bn then Sn else Sn This method has the advantage of not requiring conversion to single assignment form. Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 23. VCs with Weakest Preconditions (3) - Example wp(ABS, true) = wp(C1 ; C2 , x ≥ 0) = wp(C1 , (c > 0 → x ≥ 0) ∧ (¬c > 0 → x ≥ 0)) = (x < 0 → (c > 0 → −x ≥ 0) ∧ (¬c > 0 → −x ≥ 0)) ∧ (¬x < 0 → wp(if y < 0 then y := −y else skip, (c > 0 → x ≥ 0) ∧ (¬c > 0 → x ≥ 0))) = (x < 0 → (c > 0 → −x ≥ 0) ∧ (¬c > 0 → −x ≥ 0)) ∧ (¬x < 0 → (y < 0 → (c > 0 → x ≥ 0) ∧ (¬c > 0 → x ≥ 0)) ∧ (¬y < 0 → (c > 0 → x ≥ 0) ∧ (¬c > 0 → x ≥ 0))) Normalizing, by applying distributivity yields... Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 24. VCs with Weakest Preconditions (4) - Example 1. x < 0 → c > 0 → −x ≥ 0 2. x < 0 → ¬c > 0 → −x ≥ 0 3. ¬x < 0 → y < 0 → c > 0 → x ≥ 0 4. ¬x < 0 → y < 0 → ¬c > 0 → x ≥ 0 5. ¬x < 0 → ¬y < 0 → c > 0 → x ≥ 0 6. ¬x < 0 → ¬y < 0 → ¬c > 0 → x ≥ 0 In this normalized form it becomes obvious that the effort of discharging the proof obligations is basically the same as for path analysis by symbolic execution. Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 25. VCs with Efficient Weakest Preconditions (1) An alternative notion to the conservative weakest precondition is that of weakest liberal precondition wlp(S, φ): the postcondition is only required to be satisfied if the program terminates correctly. For programs without iteration, the weakest liberal precondition is defined in the same way as the conservative weakest precondition, except for the assert command: wlp(assert ψ, φ) = ψ → φ Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 26. VCs with Efficient Weakest Preconditions (2) The relation between both notions is well-known: Lemma For any command block S and assertion φ, wp(S, φ) ≡ wlp(S, φ) ∧ wp(S, true) The relevance of this notion is that the weakest liberal precondition of a single-assignment program S with respect to φ can be computed from the linear size formula F(S) of the program without requiring further traversals of S, so there are no opportunities for duplicating φ. Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 27. VCs with Efficient Weakest Preconditions (3) F(skip) = true F(x := e) = x = e F(if b then S else S f ) = (b ∧ F(S t )) ∨ (¬b ∧ F(S f )) t F(C ; S) = F(C ) ∧ F(S) F(assert ψ) = ψ Let S be a single-assignment command block. Then for any assertion φ, wlp(S, φ) ≡ F(S) → φ. Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 28. VCs with Efficient Weakest Preconditions (4) — Example wp(ABSSA, true) = wp(C1 ; C2 ; assert x2 ≥ 0, true) = F(C1 ; C2 ) → x2 ≥ 0 = ((x0 < 0 ∧ x1 = −x0 ∧ x2 = x1 ∧ y3 = y0 )∨ (¬x0 < 0 ∧ ((y0 < 0 ∧ y1 = −y0 ∧ y2 = y1 )∨ (¬y0 < 0 ∧ y2 = y0 )) ∧ x2 = x0 ∧ y3 = y2 )) ∧ ((c0 > 0 ∧ c1 = c0 − 1 ∧ c2 = c1 ) ∨ (¬c0 > 0 ∧ c2 = c0 )) → x2 ≥ 0 But what does the VC look like in general? Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 29. VCs with Efficient Weakest Preconditions (5) The set of efficient weakest precondition verification conditions of S is defined as follows: VCwp (S) = Fp(assert ψ, S) → ψ | for all assertions ψ and all occurrences of assert ψ in S The path formula Fp(C , S) of C in S describes the entire set of paths from START to a specific command, at a concrete point of the program. Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 30. VCs with Efficient Weakest Preconditions (6) Remarks: Unlike with symbolic execution, there is no direct association between a single invalid VC and an error path, which is the price to pay for efficiency. We avoid exponential explosion: in general, the size of each VC is worst-case linear in the size n of the program, and there are k VCs, with k the number of assert commands, which is also linear in n in the worst-case. So overall VCwc is of quadratic size in n. “Lemma-usage” of asserts: Fp includes assert information. Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 31. Outline 1 Setting 2 Encoding Programs as Formulas using SA 3 VCs with Symbolic Execution 4 VCs with Weakest Preconditions 5 VCs with Bounded Model Checking 6 Conclusions Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 32. VCs with Bounded Model Checking (1) From a program S we extract two sets of formulas, such that: P is a logical consequence of C (the entailment C |= P holds), if and only if no assert command fails in any execution of S. C describes logically the operational contents of the program, and P is extracted from the assert formulas that can be found in it. This technique explicitly assumes that a satisfiability-based tool is used to find models corresponding to an execution of the program that violates at least one assert command: C ∪ {¬ P} Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 33. VCs with Bounded Model Checking (2) To see that this can be formulated in terms of verification conditions, it suffices to observe that for finite C the semantic entailment problem C |= P is equivalent to the validity problem |= C→ P Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 34. VCs with Bounded Model Checking (3) For our programs without loops the method applies the following steps: 1 The program is converted into single-assignment form; 2 The resulting program is then converted into a sequence of commands on the form if b then Ca else skip, with Ca an atomic command. 3 Extract the model from the Conditional Normal Form. For every command if b then x := e else skip in the program, C includes the formula b → x = e; For every command if b then assert ψ else skip in the program, P includes the formula b → ψ. 4 Generate VC: C→ P. Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 35. VCs with Bounded Model Checking (3) - Example ABSCNF : if x0 < 0 then x1 := −x0 else skip ; if x0 < 0 then x2 := x1 else skip ; if x0 < 0 then y3 := y0 else skip ; if ¬(x0 < 0) ∧ y0 < 0 then y1 := −y0 else skip ; if ¬(x0 < 0) ∧ y0 < 0 then y2 := y1 else skip ; if ¬(x0 < 0) ∧ ¬(y0 < 0) then y2 := y0 else skip ; if ¬(x0 < 0) then x2 := x0 else skip ; if ¬(x0 < 0) then y3 := y2 else skip ; if c0 > 0 then c1 := c0 − 1 else skip ; if c0 > 0 then c2 := c1 else skip ; if ¬(c0 > 0) then c2 := c0 else skip ; if true then assert x2 ≥ 0 else skip Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 36. VCs with Bounded Model Checking (4) - Example C : 1. x0 < 0 → x1 = −x0 2. x0 < 0 → x2 = x1 3. x0 < 0 → y3 = y0 4. ¬(x0 < 0) ∧ y0 < 0 → y1 = −y0 5. ¬(x0 < 0) ∧ y0 < 0 → y2 = y1 6. ¬(x0 < 0) ∧ ¬(y0 < 0) → y2 = y0 7. ¬(x0 < 0) → x2 = x0 8. ¬(x0 < 0) → y3 = y2 9. c0 > 0 → c1 = c0 − 1 10. c0 > 0 → c2 = c1 11. ¬(c0 > 0) → c2 = c0 P : 1. true → x2 ≥ 0 Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 37. VCs with Bounded Model Checking (4) C can then be written as Fbmc(S), where: S denotes the program that results from replacing every command assert ψ in S by skip. Fbmc(S) is a variant of F(S); P on the other hand can be written as follows: Fb(assert ψ, S) → ψ | for all assertions ψ and all occurrences of assert ψ in S Fb(C,S) captures only the branching information that enables the execution of the command C . Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 38. VCs with Bounded Model Checking (5) The verification condition C → P can now be split using basic equivalences to obtain a set of normalized VCs: Given a single-assignment command block S, the set of bounded model checking verification conditions of S is defined as follows: VCbmc (S) = Fbmc(S) ∧ Fb(assert ψ, S) → ψ | for all assertions ψ and all occurrences of assert ψ in S Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 39. Outline 1 Setting 2 Encoding Programs as Formulas using SA 3 VCs with Symbolic Execution 4 VCs with Weakest Preconditions 5 VCs with Bounded Model Checking 6 Conclusions Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 40. Conclusions In BMC, the formulas occurring as antecedents of VCs do not include assert formulas, whereas in the efficient WP method it does, which allows them to be used as lemmas. The size of VCs is in both cases linear for programs with a single postcondition assert command; for programs with an arbitrary number of such commands both have a quadratic bound. Symbolic execution generates VCs of exponential-size in the worst-case, but offers a one-to-one association between VCs and execution paths, valuable for error-tracing. Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs
  • 41. Conclusions None of the methods can be said to always generate smaller VCs than the other. Since it is difficult to judge the performance of automatic provers (and the effect of operations like splitting, which increase the size of formulas but not necessarily make proofs harder), an empirical comparison seems to be required. Build a VCGen based on the BMC technique for Boogie programs. Include the iteration. Cruz, Frade & Pinto Verification Conditions for Single-assignment Programs