Logic and Computability - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

Logic and Computability

Description:

1 Intro & Propositional Logic. Administrative. Class: Tue 12 ... 'disjunction'): p q, it rains or I have an umbrella (inclusive disjunction: both may be true) ... – PowerPoint PPT presentation

Number of Views:29
Avg rating:3.0/5.0
Slides: 23
Provided by: roderic5
Category:

less

Transcript and Presenter's Notes

Title: Logic and Computability


1
Logic and Computability
  • 1 Intro Propositional Logic

2
Administrative
  • Class Tue 12-2 c.t.
  • Material
  • Huth and Ryan, Logic in Computer Science,
    Cambridge University Press, 2004. (Buy the book)
  • Slides will be online after class
  • Lectures
  • Content
  • Propositional Logic
  • Predicate Logic, computability
  • Temporal logic

3
Uebung
4
Why Logic?
5
Why Logic?
  • Rules for discussions
  • Understand thinking
  • Understand reasoning
  • Learn how to write proofs
  • Describe questions unambiguously
  • Learn how to automate proofs
  • Understand what is and is not provable
  • Use a prover to solve a question
  • We will be precise, even pedantic in our proof
    rules why?

6
Types of Logic
  • Three important types
  • Propositional logic
  • If it rains, I get wet. I am not wet. Therefore,
    it does not rain.
  • Simple statements about facts (propositions)
  • Can be proven true or false automatically
  • Very powerful tools are available (SAT solvers)
  • Predicate logic
  • For every lock there is a key, but there is no
    key for every lock.
  • More complicated statements involving quantifiers
  • Cannot in general be proven correct or incorrect
  • Tools (theorem provers ) help you write proofs
  • Temporal logic
  • Whenever it rains, eventually the sun will shine
  • Statements involving time

7
Use of Logic
  • Propositional logic has strong ties to computer
    circuits (also called logic circuits)
  • Check equivalence of two circuits
  • Automatic Test Pattern Generation
  • Check if circuit adheres to spec
  • But also search questions over finite domains

8
Use of Logic
  • Predicate logic
  • Very general
  • Subsumes many other restricted logics in common
    use
  • Program correctness
  • Quantifiers help solve game-style questions.
  • Not necessarily finite domain
  • Temporal Logic
  • Verification of reactive systems
  • Whenever a request arrives, eventually the
    request is granted
  • The request is never granted to two requestors at
    the same time

9
Classical Questions in Logic
  • Does one formula entail another?
  • If x then y. x is true. Therefore, y is true
  • If x then y. y is false. Therefore, x is false
  • Is this formula always true? (validity)
  • ((x implies y) and x) implies y
  • Can this formula ever be true? (satisfiability)
  • (x implies y) and x and (not y)
  • (x implies y) and (not x) and y
  • Is the formula true in this case? (model
    checking)
  • x is true, y is true. Can we conclude (x and y)?
  • (These questions are closely related)
  • Can I write a program that answers these
    questions automatically?

10
Contents of Class
  • Propositional Logic
  • The language and its meaning, proof by search for
    a model
  • Deductive proofs
  • Connection between model-based and deductive
    proofs
  • Questions is this formula always true? Can it be
    true at all?
  • Predicate Logic
  • The language and its meaning
  • Deductive proofs
  • Why we cannot prove everything
  • Questions is this formula always true? Can it be
    true at all?
  • Temporal Logic
  • The language and its meaning
  • Model checking
  • Question Does a given model fulfill a formula?

11
Today
  • The syntax of propositional logic
  • The semantics of propositional logic
  • Proving validity and satisfiability
  • Complexity
  • An example
  • (HR 1.4)

12
Syntax of Propositional Logic
  • We have
  • proposition symbols p, q, r. They stand for
    statements that we do not analyze any further.
    it rains, I am wet, I have an umbrella.
  • We have Boolean connectives
  • ? (and, conjunction) p ? q, it rains and I
    have an umbrella
  • ? (or, disjunction) p ? q, it rains or I
    have an umbrella (inclusive disjunction both may
    be true)
  • ? (not, negation) ?p it does not rain
  • ? (implication) p ? q if it rains, I am wet
  • In BNF ? p ? ? ? ? ? ? ?? ? ? ?

13
Terminology
  • An environment gives a value for each
    propositional symbols.
  • Example (ptrue, qfalse, rfalse) it rains, I
    am not wet, I do not have an umbrella
  • We will write T for true and F for false. (Also
    usual 1,0)
  • A model of a formula is an environment that makes
    the model true.
  • Example (ptrue, qfalse, rfalse) is a model of
    p ? ?q
  • We write (ptrue, qfalse, rfalse) p ? ?q
  • A formula is satisfiable if it has a model.
  • p ? ?q is satisfiable
  • p ? ?p is not satisfiable
  • A formula is valid if all its environments are
    models
  • (p ? q) ? q is valid

14
Semantic of Propositional Logic Truth Tables
  • Compositional if you know whether the parts are
    true, you know whether the whole is true
  • Perhaps ? is not what you expect.
  • It does not rain. Therefore, If it rains, I am
    wet.

15
Parsing a Formula
  • What is the meaning of (((?p) ? q) ? (p ? (q ?
    (?r))))?
  • It is a tree, represented by
  • ?
  • ?
  • ?
  • p
  • q
  • ?
  • p
  • ?
  • q
  • ?
  • r

16
Semantics of Propositional Logic
  • Take the model (p T, qF, r F). What is the
    value of (((?p) ? q) ? (p ? (q ? (?r))))?
  • ? 1
  • ? 0
  • ? 0
  • p 1
  • q 0
  • ? 0
  • p 1
  • ? 0
  • q 0
  • ? 1
  • R 0

17
Semantics of Propoositional Logic
Is p ? (q ? ? r) valid? Satisfiable?
18
A Proof rule
  • Suppose ? has variables p1,, pk. How doe we
    check satisfiability of ??
  • How about validity?
  • What is the complexity?

19
A Proof rule
  • For each environment e
  • If e ? then ? is satisfiable
  • If not (e ?), then print not valid
  • Complexity of solution there are 2k possible
    environments. Checking one environment takes
    time linear in the size of the formula. Thus
    exponential time.
  • In fact, satisfiability is NP complete
  • Checking an answer can be done in polynomial time
  • Any polynomial time Turing machine can be encoded
    as a propositional-logic formula of polynomial
    size
  • What is the complexity of checking validity?

20
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
21
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
  • Let ui ?j ?k ?j ? (xji ? xki) number i occurs
    once in square
  • Let u ?i ui Each number occurs once in square
  • Your formula is
  • v ? u ? r1 ? r2 ? r3 ? c1 ? c2 ? c3 ? d1 ? d2

22
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
Write a Comment
User Comments (0)
About PowerShow.com