Integrating SMT with Theorem Proving for AMS Verification Yan Peng - - PowerPoint PPT Presentation

integrating smt with theorem proving for ams verification
SMART_READER_LITE
LIVE PREVIEW

Integrating SMT with Theorem Proving for AMS Verification Yan Peng - - PowerPoint PPT Presentation

Integrating SMT with Theorem Proving for AMS Verification Yan Peng & Mark Greenstreet University of British Columbia Vancouver, CA July 09, 2014 Peng & Greenstreet (UBC) Integrating SMT with TP FAC (July 09, 2014) 1 / 21 Outline


slide-1
SLIDE 1

Integrating SMT with Theorem Proving for AMS Verification

Yan Peng & Mark Greenstreet

University of British Columbia Vancouver, CA

July 09, 2014

Peng & Greenstreet (UBC) Integrating SMT with TP FAC (July 09, 2014) 1 / 21

slide-2
SLIDE 2

Outline Integrating SMT with Theorem Proving for AMS Verification Contributions Integrating SMT with Theorem Proving, challenges and solutions Verifying global convergence of a Digital Phase-Locked Loop(DPLL) using recurrence Conclusion

Peng & Greenstreet (UBC) Integrating SMT with TP FAC (July 09, 2014) 2 / 21

slide-3
SLIDE 3

Contributions Combine industrial strength SMT solver with industrial strength theorem prover. Model state-of-the-art DPLL with recurrences. Proof of global convergence. Able to prove design with parameter variation.

Peng & Greenstreet (UBC) Integrating SMT with TP FAC (July 09, 2014) 3 / 21

slide-4
SLIDE 4

Outline Integrating SMT with Theorem Proving for AMS Verification

  • Contributions

Integrating SMT with Theorem Proving ◮ Why combine Z3 and ACL2? ◮ Software framework and technical challenges Verifying global convergence of a Digital Phase-Locked Loop(DPLL) using recurrence Conclusion

Peng & Greenstreet (UBC) Integrating SMT with TP FAC (July 09, 2014) 4 / 21

slide-5
SLIDE 5

SMT and Theorem Proving - Z3 Satisfiability Modulo Theories (SMT) problem is a unified decision procedure for logical formulas which combines solvers for a rich set of background theories. Possible theories: propositional logic, arithmetic, uninterpreted functions, bitvectors theories etc. Z3, Microsoft Research [MB08, JM12]. Non-linear arithmetic theories, suitable for AMS design with non-linear dynamics. Lack of: ◮ Induction proof ◮ Structured proof

Peng & Greenstreet (UBC) Integrating SMT with TP FAC (July 09, 2014) 5 / 21

slide-6
SLIDE 6

SMT and Theorem Proving - ACL2 Theorem proving is a technique for proving a set of theorems by building upon a set of basic axioms and use of logic rules, e.g. rewrite rules, induction. In order to prove a final theorem, one looks at what is needed and develops a set of lemmas. ACL2, University of Texas at Austin.[KM97] But working through complicated boolean formulas, systems of inequalites, etc., can be extremely tedious. ACL2 and Z3 complement each other: ◮ ACL2 provides structured proofs and induction proofs. ◮ Z3 discharges complicated/tedious systems of inequalities.

Peng & Greenstreet (UBC) Integrating SMT with TP FAC (July 09, 2014) 6 / 21

slide-7
SLIDE 7

SMT and Theorem Proving - clause processor

clauses returned by clause processor:

clause processor

k

c

1

c

1

c

k

c c2 c

clause from ACL2

c

2

c

A clause processor takes the goal one wants to prove and decomposes the goal into a conjunction of subgoals. Each subgoal is a called a clause. ACL2 supports two kinds of clause processors: ◮ A verified clause processor is written in Lisp and proven correct within ACL2. ◮ A trusted clause processor is anything else. Theorems whose proofs rely on a trusted clause processor are tagged accordingly. We integrate Z3 into ACL2 as a trusted clause processor.

Peng & Greenstreet (UBC) Integrating SMT with TP FAC (July 09, 2014) 7 / 21

slide-8
SLIDE 8

Challenge: reals vs. rationals

clauses returned by clause processor:

clause processor

k

c

1

c

x,y,z. c(x,y.z) ∀

clause from ACL2 1

c

k

c c2 c(x,y,z)

2

c

Challenge: ACL2 has rationals and Z3 has reals. ◮ In ACL2, ¬∃x. x2 = 2 is a theorem. ◮ In Z3, ∃x. x2 = 2 is a theorem. Solution: only use Z3 to prove propositions where all variables are universally quantified.

Peng & Greenstreet (UBC) Integrating SMT with TP FAC (July 09, 2014) 8 / 21

slide-9
SLIDE 9

Challenge: typed vs. untyped

c(x,y,z) clause processor

k

c

1

c

1

c

k

c

2

c

clauses returned by clause processor: clause from ACL2 (implies (and (rationalp x) (rationalp y) (rationalp z)) (c x y z))

c2

Challenge: ACL2 is untyped but Z3 is typed. Solution: user adds type assertions to antecedent. ◮ These are almost always needed anyways. ◮ This requirement is not a significant burden.

Peng & Greenstreet (UBC) Integrating SMT with TP FAC (July 09, 2014) 9 / 21

slide-10
SLIDE 10

Challenge: user defined functions

Expanded => Original

clause processor

k

c

1

c

clause from ACL2

c

2

c

about recursive functions. Validate user’s claims

Challenge: ◮ ACL2 supports arbitrary lisp functions. ◮ Z3 functions are more like macros (no recursion). Solution: ◮ Set up translation for a basic set of functions. ◮ Expand non-recursive functions. ◮ Expand recursive functions to bounded depth. ◮ Expansion done on ACL2’s representation: can verify correctness.

Peng & Greenstreet (UBC) Integrating SMT with TP FAC (July 09, 2014) 10 / 21

slide-11
SLIDE 11

Other issues: Claims can contain non-polynomial terms. ◮ Replace offensive subexpression with a variable. ◮ User adds constraints about the variable. ◮ These constraints are returned as clauses for ACL2 to prove. ACL2 may need hints to discharge clauses returned from the clause processor. ◮ Solution: nested hints. ◮ These hints tell the clause processor what hints to attach to returned clauses. These features provides a very flexible back-and-forth between induction proofs in ACL2 and handling the details of the algebra with Z3.

Peng & Greenstreet (UBC) Integrating SMT with TP FAC (July 09, 2014) 11 / 21

slide-12
SLIDE 12

Example - the theorem ∀ a b γ ∈ R, m n ∈ Z.If 0 < m < n, 0 < gamma < 1. → γm((a + b)2 − 2ab) ≥ γn · 2ab

1 (defun f-mul-2 (x) (f-mul 2 x))

(defun f-plus (x y) (+ x y))

3 (defun f-square (x) (f-mul x x))

(defun f-neg (x) (- x))

5 (defun f-minus (x y) (f-plus x (f-neg y)))

(defun f-expt (x n) (expt x n))

Peng & Greenstreet (UBC) Integrating SMT with TP FAC (July 09, 2014) 12 / 21

slide-13
SLIDE 13

Example - code

(defthm demonstration

2

(implies (and (and (rationalp a) (rationalp b)

4

(rationalp gamma) (integerp m)

6

(integerp n)) (and (> gamma 0)

8

(< gamma 1) (> m 0)

10

(< m n))) (>= (f-mul (expt gamma m)

12

(f-minus (f-square (f-plus a b)) (f-mul (f-mul-2 a) b)))

14

(f-mul (foo gamma n) (f-mul (f-mul-2 a) b))))

16

:hints ...)

Peng & Greenstreet (UBC) Integrating SMT with TP FAC (July 09, 2014) 13 / 21

slide-14
SLIDE 14

Example - code

1 :hints

(("Goal"

3

:clause-processor (my-clause-processor clause

5

’( (:expand ((:functions ((f-mul rationalp) (f-mul-2 rationalp)

7

(f-plus rationalp) (f-square rationalp)

9

(f-neg rationalp) (f-minus rationalp)

11

(f-expt rationalp))) (:expansion-level 1))

13

(:python-file "demonstration") (:let ((expt_gamma_m (expt gamma m) rationalp)

15

(expt_gamma_n (expt gamma n) rationalp))) (:hypothesize ((< expt_gamma_n expt_gamma_m)

17

(> expt_gamma_m 0) (> expt_gamma_n 0)))

19

(:use ((:type ()) (:hypo ())

21

(:main ()))))))))

Peng & Greenstreet (UBC) Integrating SMT with TP FAC (July 09, 2014) 14 / 21

slide-15
SLIDE 15

Outline Integrating SMT with Theorem Proving for AMS Verification

  • Contributions
  • Integrating SMT with Theorem Proving

Verifying global convergence of a Digital Phase-Locked Loop(DPLL) using recurrence ◮ The state-of-the-art Digital PLL ◮ Establish recurrence model for the DPLL ◮ Prove global convergence using Z3 and ACL2 Conclusion

Peng & Greenstreet (UBC) Integrating SMT with TP FAC (July 09, 2014) 15 / 21

slide-16
SLIDE 16

A state-of-the-art Digital PLL (from CICC 2010)[CNA10]

DCO

BBPFD

0:23 0:14 15:23

LPF

DCO

+ −

dn up ∆θ c v

PFD Fref

Fref

Σ

0:7 0:3 4:7

∆Σ

FDCO Fref

Σ DAC − +

Cdecap

F − Center code

  • ÷N

DCO has three control inputs: capacitance setting (digital), supply voltage (linear), phase correction (time-difference of digital transitions). Uses linear and bang-bang PFD. Integrators are digital. LPF and decap to improve power-supply rejection. It is impractical to verify global convergence using simulation.

Peng & Greenstreet (UBC) Integrating SMT with TP FAC (July 09, 2014) 16 / 21

slide-17
SLIDE 17

Establish the Recurrence Model A limit cycle is an isolated closed trajectory, for which its neighbouring trajectories are not closed they spiral either towards

  • r away from the limit cycle.

The recurrence model:

c(i + 1) = c(i) + g1sign(φ(i)) v(i + 1) = v(i) + g2(c(i) − ccode) φ(i + 1) = (1 − Kt)φ(i) + 2π fdco(i)

Nfref − 1

  • where fdco(i) = f0

1+αv(i) 1+βc(i) Peng & Greenstreet (UBC) Integrating SMT with TP FAC (July 09, 2014) 17 / 21

slide-18
SLIDE 18

The proof: the big picture Coarse convergence: from any initial condition, φ eventually crosses 0 in a state where c and v are not saturated. ◮ Proof sketch: ◮ Use Ricatti equation to get a ranking function based on linear model at convergence. ◮ Use this ranking function to show coarse convergence using non-linear, global model. ◮ Z3 discharges all of the proof obligations. Fine convergence: from any crossing of φ = 0 with c and v away from their saturation conditions (as established above), φ will continue to make zero-crossings that each move closer to the intended equilibrium. ◮ Proof sketch: see the next few slides.

Peng & Greenstreet (UBC) Integrating SMT with TP FAC (July 09, 2014) 18 / 21

slide-19
SLIDE 19

The proof: fine convergence using induction proof

5 5 10 0.015 0.01 0.005 0.005 0.01 c1 c2 (2n1)

c (quantized) (continuous) Solve the recurrence (verified by ACL2 – rewrite & induction):

c(j) = c0 + g1j φ(j) = γjφ0 + 2π

j−1

  • i=0

γ(j−1−i)

  • µ 1 + αv

1 + βc(i) − 1

  • We want to prove:

∀m ≥ 3, φ(2m − 1) < 0

A symmetric argument applies to lower half of the space.

Peng & Greenstreet (UBC) Integrating SMT with TP FAC (July 09, 2014) 19 / 21

slide-20
SLIDE 20

The proof

5 5 10 0.015 0.01 0.005 0.005 0.01 c1 c2 (2n1)

c (quantized) (continuous)

Exploit the asymmetry between terms with c < ceq and c > ceq where ceq is chosen to set fdco = fref. ◮ We pair up points to simplify the formula. ◮ Basic idea: the negative terms dominate the positive ones. Proving these claims manually involves many pages of messy algebra: ◮ Just have Z3 takes care of it.

Peng & Greenstreet (UBC) Integrating SMT with TP FAC (July 09, 2014) 20 / 21

slide-21
SLIDE 21

Conclusion We’ve shown an integration of the Z3 SMT solver into the ACL2 theorem prover with applications for AMS verification. Theorem proving is hard! Reachability is easy! Why use a theorem prover? ◮ Reachability tools only solve parts of the problem. Human reasoning is needed to conclude that the system works given these partial results. ◮ Our formulation lets us work directly on the recurrences rather than on continuizations:

Can reason in detail about limit-cycle behaviour.

◮ We hope for “re-usable proofs.”

Proof re-use has been very useful in the hardware

verification world.

AMS verification seems amenable to the same approach:

there aren’t that many types of AMS blocks even though there are many implementations.

Peng & Greenstreet (UBC) Integrating SMT with TP FAC (July 09, 2014) 21 / 21

slide-22
SLIDE 22

References

  • J. Crossley, E. Naviasky, and E. Alon, An energy-efficient ring-oscillator digital pll,

Custom Integrated Circuits Conference (CICC), 2010 IEEE, 2010, pp. 1–4. Dejan Jovanovi´ c and Leonardo Moura, Solving non-linear arithmetic, 6th International Conference on Automated Reasoning (Bernhard Gramlich, Dale Miller, and Uli Sattler, eds.), Lecture Notes in Computer Science, vol. 7364, Springer Berlin Heidelberg, June 2012, pp. 339–354. Matt Kaufmann and J. S. Moore, An industrial strength theorem prover for a logic based on common lisp, IEEE Trans. Softw. Eng. 23 (1997), no. 4, 203–213. Leonardo Moura and Nikolaj Bjørner, Z3: An efficient SMT solver, Tools and Algorithms for the Construction and Analysis of Systems (C.R. Ramakrishnan and Jakob Rehof, eds.), Lecture Notes in Computer Science, vol. 4963, Springer Berlin Heidelberg, 2008, pp. 337–340.

Peng & Greenstreet (UBC) Integrating SMT with TP FAC (July 09, 2014) 22 / 21