Download presentation

Presentation is loading. Please wait.

Published byTamara Stavely Modified over 2 years ago

1
Logic Stuff & FV Basics Erik Seligman CS 510, Lecture 2, January 2009

2
Goals of This Session Review basics of boolean logic, and some fundamental FV algorithms Logic should just be a review for people in this class! Establish common symbols & terms Variety of ways to express common ops Have basic foundation for discussing FV Getting a flavor for contents of tools NOT describing full internal algorithms NOT full mathematical rigor –If you want screenfuls of symbols, take Xie or Song class!

3
Basic Boolean Logic

4
Fundamental operations For consistency, will use Verilog-like notation: AND: a & b OR: a | b NOT: ~a Sometimes AND represented as multiplication, and OR as addition Like arithmetic, except 1+1 == 1 Implication: a -> b Same as: ~a | b Terms: a is the antecedent, b is the consequent

5
Basic Boolean Identities Commutative, Associative Distributive both ways a & (b|c) == (a&b) | (a&c) a | (b&c) == (a|b) & (a|c) Idempotence: a&a == a, a|a == a DeMorgan ~(a&b) = ~a | ~b ~(a|b) = ~a & ~b

6
Implication relationships a -> b Converse: b -> a Inverse: ~a -> ~b Contrapositive: ~b -> ~a Which pairs are identical in truth value? Can be useful when restating for FV Use |= (“logically entails”) symbol as distinct from implication when appropriate (a -> b) |= (~b -> ~a)

7
Inference Rules Rules to derive new statements Some basic rules (a -> b), (a) (modus ponens) b (a | b), (~a) b a -> F (contradiction) ~a

8
What is a Proof? Apply sequence of inference rules Example: Known: S1: a, S2: (a -> b), S3: (d -> ~b)) Prove: ~d –C1: S1, S2 |= b –C2: S3 |= (~d | ~b) –C3: C1, D3 |= ~d

9
Predicate Logic Add predicates, or functions, and quantifiers: For All (A), Exists (E) Examples: A(x) Cat(x) -> Mammal(x) E(x) Cat(x) & ~Black(x)

10
Linear Temporal Logic (LTL)

11
What Is Linear Temporal Logic? Add notion of time to predicate logic X = Next time G = Globally / always F = Future / eventually U = Until Statements evaluated at points in time Discrete, “clocked” machine model Lots of power for stating properties Useful in real-life designs In upcoming 2009 SVA standard

12
Equivalent operations in LTL Ga == ~(F(~a)) Fa == ~(G(~a)) Fa == T U a Distributive laws G(a &b) = Ga & Gb F(a | b) = Fa | Fb But be careful… –can G(a|b) be distributed? –How about F(a&b)?

13
LTL examples Eventually bus grant will occur F(grant) Requests will be held until there is a grant or a power down req -> (req U (grant | power_down)) Deadlock free Ai. req[i] -> F(grant[i]) At some point after reset, the reset signal will stay low forever reset -> F(G(~reset))

14
LTL: Strong and Weak Statements If the machine may exit/terminate, and an “until” is waiting, did it pass? Example: (a -> b U c) Strong property: must finish Weak property: considered true if evaluation may never complete Usually the default

15
Types of Properties Safety: “Something bad won’t happen.” G(~ (grant & busy)) Liveness: “Something good will happen.” F(grant) Be careful: weak or strong? Fairness: “Something happens infinitely often.” G(F(!busy)) Usually considered subset of liveness Often required as assumption on design inputs

16
Binary Decision Diagrams (BDDs)

17
BDD Example (a & c) | (~a & b & ~c) a b cc 1 1 0 0 0 1 101 0 001

18
BDD Reduction & Ordering Always specify an order for the variables Reduction: merge identical nodes a b cc 0 1 0 0 0 1 101 0 011 a b c 1 0 0 0 1 1 0 10

19
Why are BDDs useful? Canonical: unique for given var ordering Assuming they are reduced Two formulas equivalent iff same BDD! Easy to define operations Complement Substitute constant (“Restrict”) Apply any boolean operator (&, |, etc) Many cases proven efficient in practice But danger of exponential blowup

20
Complement A BDD Replace f with ~f: just reverse terminals a b cc 1010 1 0 0 0 1 101 1010 0101 0101 1010

21
Substitute Constant in BDD Just eliminate irrelevant subtrees, connect correct nodes Example: c = 1 a b cc 1 1 0 0 0 1 101 0 001

22
Substitute Constant in BDD Just eliminate irrelevant subtrees, connect correct nodes Example: c = 1 a b 1 0 0 1 001

23
Substitute Constant in BDD Just eliminate irrelevant subtrees, connect correct nodes Example: c = 1 a 10 0 1 Don’t forget to reduce

24
Apply Operation to BDDs (AND, OR, etc) Basic idea: recursively examine, with one var restricted to constant Each recursive call reduced #vars by 1 At terminal apply obvious function APPLY(f1,f2,AND) = v1 0 1 APPLY(f1,f2,AND)| v1=0 APPLY(f1,f2,AND)| v1=1

25
APPLY example Goal: BDD1(a,b) AND BDD2(a,b) a 10 0 1 b 10 0 a 10 10 BDD1 = a&b BDD2 = !a

26
APPLY example: Step 1 a 10 0 1 b 10 0 a 10 10 Use restrictions for a=0, a=1 a 10 APPLY| a=0 APPLY| a=1

27
APPLY example: Step 2 a 10 0 1 b 10 0 a 10 10 Use restrictions for a=0, a=1 a 10 0 AND 1 BDD1.b AND 0

28
APPLY example: Step 3 a 10 0 1 b 10 0 a 10 10 Compute results using constants if available a 10 00

29
APPLY example: Result 0 2 recursive calls per variable But always reduces size of problem So eventual constants guaranteed

30
BDDs: Exponential Blowup (a&b) | (c&d) a b c 10 d

31
BDDs: Exponential Blowup (a&b) | (c&d) a c 10 c bb d d

32
SAT Algorithms

33
What is SAT? SAT= general problem: can boolean statement be satisfied? Known NP-complete But good heuristics known FV Focus was on BDDs in 1990s Now seen as too restrictive Modern tools have BDD + SAT engines

34
SAT Example: DPLL Algorithms Algorithms first proposed in 1960’s But renewed interest due to FV application Start by converting formula to CNF form: product-of-sums (clauses) (a+b+c)(a+~d+e)(~b+~c)… Reminder: multiplication=AND, addition=OR Target: assignment satisfying every term If some clause is 0, assignment fails

35
Outline of DPLL algs (from Zhang/Malik paper, see ref slide)

36
Sub-functions Deduction: find what must be true Example: (a+b)(~c+d) If c was assigned 1, then d must be 1 Can spend compute cycles to be more aggressive Choose_free_variable: tricky part! Look for var that affects most clauses? Weight clauses strategically? Learn from conflicts/backtracks?

37
Other DPLL SAT Aspects Capacity: How to store set of clauses? Direct: sparse matrix representation BDDs, tries, other options Preprocessing First pass: gather high-level data hints Randomization Random restart if seem to be dying? Other approaches: SAT is still an active research area! www.satlive.org

38
References http://www.jimloy.com/logic/logic.htm http://www.jimloy.com/logic/logic.htm http://ocw.mit.edu/OcwWeb/Electrical-Engineering- and-Computer-Science/6-042JFall- 2005/LectureNotes/index.htm http://ocw.mit.edu/OcwWeb/Electrical-Engineering- and-Computer-Science/6-042JFall- 2005/LectureNotes/index.htm http://en.wikipedia.org/wiki/Linear_temporal_logic http://en.wikipedia.org/wiki/Linear_temporal_logic http://www.inf.unibz.it/~artale/FM/slide3.pdf http://www.inf.unibz.it/~artale/FM/slide3.pdf http://www.cerc.utexas.edu/~gnolkha/verif/BDD.ppt http://www.cerc.utexas.edu/~gnolkha/verif/BDD.ppt http://www.comp.nus.edu.sg/~abhik/CS4271/lectures/L ec11-BDD.pdf http://www.comp.nus.edu.sg/~abhik/CS4271/lectures/L ec11-BDD.pdf http://www.satlive.org/ http://www.satlive.org/ http://www.princeton.edu/~chaff/publication/cade_cav_ 2002.pdf http://www.princeton.edu/~chaff/publication/cade_cav_ 2002.pdf

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google