Generating Sharper and Simpler Nonlinear Interpolants for Program - - PowerPoint PPT Presentation

β–Ά
generating sharper and
SMART_READER_LITE
LIVE PREVIEW

Generating Sharper and Simpler Nonlinear Interpolants for Program - - PowerPoint PPT Presentation

Generating Sharper and Simpler Nonlinear Interpolants for Program Verification Takamasa Okudono 1 , Yuki Nishida 2 , Kensuke Kojima 2 , Kohei Suenaga 2 , Kengo Kido 1 and Ichiro Hasuo 3 1 University of Tokyo, Japan 2 Kyoto University, Japan 3


slide-1
SLIDE 1

Generating Sharper and Simpler Nonlinear Interpolants for Program Verification

Takamasa Okudono1, Yuki Nishida2, Kensuke Kojima2, Kohei Suenaga2, Kengo Kido1 and Ichiro Hasuo3

1University of Tokyo, Japan 2Kyoto University, Japan 3National Institute of Informatics, Japan

APLAS 2017, Suzhou, China. November 28th 2017

1 Takamasa Okudono (University of Tokyo)

slide-2
SLIDE 2

Interpolant is effective at program verification

For polynomial interpolants, atomic propositions are: (Poly.)≧0, (Poly.)>0, (Poly.)=0

Purpose of This Work

  • Automatic generation of polynomial interpolants.

Takamasa Okudono (University of Tokyo) 2

Disjointness of the regions Essential to separate the regions

  • 𝐡, 𝐢: Formulas satisfying ⊨ Β¬(𝐡 ∧ 𝐢).
  • Formula 𝐽 is an interpolant of 𝐡 and 𝐢 if:
  • 1. ⊨ 𝐡 β†’ 𝐽
  • 2. ⊨ Β¬(𝐢 ∧ 𝐽)
  • 3. Variables in 𝐽 appear in both of 𝐡, 𝐢
  • Def. [interpolant]
slide-3
SLIDE 3

Existing Work

  • [Dai+, CAV’13]: generation of polynomial interpolants with

numerical optimization

  • Challenge 1: Unable to generate any interpolants in β€œtouching” cases
  • Challenge 2: Incorrect and complex due to numerical errors

3 Takamasa Okudono (University of Tokyo)

Touching

54.1800𝑦 + 108.3601𝑧 β‰₯ 0 𝑦 + 2𝑧 β‰₯ 0

slide-4
SLIDE 4

Our Contribution

  • [Dai+, CAV’13]: generation of polynomial interpolants with

numerical optimization

  • Challenge 1: Unable to generate any interpolants in β€œtouching” cases
  • Challenge 2: Incorrect and complex due to numerical errors

4 Takamasa Okudono (University of Tokyo)

Touching

54.1800𝑦 + 108.3601𝑧 β‰₯ 0 𝑦 + 2𝑧 β‰₯ 0

Solved! (Contribution 1) Solved! (Contribution 2)

slide-5
SLIDE 5

Challenge 1 in [Dai+]: Sharpness

  • If two regions of 𝐡, 𝐢 are β€œtouching”, [Dai+, CAV’13] always

fails at generating their interpolant.

5 Takamasa Okudono (University of Tokyo)

Touching

  • 𝐡 = (𝑧 βˆ’ 𝑦 > 0 ∧ 𝑧 + 𝑦 > 0)
  • 𝐢 = (βˆ’π‘§ β‰₯ 0)
slide-6
SLIDE 6

Challenge 1 in [Dai+]: Sharpness

  • If two regions of 𝐡, 𝐢 are β€œtouching”, [Dai+, CAV’13] always

fails at generating their interpolant.

6 Takamasa Okudono (University of Tokyo)

Touching

  • 𝐡 = (𝑧 βˆ’ 𝑦 > 0 ∧ 𝑧 + 𝑦 > 0)
  • 𝐢 = βˆ’π‘§ β‰₯ 0
  • 𝐽 = 𝑧 > 0
  • There is an interpolant, but

[Dai, CAV’13] cannot find it!

slide-7
SLIDE 7

Challenge 1 in [Dai+]: Sharpness

  • If two regions of 𝐡, 𝐢 are β€œtouching”, [Dai+, CAV’13] always

fails at generating their interpolant.

7 Takamasa Okudono (University of Tokyo)

slide-8
SLIDE 8

Challenge 1: Flow of [Dai+]

Takamasa Okudono (University of Tokyo) 8

(1) Formulas

𝐡, 𝐢

(2) Polynomial Optimization Problem (3) SDP Problem (4) Numerical Solution

  • f (3)

(5) Numerical Solution

  • f (2)

(6) Interpolant

𝐽

Use SDP Solver [Parrilo, Mathematical Programming’03]

↦ ↦ ↦ ↦ ↦

slide-9
SLIDE 9

Contribution 1: Method for Sharpness

Takamasa Okudono (University of Tokyo) 9

Method for Sharpness (1) Formulas

𝐡, 𝐢

(2) Polynomial Optimization Problem (3) SDP Problem (4) Numerical Solution

  • f (3)

(5) Numerical Solution

  • f (2)

(6) Interpolant

𝐽

Use SDP Solver [Parrilo, Mathematical Programming’03]

↦ ↦ ↦ ↦ ↦

slide-10
SLIDE 10

Contribution 1: Example

Takamasa Okudono (University of Tokyo) 10

(1) Formulas

𝐡, 𝐢

(2) Polynomial Optimization Problem Method for Sharpness

𝐡 = y βˆ’ x > 0, y + x > 0 , 𝐢 = (βˆ’π‘§ β‰₯ 0)

↦

slide-11
SLIDE 11

Contribution 1: Example [Dai+, CAV’13]

Takamasa Okudono (University of Tokyo) 11

  • 𝐡 = (y βˆ’ x > 0, y + x > 0), 𝐢 = (βˆ’π‘§ β‰₯ 0)
  • [Dai+, CAV’13]
  • Find polynomials 𝜏1, 𝜏2, 𝜏3, 𝜏4, 𝜏5 ∈ ℝ[π‘Œ]s.t.
  • 𝐽 ≔

1 2 + 𝜏1 + 𝜏2 𝑧 βˆ’ 𝑦 + 𝜏3 𝑧 + 𝑦 + 𝜏4 𝑧 βˆ’ 𝑦

𝑧 + 𝑦 + 𝑧 βˆ’ 𝑦 2 𝑧 + 𝑦 2

  • 𝐽′ ≔

1 2 + 𝜏5(βˆ’π‘§)

  • 𝜏1, 𝜏2, 𝜏3, 𝜏4, 𝜏5 are sums of squares
  • 𝐽 + 𝐽′ = 0
  • (𝐽 contains only 𝑧)
  • Then 𝐽 > 0 is an interpolant

𝜏 is a sum of squares ⟺ βˆƒπœ’1, … , πœ’π‘œ ∈ ℝ π‘Œ ; 𝜏 = πœ’1

2 + β‹― + πœ’π‘œ 2

slide-12
SLIDE 12

Contribution 1: Example [Dai+, CAV’13]

Takamasa Okudono (University of Tokyo) 12

  • 𝐡 = (y βˆ’ x > 0, y + x > 0), 𝐢 = (βˆ’π‘§ β‰₯ 0)
  • [Dai+, CAV’13]
  • Find polynomials 𝜏1, 𝜏2, 𝜏3, 𝜏4, 𝜏5 ∈ ℝ[π‘Œ]s.t.
  • 𝐽 ≔

1 2 + 𝜏1 + 𝜏2 𝑧 βˆ’ 𝑦 + 𝜏3 𝑧 + 𝑦 + 𝜏4 𝑧 βˆ’ 𝑦

𝑧 + 𝑦 + 𝑧 βˆ’ 𝑦 2 𝑧 + 𝑦 2

  • 𝐽′ ≔

1 2 + 𝜏5(βˆ’π‘§)

  • 𝜏1, 𝜏2, 𝜏3, 𝜏4, 𝜏5 are sums of squares
  • 𝐽 + 𝐽′ = 0
  • (𝐽 contains only 𝑧)
  • Then 𝐽 > 0 is an interpolant

Infeasible and unable to generate any interpolants!

slide-13
SLIDE 13

Contribution 1: Example [Dai+, CAV’13]

Takamasa Okudono (University of Tokyo) 13

  • 𝐡 = (y βˆ’ x > 0, y + x > 0), 𝐢 = (βˆ’π‘§ β‰₯ 0)
  • [Dai+, CAV’13]
  • Find 𝜏1, 𝜏2, 𝜏3, 𝜏4, 𝜏5 ∈ ℝ[π‘Œ] s.t.
  • 𝐽 ≔

1 2 + 𝜏1 + 𝜏2 𝑧 βˆ’ 𝑦 + 𝜏3 𝑧 + 𝑦 + 𝜏4 𝑧 βˆ’ 𝑦

𝑧 + 𝑦 + 𝑧 βˆ’ 𝑦 2 𝑧 + 𝑦 2

  • 𝐽′ ≔

1 2 + 𝜏5(βˆ’π‘§)

  • 𝜏1, 𝜏2, 𝜏3, 𝜏4, 𝜏5 are sums of squares
  • 𝐽 + 𝐽′ = 0
  • (𝐽 contains only 𝑧)
  • Then 𝐽 > 0 is an interpolant

Infeasible and unable to generate any interpolants! ∡Assume the feasibility. 0 = 𝐽 + 𝐽′ 0, 0 = 1 + 𝜏1 0, 0 > 0.

  • Contradiction. β–‘
slide-14
SLIDE 14

Contribution 1: Example [Dai+, CAV’13]

Takamasa Okudono (University of Tokyo) 14

  • 𝐡 = (y βˆ’ x > 0, y + x > 0), 𝐢 = (βˆ’π‘§ β‰₯ 0)
  • Our method for sharpness
  • Find polynomials 𝜏1, 𝜏2, 𝜏3, 𝜏4, 𝜏5 ∈ ℝ[π‘Œ]and 𝑠

1, 𝑠2, 𝑠3 ∈ ℝβ‰₯0 s.t.

  • 𝐽 ≔ 𝜏1 + 𝜏2 𝑧 βˆ’ 𝑦 + 𝜏3 𝑧 + 𝑦 + 𝜏4 𝑧 βˆ’ 𝑦

𝑧 + 𝑦 + 𝑠

1 + 𝑠2 𝑧 βˆ’ 𝑦 + 𝑠3 𝑧 + 𝑦

  • 𝐽′ ≔ 𝜏5 βˆ’π‘§
  • 𝜏1, 𝜏2, 𝜏3, 𝜏4, 𝜏5 are sums of squares
  • 𝑠

1 + 𝑠2 + 𝑠3 > 0

  • 𝐽 + 𝐽′ = 0
  • 𝐽 contains only 𝑧
  • Then 𝐽 > 0 is an interpolant
slide-15
SLIDE 15

Contribution 1: Example [Dai+, CAV’13]

Takamasa Okudono (University of Tokyo) 15

  • 𝐡 = (y βˆ’ x > 0, y + x > 0), 𝐢 = (βˆ’π‘§ β‰₯ 0)
  • Our method for sharpness
  • Find polynomials 𝜏1, 𝜏2, 𝜏3, 𝜏4, 𝜏5 ∈ ℝ[π‘Œ]and 𝑠

1, 𝑠2, 𝑠3 ∈ ℝβ‰₯0 s.t.

  • 𝐽 ≔ 𝜏1 + 𝜏2 𝑧 βˆ’ 𝑦 + 𝜏3 𝑧 + 𝑦 + 𝜏4 𝑧 βˆ’ 𝑦

𝑧 + 𝑦 + 𝑠

1 + 𝑠2 𝑧 βˆ’ 𝑦 + 𝑠3 𝑧 + 𝑦

  • 𝐽′ ≔ 𝜏5 βˆ’π‘§
  • 𝜏1, 𝜏2, 𝜏3, 𝜏4, 𝜏5 are sums of squares
  • 𝑠

1 + 𝑠2 + 𝑠3 > 0

  • 𝐽 + 𝐽′ = 0
  • 𝐽 contains only 𝑧
  • Then 𝐽 > 0 is an interpolant

𝜏1 = 0 𝜏2 = 0 𝜏3 = 1 𝜏4 = 0 𝑠

1 = 0

𝑠2 = 1 𝑠3 = 0 𝑠5 = 2

Feasible and able to generate an interpolant!

𝐽 = 2𝑧

slide-16
SLIDE 16

Contribution 1: Completeness

Takamasa Okudono (University of Tokyo) 16

A and B s.t. ⊨ Β¬(A∧B) [Dai+] Method for Sharpness β€œtouching” cases

slide-17
SLIDE 17

Challenge 2: Numerical Error in [Dai+]

Takamasa Okudono (University of Tokyo) 17

(1) Formulas

𝐡, 𝐢

(2) Polynomial Optimization Problem (3) SDP Problem (4) Numerical Solution

  • f (3)

(5) Numerical Solution

  • f (2)

(6) Interpolant

𝐽

Use SDP Solver

↦ ↦ ↦ ↦ ↦

Numerical Error

slide-18
SLIDE 18

Challenge 2: Numerical Error in [Dai+]

Takamasa Okudono (University of Tokyo) 18

(1) Formulas

𝐡, 𝐢

(2) Polynomial Optimization Problem (3) SDP Problem (4) Numerical Solution

  • f (3)

(5) Numerical Solution

  • f (2)

(6) Interpolant

𝐽

Use SDP Solver

↦ ↦ ↦ ↦ ↦

Numerical Error Numerical Error

slide-19
SLIDE 19

Challenge 2: Numerical Error in [Dai+]

Takamasa Okudono (University of Tokyo) 19

(1) Formulas

𝐡, 𝐢

(2) Polynomial Optimization Problem (3) SDP Problem (4) Numerical Solution

  • f (3)

(5) Numerical Solution

  • f (2)

(6) Interpolant

𝐽

Use SDP Solver

↦ ↦ ↦ ↦ ↦

Numerical Error Numerical Error Numerical Error Numerical error spreads Less simple Maybe spurious

slide-20
SLIDE 20

Challenge 2: Numerical Error in [Dai+]

Takamasa Okudono (University of Tokyo) 20

(1) Formulas

𝐡, 𝐢

(2) Polynomial Optimization Problem (3) SDP Problem (4) Numerical Solution

  • f (3)

(5) Numerical Solution

  • f (2)

(6) Interpolant

𝐽

Use SDP Solver

↦ ↦ ↦ ↦ ↦

Numerical Error Numerical Error Numerical Error Numerical error spreads Less simple Maybe spurious

The same problem occurs in our method for sharpness (Contribution 1)

slide-21
SLIDE 21

Challenge 2: Example

  • Example: 𝐡 = 𝑦 = 0 ∧ 𝑧 = 0 , 𝐢 = (𝑦 + 2𝑧 < 0)
  • Spurious interpolant 𝐽 = 54.1800𝑦 + 108.3601𝑧 β‰₯ 0
  • 𝑦, 𝑧 = (βˆ’108.3601, 54.1800) satisfies both 𝐢 and 𝐽

21 Takamasa Okudono (University of Tokyo)

  • 𝐡, 𝐢: Formulas satisfying ⊨ (𝐡 ∧ 𝐢).
  • Formula 𝐽 is an interpolant of 𝐡 and 𝐢 if:
  • 1. ⊨ 𝐡 β†’ 𝐽
  • 2. ⊨ Β¬(𝐢 ∧ 𝐽)
  • 3. Variables in 𝐽 appears in both of 𝐡, 𝐢
  • Def. [interpolant]
slide-22
SLIDE 22

Contribution 2: Observation

β‰ˆΓ—2

22 Takamasa Okudono (University of Tokyo)

Spurious Interpolant: 𝐽 = 54.1800𝑦 + 108.3601𝑧 β‰₯ 0 Simplified Interpolant: 𝐽 = 𝑦 + 2𝑧 β‰₯ 0

Correct and simple interpolant of 𝐡 = 𝑦 = 0 ∧ 𝑧 = 0 , 𝐢 = (𝑦 + 2𝑧 < 0)

slide-23
SLIDE 23

Contribution 2: Working Assumption

  • Working Assumption: Simple interpolants tend to be correct

and useful to capture the program’s nature.

  • Strategy:
  • Simplify the ratio that appears in the interpolant
  • Find and guess simple integers

Takamasa Okudono (University of Tokyo) 23

slide-24
SLIDE 24

Contribution 2: Technique

24 Takamasa Okudono (University of Tokyo)

  • Continued Fraction Expansion
  • Input: real number 𝑦
  • Output: β€œbest” approximations 𝑏1

𝑐1 , 𝑏2 𝑐2 , … of 𝑦

  • Example:
  • 3.1416 = 3 +

1 7+

1 16+ 1 11

  • 1st approximation: 3.1416 ≃ 3
  • 2nd approximation: 3.1416 ≃ 3 + 1

7 = 22 7

  • 3rd approximation: 3.1416 ≃ 3 +

1 7+ 1

16

= 355

113

slide-25
SLIDE 25

Contribution 2: Technique

25 Takamasa Okudono (University of Tokyo)

  • Continued Fraction Expansion
  • Input: real number 𝑦
  • Output: β€œbest” approximations 𝑏1

𝑐1 , 𝑏2 𝑐2 , … of 𝑦

  • Example:
  • 3.1416 = 3 +

1 7+

1 16+ 1 11

  • 1st approximation: 3.1416 ≃ 3
  • 2nd approximation: 3.1416 ≃ 3 + 1

7 = 22 7

  • 3rd approximation: 3.1416 ≃ 3 +

1 7+ 1

16

= 355

113

(3.1416: 1) (3: 1) (22: 7) (355: 113)

Simple Faithful

slide-26
SLIDE 26

Contribution 2: Simplification of Ratio

26 Takamasa Okudono (University of Tokyo)

46.7375 155.0975 60.1733 1 3 1 3 10 4 31 103 40 97 322 125 … … … 467375 1550975 601733

More Faithful Less Simple

  • The simplification starts from the simplest ratio
  • Make it more faithful to the original solution and less simple

iteratively.

Original

slide-27
SLIDE 27

(1) Formulas

𝐡, 𝐢

(2) Polynomial Optimization Problem (3) SDP Problem (4) Numerical Solution

  • f (3)

(7) Simplified Solution

  • f (2)

(8) Simple and Verified Interpolant 𝐽 d := 1 (6) Simplified Solution

  • f (3)

(5) d-th Simplification

  • f (4)

FAIL d++ if (5) does not satisfy (3) No validated solution (5) satisfies (3) Method for Sharpness Method for Simplicity Validity is guaranteed! Maybe spurious…

Challenge 2: Method for Simplicity

↦ ↦ ↦ β†’ ↦ ↦ ↦ ↦ ↦ ↦

slide-28
SLIDE 28
  • 𝐡: blue regions, 𝐢: red regions, 𝐽: black hatched regions.

Experiments: Geometric Examples

28 Takamasa Okudono (University of Tokyo)

slide-29
SLIDE 29
  • 𝐡: blue regions, 𝐢: red regions, 𝐽: black hatched regions.

Experiments: Geometric Examples

29 Takamasa Okudono (University of Tokyo)

slide-30
SLIDE 30
  • These examples are rather simple, but [Dai+, CAV’13] cannot

verify them because of numerical errors (Challenge 2).

Experiments: Program Examples

30 Takamasa Okudono (University of Tokyo)

slide-31
SLIDE 31

Experiments: Program Examples

31 Takamasa Okudono (University of Tokyo)

(x, v) = (0, 0) While(nondet()){ (x, v) = (x + 2*v, v + 2); } Assert(x >= 0) (x, v) = [𝑦 β‰₯ 0, 𝑀 β‰₯ 0] While(nondet()){ (x, v) = (x + 2*v, v + 2); } Assert(x >= 0)

Abstraction with

𝑦 β‰₯ 0 and 𝑀 β‰₯ 0

Find good predicates by CEGAR[Clarke+, CAV’00] and our interpolant generation

slide-32
SLIDE 32

(x, v) = (0, 0); Assert(x >= 0) (x, v) = [anything]; Assert(x >= 0) (x, v) = [anything] While(nondet()){ (x, v) = (x + 2*v, v + 2); } Assert(x >= 0) (x, v) = (0, 0) While(nondet()){ (x, v) = (x + 2*v, v + 2); } Assert(x >= 0)

Experiments: Program Examples

32 Takamasa Okudono (University of Tokyo)

Abstraction with nothing Find Counterexample Extract the original trace 𝐡 = 𝑦 = 0, 𝑀 = 0 𝐢 = (𝑦 < 0) 𝐽 = (𝑦 β‰₯ 0) Make Formulas Generate an interpolant Touching Add 𝑦 β‰₯ 0

slide-33
SLIDE 33

(x, v) = (0, 0); (x, v) = (x + 2*v, v + 2); Assert(x >= 0) (x, v) = [𝑦 β‰₯ 0, 𝑀: any]; (x, v) = (x + 2*v, v + 2); Assert(x >= 0) (x, v) = [𝑦 β‰₯ 0, 𝑀: any] While(nondet()){ (x, v) = (x + 2*v, v + 2); } Assert(x >= 0) (x, v) = (0, 0) While(nondet()){ (x, v) = (x + 2*v, v + 2); } Assert(x >= 0)

Experiments: Program Examples

33 Takamasa Okudono (University of Tokyo)

Abstraction with 𝑦 β‰₯ 0 Find Counterexample Extract the original trace 𝐡 = 𝑀1 = 0 𝐢 = (𝑦1 = 0 ∧ 𝑀2 = 𝑀1 + 2 ∧ 𝑦2 = 𝑦1 + 2𝑀1 ∧ 𝑦2 < 0) 𝐽 = (𝑀1 β‰₯ 0) Make Formulas Generate an interpolant Add 𝑀 β‰₯ 0

slide-34
SLIDE 34

(x, v) = [𝑦 β‰₯ 0, 𝑀 β‰₯ 0] While(nondet()){ (x, v) = (x + 2*v, v + 2); } Assert(x >= 0) (x, v) = (0, 0) While(nondet()){ (x, v) = (x + 2*v, v + 2); } Assert(x >= 0)

Experiments: Program Examples

34 Takamasa Okudono (University of Tokyo)

Abstraction with 𝑦 β‰₯ 0 and 𝑀 β‰₯ 0

slide-35
SLIDE 35

Our Challenge

  • Our method works only for fairly simple examples:
  • Geometric examples: at most quadratic
  • Program examples: at most linear

35 Takamasa Okudono (University of Tokyo)

slide-36
SLIDE 36

Conclusion

  • Our Contributions: Solved some challenges in [Dai+, CAV’13]
  • Challenge 1: Sharpness
  • Challenge 2: Numerical Error
  • Our method works only for fairly simple examples:
  • Geometric examples: at most quadratic
  • Program examples: at most linear

36 Takamasa Okudono (University of Tokyo)