Logik 2 - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Logik 2

Description:

Institute for Applied Information Processing and Communications (IAIK) Secure ... A clause is a disjunction of literals (p q ... – PowerPoint PPT presentation

Number of Views:57
Avg rating:3.0/5.0
Slides: 18
Provided by: roderic5
Category:

less

Transcript and Presenter's Notes

Title: Logik 2


1
Logik 2
  • More propositional logic

2
Example Magic Square
  • Every element is 1,2, , or 9
  • Each row, each column, and each diagonal sums to
    15
  • Can I present this requirement as a propositional
    logic formula?

? 15
? 15
? 15
?15
?15
?15
?15
?15
3
First Steps
15 159 168 249 258 267
348 357 456
  • Introduce variables x11x19, x21x29,,x19x99
  • xij is supposed to mean xi j
  • Let r1 (x11?x25?x39) ? (x11?x26?x38) ?
    (x11?x28?x36) ? row 1 sums to 15
  • Similar for r2, r3, c1, c2, c3, d1, d2 rows,
    columns, and diagonals
  • A position holds exactly one number
  • Let vij be an abbreviation for xij ? ?k ?j ? xik
  • Let vi ?j vij ? ?j xij exactly one number for
    square i
  • Let v ?i vi exactly one number in every
    position
  • Each number occurs once
  • Let ui ?j ?k ?j ? (xji ? xki) number i occurs
    once in square
  • Let u ?i ui Each number occurs once in square
  • The formula is
  • v ? u ? r1 ? r2 ? r3 ? c1 ? c2 ? c3 ? d1 ? d2

4
Next
  • Write a script to generate the formula
  • Download limboole and a SAT solver like Precosat
    from Armin Bieres home page
  • Run the formula through precosat to get an answer
  • Then, try the same for Sudoku

5
Some Rules
  • ?(a ? b) is equivalent to ?a ? ?b
  • ?(a ? b) is equivalent to ?a ? ?b
  • ? ? ? is equivalent to ?? ? ?
  • We can see ? as an abbreviation, leaving us only
    with ?, ?, and ?.
  • (Prove by drawing truth tables)
  • Proof by induction. Let P be a claim about
    formulas
  • If P(p) and P(?p) and
  • P(?) and P(?) implies P(? ? ?)
  • P(?) and P(?) implies P(? ? ?)
  • P(?) implies P(??)

6
Equivalence of Circuits
  • Circuits can safely be modeled at Boolean level
  • There is a big market for tools that optimize
    circuits.
  • But they make mistakes!
  • How do we check whether two circuits are
    equivalent?

7
Example
  • Let ? ? ? abbreviate (? ? ?) ? (? ? ?)
  • Let ? ? ? abbreviate ?(? ? ?)
  • Compare
  • c ? (?a ? b) ? ( a ? ? b)
  • c ? (a ? b) ? (?a ? ?b)
  • Rename
  • ? c ? (?a ? b) ? ( a ? ? b)
  • ? c ? (a ? b) ? (?a ? ?b)
  • Introduce a comparison
  • c ? c
  • Is the following satisfiable?
  • ? (c ? (?a ? b) ? ( a ? ? b)) ? (c ? (a ? b)
    ? (?a ? ?b)) ? (c ? c)
  • Claim ? is satisfiable iff ? and ? are
    equivalent

8
CNF
  • SAT solvers decide satisfiability very quickly
  • For simplicity, sat solvers only take conjunctive
    normal form (CNF)
  • Definitions
  • A literal is a propositional symbol or its
    negation (p, ?p)
  • A clause is a disjunction of literals (p ? q ?
    ?r)
  • A formula in CNF is a conjunction of clauses
    ((?p?q) ? (?q ? r) ? (?r ? ?p))
  • Claim I can rewrite any formula ? to a formula
    CNF(?) in CNF such that ? is satisfiable iff
    SAT(?) is satisfiable

9
Rewriting to CNF, Conjunction
  • c ? a ? b
  • is equivalent to
  • c ? a and
  • c ? b and
  • a ? b ? c
  • is equivalent to
  • (?c ? a) ? (? c ? b) ? (?a ? ?b ? c)

10
Rewriting to CNF
  • Idea
  • For every subformula introduce a new variable
  • ? (p ? q) becomes CNF(?) (xp?q ? p ? q) ?
    xp?q
  • ? (p ? q) ? ?p becomes CNF(?) (xp?q ? p ? q)
    ? (x?p ? ?p) ? (x? ? xp?q ? x?p) ? x?
  • Note
  • ? and CNF(?) are not equivalent!
  • ? and CNF(?) are equisatisfiable
  • CNF(?) can easily be written as CNF
  • Only a linear blowup
  • Rewriting to CNF
  • r ? (p ? q) is equivalent to (p ? r) ? (q ? r) ?
    (r ? p ? q) is equivalent to (?p ? r) ? (?q ? r)
    ? (?r ? p ? q)
  • Similar for conjunction and negation

11
Rewriting a formula to CNF
  • For any subformula ?,
  • If ? is a literal, let x? ?
  • Otherwise, let x? be a new variable
  • Definition CNF(?) EXT(?) ? x?
  • Base EXT(p) p EXT(?p) ?p
  • Recursion
  • EXT(? ? ?) EXT(?) ? EXT(?) ? (?x? ? x?) ? (?x?
    ? x?) ? (?x? ? x? ? x?)
  • Note x? ? ? ?
  • EXT(? ? ? ) EXT(?) ? EXT(?) ? (x? ? x?) ? (x? ?
    x?) ? (?x? ? ?x? ? x?)
  • Note x? ? ? ?
  • EXT(??) EXT(?) ? (x? ? x?) ? (?x? ? ?x?)
  • Note x? ??

The formula is satisfied
The assignment follows the rules of the formula
12
Proof of Equisatisfiability
  • Theorem ? is satisfiable iff CNF(?) is
    satisfiable
  • Lemma 1 If CNF(?) is satisfiable, then ?
    satisfiable
  • Lemma 2 If ? is satisfiable, then CNF(?)
    satisfiable

13
Lemma 1
  • Lemma 1 If CNF(?) is satisfiable, then ?
    satisfiable
  • Proof
  • We will prove if e CNF(?) then e ?
  • Proof by induction. Suppose e CNF(?). Then, e
    EXT(?) ? x?
  • base case ? p, ? ?p. Clear because EXT(?)
    ?
  • Induction step
  • Suppose ? ? ? ?
  • EXT(?) EXT(?) ? EXT(?) ? (?x? ? x?) ? (?x? ?
    x?) ? (?x? ? x? ? x?)
  • e x? so
  • e EXT(?) ? x? or e EXT(?) ? x? so
  • e CNF(?) or e CNF(?), so
  • e ? or e ?, so
  • e ? ? ? ?
  • Similar for conjunction and negation

14
Rewriting to CNF
  • You can do the same for circuits. Try with
    example

15
SAT Solving Simple Observations
  • Definition a partial assignment assign values to
    some variables.
  • An assignment satisfies a formula in CNF if it
    makes all clauses true
  • A partial assignment does not satisfy a formula
    if there is a clause that it makes false
  • Boolean Constraint propagation
  • For a clause (a ? b), if a partial assignment e
    sets a FALSE, then any full assignment e that
    extends e and satisfies the formula sets b
    TRUE.
  • Example a ? b ? (a ? b)

16
SAT Solving
  • DPLL branch and bound (Davis, Putnam, Logeman,
    Loveland, 1960, 1962)
  • Call SAT(?)
  • SAT(e)
  • e BCP(e)
  • If e makes ? true return true
  • If e makes ? false, return false
  • Pick a variable v
  • r1 SAT(e e ? (var ? 1)
  • r0 SAT(e e ? (var ? 0)
  • return r0 r1.
  • Example (? a ? b) ? (a ? ? b) ? (? a ? ? b)

17
  • more details see Biere, http//fmv.jku.at/amc/,
    from whence the examples.
Write a Comment
User Comments (0)
About PowerShow.com