G52PAS 2011-2012 Answer to the exercise on FOL Express the following sentences in first-order logic: 1. A friend of a friend is a friend. (Use a binary predicate F riend.) 2. An enemy’s enemy is a friend. (Use binary predicates F riend and Enemy.) 3. If two people are friends, then they are not enemies. (Use binary predicates F riend and Enemy.) 4. Any two people are either enemies or friends. (Use binary predicates F riend and Enemy.) 5. John has a friend. (Use a binary predicate F riend and constant J for John.) 6. John has at least two friends. (Use a binary predicate F riend, constant J for John, and equality=.) 7. John has exactly two friends, and everyone else is an enemy. (Use binary predicates F riend and Enemy, constant J for John, and equality=.) Answer I used F riend(x, y) for ‘y is a friend of x’ and also for ‘x and y are friends’. May be the latter is better expressed as F riend(x, y) ∧ F riend(y, x)’, but I wanted to keep the formulas shorter. (Same for enemies.) 1. A friend of a friend is a friend. ∀x∀y∀z(F riend(x, y) ∧ F riend(y, z) ⇒ F riend(x, z)) 2. An enemy’s enemy is a friend. ∀x∀y∀z(Enemy(x, y) ∧ Enemy(y, z) ⇒ F riend(x, z)) 3. If two people are friends, then they are not enemies. ∀x∀y(F riend(x, y) ⇒ ¬Enemy(x, y)) 4. Any two people are either enemies or friends. ∀x∀y(F riend(x, y) ∨ Enemy(x, y)) 5. John has a friend. ∃xF riend(J, x) 1 6. John has at least two friends. ∃x∃y(F riend(J, x) ∧ F riend(J, y) ∧ ¬(x = y)) 7. John has exactly two friends, and everyone else is an enemy. ∃x∃y(F riend(J, x)∧F riend(J, y)∧¬(x = y)∧∀z(¬(z = x)∧¬(z = y) ⇒ Enemy(J, z)) 2