Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Quantified Formulas Acknowledgement: QBF slides borrowed from S. Malik.

Similar presentations


Presentation on theme: "1 Quantified Formulas Acknowledgement: QBF slides borrowed from S. Malik."— Presentation transcript:

1 1 Quantified Formulas Acknowledgement: QBF slides borrowed from S. Malik

2 2 Why do we need quantifiers ? As always: more modeling power Examples of quantifiers usage:  “Everyone in the room has a friend”  “There is a person in the room that all of his cars are red”  “There is not more than one person in the room that earns more than $1M”

3 3 Quantifiers in Math… For any integer x there is a smaller integer y 8x2Z 9y2Z. y < xX Reverse claim: There exists an integer y such that any integer x is greater than y 8x2Z 9y2Z. y < x£ (Bertrand’s postulate) For any natural number greater than 1 there is a prime number p such that n < p < 2 n 8n2 N. 9p2 N. n >1 ! (isprime( p ) Æ n < p < 2 n )

4 4 Actually… Satisfiability of  ( x 1, , x n ) = does there exist an interpretation of x 1, , x n that satisfies  Validity of  ( x 1, , x n ) = does it hold that all interpretation of x 1, , x n satisfy  Conclusion: what we did so far (satisfiability, validity) is non-alternating quantification.

5 5 Example: Quantified Propositional Logic Better known as Quantified Boolean Formulas (QBF) formula: var | : formula | formula Ç formula | ( formula ) | T | F| 8 var. (formula) | 9 var. (formula) 8 x. ( x Ç 9 y. ( y ! x )) 8 x. ( 9 y. (( x Ç :y ) Æ ( :x Çy )) Æ 9 y. (( :y Ç :x ) Æ ( x Ç y ))) Binding scope of y X X

6 6 Prenex Normal-Form (PNF) Formulas in PNF look like this:  ’: Q[ n ]V[ n ]. .Q[1]V[1]. Quantifier-free formula where Q[ i ] 2 { 8, 9 } and V[ i ] is a variable. Every quantified formula can be transformed to PNF while preserving validity. How ? prefix

7 7 Prenex Normal Form (PNF) 1. Eliminate ! and $ (transform to Ç Æ : ) 2. Push negations inside using: : 8 x.  $ 9 x. :  : 9 x.  $ 8 x. :  3. If there are name conflicts across scopes, solve with renaming. 4. Move quantifiers out by using recursively rules such as: 1. Q 1 x.  1 (x) Æ Q 2 y.  2 (y) $ Q 1 x. Q 2 y. (  1 (x) Æ  2 (y))Q i 2 { 8, 9 } 2. Q 1 x.  1 (x) Ç Q 2 y.  2 (y) $ Q 1 x. Q 2 y. (  1 (x) Ç  2 (y))Q i 2 { 8, 9 }   1 Æ 9 x.  2 (x) $ 9 x. (  1 Æ  2 (x)) where x does not appear in  1   1 Æ 8 x.  2 (x) $ 8 x. (  1 Æ  2 (x)) where x does not appear in  1 5. 8 x.  1 (x) Æ 8 x.  2 (x) $ 8 x. (  1 (x) Æ  2 (x)) 6. 9 x.  1 (x) Ç 9 x.  2 (x) $ 9 x. (  1 (x) Ç  2 (x))

8 8 Prenex Normal Form (PNF): example :9 x. : ( 9 y. (( y ! x ) Æ ( : x Ç y )) Æ :8 y. (( y Æ x ) Ç ( : x Æ : y))) 1,2. Eliminate !, push negations inside: 8 x. ( 9 y. (( :y Ç x ) Æ ( : x Ç y )) Æ 9y. (( :y Ç : x ) Æ ( x Ç y ))) 3. Renaming: 8 x. ( 9y 1. (( :y 1 Ç x ) Æ ( : x Ç y 1 )) Æ 9y 2. (( :y 2 Ç : x ) Æ ( x Ç y 2 ))) 4. Move quantifiers to front: 8 x. 9y 1. 9y 2. ( x Ç :y 1 ) Æ ( : x Ç y 1 ) Æ ( :y 2 Ç : x ) Æ ( x Ç y 2 )

9 9 Why eliminating 9 x. Æ i L i is enough A procedure for eliminating an existential quantifier applied to a conjunction of literals is enough, because:  Given a formula , write it in DNF.  Use the fact that  Eliminate universal quantifiers using the fact 8 x.  $ :9 x. : 

10 10 Quantifier Elimination Examples first, generalization later. Example #1: Quantified Boolean Formulas (QBF) Example #2: Quantified Linear Arithmetic (QLA)

11 11 Example #1: QBF Examples of Quantified Boolean Formula  :  u  e.( uÇ :e )( :uÇ e )  :  e 4 e 5  u 1 u 2 u 3  e 1 e 2 e 3. f ( e 1, e 2, e 3, e 4, e 5, u 1, u 2, u 3 ) QBF Problem: is  valid? P-Space Complete, theoretically harder than NP-Complete problems such as SAT.

12 12 Motivations QBF has practical applications:  AI Planning  Sequential circuit verification  …

13 13 a Ç b Ç g Ç h’Ç f a Ç b Ç g Ç h’ Solving QBF with projection: 9 Eliminate 9x. by projecting x on variables in higher quantification levels (their scope includes x ’s scope). In Propositional Logic projection can be done with Resolution. Resolution example: a Ç b Ç c’ Ç fg Ç h’ Ç c Ç f

14 14 Solving QBF with projection: 8 Transform 8 to 9 via: ( 8x.  $ ( :9x. :  CNF is easier than general formulas: Suffix is DNF Back to CNF Shortcut for CNF formulas: simply erase universally quantified variables! Replace with true

15 15 Resolution Based QBF Algorithm false

16 16 Example #2: Quantified Linear Arithmetic formula = predicate | formula Ç formula | : formula | (formula) | 8 var. formula | 9 var. formula predicate =  i a i x i · c 8x. 9y. 9z. ( y +1 · x Æ z +1 · y Æ 2 x +1 · z )

17 17 Solving QLA with projection Eliminate 9x. by projecting x. In Linear Arithmetic over R projection can be done with Fourier-Motzkin elimination. Fourier-Motzkin method to eliminate a variable x n : - for each pair of constraints:  i=1.. n -1 a i ’ x i < x n <  i=1.. n -1 a i x i add a constraint  i =1.. n -1 a i ’ x i <  i =1.. n -1 a i x i - in the end remove all constraints involving x n.

18 18 x + 1 · 3z + 3 2y · 2z + 4 Solving QLA with projection Fourier Motzkin: example. Eliminate y : x + 1 · z + 2 Æ x + 1 · y Æ y · 3z + 3 Æ

19 19 Quantifier elimination - example 8x. 9y. 9z. ( y +1 · x Æ z +1 · y Æ 2 x +1 · z ) 8x. 9y. ( y +1 · x Æ 2 x +1 · y -1 ) 8x. (2 x +2 · x -1)// transform to 9 :9x. : (2 x +2 · x -1) :9x. x > -3 : true false

20 20 Quantifier elimination by projection: summary Given a PNF formula f = Q[ n ]V[ n ]  Q[1]V[1]  For i = 1.. n { if Q[ i ] = 9 then  = project( ,V[ i ]) else  = : project( : ,V[ i ]) } Return 

21 21 More about QBF Example of using QBF (the diameter problem) A search-based procedure for QBF.

22 22 The State Space Diameter Problem S0S0 S2S2 S1S1 S3S3 S5S5 S4S4 diameter = 3 Start from the initial states, the minimum number of steps needed to visit every reachable state S0S0 initial state: S 0 S2S2 S1S1 step 1: S 1, S 2 S4S4 S3S3 step 2: S 3, S 4 S5S5 step 3: S 5

23 23 Why is the Diameter Problem important? Bounded model checking (BMC): search for a ‘bad’ state up to k steps from an initial step. BMC can be formulated as SAT. Increasing k makes is harder. Q: how deep should we go ? A: as deep as the diameter The diameter can be found by solving a QBF problem

24 24 S2S2 S1S1 Why is the Diameter Problem important? Bounded model checking (BMC) Circuit state space diameter completes BMC Can be formulated as QBF instances Provides insights to sequential verification problems in general SjSj SiSi S i, S j : sets of states state transition relation T S0S0 S0S0 S 0 : the set of initial states Does property P hold for the system? S2S2 S1S1 S3S3 S3S3 useful for falsification, but incomplete for verification

25 25 Circuit Constructed for the Diameter Problem Combinational Logic I1I1 O1O1 Combinational Logic InIn OnOn Combinational Logic I n+1 O n+1 Combinational Logic I1’I1’ O1’O1’ Combinational Logic In’In’ On’On’ The idea: prove that for every state reachable in k+1 steps, there exists inputs that drive the model to this state earlier.

26 26 Some Terminology for the Formulations Combinational Logic I1I1 O1O1 Combinational Logic InIn OnOn Combinational Logic I n+1 O n+1 Combinational Logic I1’I1’ O1’O1’ Combinational Logic In’In’ On’On’ Variables: V 1 Circuit consistency condition: C(V 1 )

27 27 Some Terminology for the Formulations Combinational Logic I1I1 O1O1 Combinational Logic InIn OnOn Combinational Logic I n+1 O n+1 Combinational Logic I1’I1’ O1’O1’ Combinational Logic In’In’ On’On’ Variables: V 2 Circuit consistency condition: C(V 2 )

28 28 QBF Formulation Combinational Logic I1I1 O1O1 Combinational Logic InIn OnOn Combinational Logic I n+1 O n+1 Combinational Logic I1’I1’ O1’O1’ Combinational Logic In’In’ On’On’ C(V 1 ) C(V 2 ) Other V1 variables V1 inputsV2 variables

29 29 Another way to project Boolean variables Shannon expansion: 9x.  =  | x =0 Ç  | x =1 8x.  =  | x =0 Æ  | x =1 // can be derived from 8x.  = :9x. :  The same applies for all finite-range variables. Applying to CNF $ resolution But:  does not need to be in CNF, and there is no need to transform the formula to DNF.

30 30 Projection for non-CNF formulas: example 9y 8z 9x. ( y Ç ( x Æ z )) 9y 8z. ( y Ç ( x Æ z ))| x =0 Ç ( y Ç ( x Æ z ))| x =1 9y 8z. (( y ) Ç ( y Ç z )) 9y :9z. ( :y Æ :z ) 9y. : (( :y Æ :z )| z =0 Ç ( :y Æ :z )| z =1 ) 9y. : ( :y ) True

31 31 Search Based QBF Algorithms Work by gradually assigning variables A partial assignment  [KGS98] M. Cadoli, A. Giovanardi, M. Schaerf. An Algorithm to Evaluate Quantified Boolean Formulae. In Proc. of 16th National Conference on Artificial Intelligence (AAAI-98)An Algorithm to Evaluate Quantified Boolean Formulae

32 32 Search Based QBF Algorithms Work by gradually assigning variables A partial assignment   Undetermined Continue search [KGS98] M. Cadoli, A. Giovanardi, M. Schaerf. An Algorithm to Evaluate Quantified Boolean Formulae. In Proc. of 16th National Conference on Artificial Intelligence (AAAI-98)An Algorithm to Evaluate Quantified Boolean Formulae

33 33 Search Based QBF Algorithms Work by gradually assigning variables A partial assignment   Undetermined  Conflict Backtrack Record the reason [KGS98] M. Cadoli, A. Giovanardi, M. Schaerf. An Algorithm to Evaluate Quantified Boolean Formulae. In Proc. of 16th National Conference on Artificial Intelligence (AAAI-98)An Algorithm to Evaluate Quantified Boolean Formulae

34 34 Search Based QBF Algorithms Work by gradually assigning variables A partial assignment   Undetermined  Conflict  Satisfied Backtrack Determine the covered satisfying space [KGS98] M. Cadoli, A. Giovanardi, M. Schaerf. An Algorithm to Evaluate Quantified Boolean Formulae. In Proc. of 16th National Conference on Artificial Intelligence (AAAI-98)An Algorithm to Evaluate Quantified Boolean Formulae

35 35 Search Based QBF Algorithms Work by gradually assigning variables A partial assignment   Undetermined  Conflict  Satisfied The majority of QBF solvers are search based, the DPLL algorithm is an example of this

36 36 Basic DPLL Flow for QBF  e  u ( e Ç u )( :e Ç :u ) Unknown True (1) False(0)

37 37 Basic DPLL Flow for QBF e = 0 Unknown True (1) False(0)  e  u ( e Ç u )( :e Ç :u )

38 38 Basic DPLL Flow for QBF e = 0 u = 1 Unknown True (1) False(0) Satisfying Node  e  u ( e Ç u )( :e Ç :u ) Universal quantification Existential quantification

39 39 Basic DPLL Flow for QBF e = 0 u = 1 Unknown True (1) False(0) Backtrack  e  u ( e Ç u )( :e Ç :u )

40 40 Basic DPLL Flow for QBF e = 0 u = 1 u = 0 Unknown True (1) False(0)  e  u ( e Ç u )( :e Ç :u )

41 41 Basic DPLL Flow for QBF e = 0 u = 1 u = 0 Unknown True (1) False(0)  e  u ( e Ç u )( :e Ç :u )

42 42 Basic DPLL Flow for QBF e = 1 Unknown True (1) False(0)  e  u ( e Ç u )( :e Ç :u ) e = 0 u = 1 u = 0

43 43 Basic DPLL Flow for QBF e = 1 u = 1 Unknown True (1) False(0)  e  u ( e Ç u )( :e Ç :u ) e = 0 u = 1 u = 0

44 44 Basic DPLL Flow for QBF e = 1 u = 1 Unknown True (1) False(0) Conflictin g Node  e  u ( e Ç u )( :e Ç :u ) e = 0 u = 1 u = 0

45 45 Basic DPLL Flow for QBF e = 1 u = 1 Unknown True (1) False(0)  e  u ( e Ç u )( :e Ç :u ) e = 0 u = 1 u = 0

46 46 Basic DPLL Flow for QBF e = 1 u = 1 e = 0 u = 1 u = 0 False Unknown True (1) False(0)  e  u ( e Ç u )( :e Ç :u )

47 47 Basic DPLL Flow for QBF  u  e ( u Ç e )( :u Ç :e ) Unknown True (1) False(0)

48 48 Basic DPLL Flow for QBF Unknown True (1) False(0) u = 1  u  e ( u Ç e )( :u Ç :e )

49 49 Basic DPLL Flow for QBF Unknown True (1) False(0) u = 1 e = 1  u  e ( u Ç e )( :u Ç :e )

50 50 Basic DPLL Flow for QBF Unknown True (1) False(0) u = 1 e = 1e = 0  u  e ( u Ç e )( :u Ç :e )

51 51 Basic DPLL Flow for QBF Unknown True (1) False(0) u = 1 e = 1e = 0  u  e ( u Ç e )( :u Ç :e )

52 52 Basic DPLL Flow for QBF Unknown True (1) False(0) u = 1 e = 1e = 0 u = 0 e = 1  u  e ( u Ç e )( :u Ç :e )

53 53 Basic DPLL Flow for QBF Unknown True (1) False(0) u = 1 e = 1e = 0 u = 0 e = 1 True  u  e ( u Ç e )( :u Ç :e )

54 54 Naïve DPLL Based Approach Works on a CNF database Learning and non-chronological backtracking is much harder – requires a change! Modern QBF solvers do not work with CNF, rather with a combination of CNF with Cubes. This lets them apply learning efficiently.


Download ppt "1 Quantified Formulas Acknowledgement: QBF slides borrowed from S. Malik."

Similar presentations


Ads by Google