HOMEWORK FIVE

out Thursday11/8, due Monday 11/19

Here are some simple exercises to help you get comfortable with propositional logic. Write out your answers and submit them in class on Wednesday November 4. We'll use the following symbols:

1. Checking Validity

Use the functions in logic.py to see which of the following are valid, i.e., true in every model. You will have to (i) convert these sentences to the appropriate string form that the python code uses (see the comments in the code) and (ii) use the expr() function in logic.py to turn each into an Expr object, and (iii) use the tt_true() function to check for validity. Note that you will have to download the three files in the code directory to use functions in logic.py. Provide text from a session that shows the result of checking the validity of each. We've done the first one as an example.

  1. p v ¬ p

    >>> tt_true(expr('P | ~P'))
    True

  2. p → p
  3. p → (p v q)
  4. (p v q) → p
  5. ((a ∧ b) → c) ↔ (a → (b → c))
  6. ((a → b) → a) → a

2. Satisfiability

Use the functions in logic.py to see which of the following are are satisfiable. We've done the first one as an example.

  1. p ∧ q

    >>> dpll_satisfiable(expr('P & Q'))
    {P: True, Q: True}

  2. alive ==> ~ dead & ~ alive & ~ dead
    alive → ¬ dead ∧ ¬ alive ∧ ¬ dead
  3. p → ¬ p v p
  4. ~ (p v ¬ p)

3. Propositional Consequence

For each of the following entailment relations, say whether or not it is true. The text on the left of the entailment symbol (⊨) represents one or more sentences (seperaed by commas) that constitute a knowledge base. We've dne the first one for you.
  1. p ∧ q ⊨ p

    true
  2. p ⊨ p ∧ q
  3. p ⊨ p v q
  4. p ⊨ ¬ ¬ p
  5. p → q ⊨ ¬ p → ¬ q
  6. ¬ p ⊨ p → q
  7. ¬ q ⊨ p → q
  8. p, p → q ⊨ q
  9. ¬ p , q → p ⊨ ¬ q

4. English to FOL

Translate the following English sentences into first order logic. If you think a sentence is ambiguous, describe the ambiguity and give logical expressions for all interpretations. We've done the first one for you using a notation with simple ascii characters for logical operators (e.g., A:∀, E:∃, =>:→, <=>:↔, ^:∧, v:v, ~:¬, >:>)

  1. There is no largest prime number.

    ~ Ex number(x) ^ prime(x) ^ Ey number(y) ^ prime(y) ^ y>x
    ~(Ex number(x) ^ prime(x) ^ (Ay number(y) ^ prime(y) -> x>=y))

  2. Everything is either dead or alive.
  3. Dead things are not animate.
  4. Zombies are not alive but they are animate.
  5. Good food is not cheap and cheap food is not good.
  6. John has exactly two brothers.
  7. No person can have two mothers.
  8. If John has a sister, she is smart.
  9. Every person is either male or female and no person can be both male and female.
  10. The enemy of your enemy is your friend.
  11. An ancestor of your ancestor is your ancestor.

5. CNF and horn clauses

For each of the following FOL sentences, (a) give a one-sentence, unambiguous paraphrase in English of what you think the FOL sentence means, (b) the say whether or not it can be rewritten as one or more horn clauses and (c) rewrite the sentence as one or more sentences in conjunctive normal form, identifying any skolem constants or functions you introduce.. Feel free to use the simple ascii forms for logical operators described in the previous problem and to use the to_cnf() function in logic.py to check your answers. We've done the first one for you.

  1. ∀x knows(x x) ∧ likes(x, x)

    (a) Everyone knows and likes himself; (b) this can be rewritten as a horn clause; (c) set of clauses: [knows(x, x), likes(x, x)]
  2. ∀x ∀y married(x, y) → loves(x, y) v hates(x, y)
  3. ∀x ∀y loves(x, y) ↔ loves(y, x)
  4. ∀x ∀y dating(x, y) v engaged(x, y) → knows(x, y) ∧ likes(x, y)
  5. ∀x ∀y loves(x, y) → ¬ hates(x, y)
  6. ∀x ∀y ¬ knows(x, y) → ¬ likes(x, y)
  7. ∀x ∃y knows(x, y) ∧ hates(x, y)
  8. ∃y ∀x knows(x, y) ∧ hates(x, y)
  9. ¬ (∀x loves(x, x))
  10. ¬ (∃x ∀y knows(x, y))

What and how to submit

Submit your homework on or before 23:59:59 on Monday, November 19 as an ascii or pdf file the CVS system (details to be supplied once the repo is set up). If you are unable to get CVS to work, submit via email to cmsc671hw@cs.umbc.edu.