1. Proving Logical Entailment
7.4 "Which of the following are correct" (Russell & Norvig, 2010)?
- "a. False ⊨ True" is true, or more accurately it can be considered "vacuously true." A⊨B is only false when B is false.
- "b. True ⊨ False." is false. Fundamental to semantic entailment is that A⊨B says "if A is true then B must also be true". True ⊨ False violates this and is therefore false.
- "c. (A∧B)⊨(A⇔B)." is true because all the models where (A∧B) is true (there is only one, seen in green below), (A⇔B) is also true.
AFFTTBFTFT(A∧B)FFFT(A↔B)TFFT - "d. A⇔B⊨A∨B." is false because there is one model where A⇔B is true but A∨B is false, which is shown in red below.
AFFTTBFTFTA⇔BTFFTA∨BFTTT - "e. A⇔B⊨¬A∨B." is true, for the same reasons as in part c.
AFFTTBFTFTA⇔BTFFT¬A∨BTTFT - "f. (A∧B)⇒C⊨(A⇒C)∨(B⇒C)" is true, for the same reasons.
AFFFFTTTTBFFTTFFTTCFTFTFTFT(A∧B)⇒CTTTTTTFT(A⇒C)∨(B⇒C)TTTTTTFT - "g. (C∨(¬A∧¬B))≡((A⇒C)∧(B⇒C))" is true, for the same reasons.
AFFFFTTTTBFFTTFFTTCFTFTFTFT(C∨(¬A∧¬B))TTFTFTFT((A⇒C)∧(B⇒C))TTFTFTFT - "h. (A∨B)∧(¬C∨¬D∨E)⊨(A∨B)." is true because (A∨B) will always be true when (A∨B)∧(¬C∨¬D∨E) is, since the conjunction with (¬C∨¬D∨E) doesn't adds models that are true when (A∨B) is not.
- "j. (A∨B)∧¬(A⇒B) is satisfiable." This is correct, the expression is satisfiable because it is true when A is true and B is false.
- "k. (A⇔B)∧(¬A∨B) is satisfiable." This is correct, the expression is satisfiable because it is true when both A and B are true and when both are false.
- "l. (A⇔B)⇔C has the same number of models as (A⇔B) for any fixed set of proposition symbols that includes A,B,C." This is correct, because the fixed set of propositions includes all symbols found in both expressions.
2. Using Resolution to Prove a Sentence
7.12 "Use resolution to prove the sentence ¬A∧¬B from the clauses in Exercise 7.20."
We start off with a KB that is a conjunction of sentences as in Exercise 7.20 below:
7.20 Convert the following set of sentences to clausal form. S1: A⇔(B∨E). S2: E⇒D. S3: C∧F⇒¬B. S4: E⇒B. S5: B⇒F S6: B⇒C Give a trace of the execution of DPLL on the conjunction of these clauses (Russell & Norvig, 2010).
We want the contents of KB in CNF so we convert each sentence to CNF. Since S1 has OR operators after converting, it will be broken up into three clauses. The others are one CNF clause each, as shown in boxes below.
S1:S2:S3:S4:S5:S6:≡≡≡≡≡≡≡≡≡≡A⇔(B∨E)(A⇒(B∨E))∧((B∨E)⇒A)(¬A∨B∨E)∧(¬(B∨E)∨A)(¬A∨B∨E)∧((¬B∧¬E)∨A)(¬A∨B∨E)∧(¬B∨A)∧(¬E∨A)E⇒D¬E∨DC∧F⇒¬B¬(C∧F)∨¬B¬C∨¬F∨¬BE⇒B¬E∨BB⇒F¬B∨FB⇒C¬B∨CBy α⇔β≡(α⇒β)∧(β⇒α)By α⇒β≡¬α∨βBy De MorganS1 in CNF, by distributivity of ∨ over ∧S3 in CNF, by α⇒β≡¬α∨βBy α⇒β≡¬α∨βS3 in CNF, by De MorganS4 in CNF, by α⇒β≡¬α∨βS5 in CNF, by α⇒β≡¬α∨βS6 in CNF, by α⇒β≡¬α∨β We are trying to prove KB ⊨¬A∧¬B so we have α=¬A∧¬B so ¬α is ¬(¬A∧¬B), which, by De Morgan's law, is logically equivalent to (A∨B). We start with a set of clauses from the CNF clauses in boxes along ¬α which is (A∨B)
We iteratively select a pair from clauses and perform the resolution on each. For example, (a) below shows resolving clauses pairs with complementary literals A∨B and ¬A∨B∨E by the process B∨EA∨B, ¬A∨B∨E, which cancels the A because A and ¬A are complementary literals and leaves the resolvent B∨E shown labeled with (b) below. If the calculated resolvent is ever empty, we have proven KB ⊨α.
I started to answer this using a full trace using the official Python code but the trace was way too long to list here. But there is more than one way to answer this depending on the order of the pairs being passed PL-RESOLVE so I rearranged the order of the clauses to make the trace short, along with not showing some iterations that don't matter to the result, shown as "//..." below.
function PL-RESOLUTION(KB,α)
clauses←{ (A∨B), ¬A∨B∨E, ¬C∨¬F∨¬B, ¬B∨F, ¬E∨B, ¬B∨C, ¬B∨A, ¬E∨A, ¬E∨D }
for each pair in clauses // (the loop iterations are expanded below):
resolvents← PL-RESOLVE(A∨B, ¬A∨B∨E) 0000(a) in graph
clauses←clauses∪{ B∨E } 000000000000000000(b) in graph
resolvents← PL-RESOLVE(¬C∨¬F∨¬B, ¬B∨F) (c) in graph
clauses←clauses∪{ ¬B∨¬C } 000000000000000(d) in graph
//...
resolvents← PL-RESOLVE(B∨E, ¬E∨B) 0000000(e) in graph
clauses←clauses∪{ B } 000000000000000000000(f) in graph
//...
resolvents← PL-RESOLVE(¬B∨C,¬B∨¬C) 0000(g) in graph
clauses←clauses∪{ C } 000000000000000000000(h) in graph
//...
resolvents← PL-RESOLVE(B,¬B) // empty! 0000(i) in graph
if resolvents contains the empty clause then return true //true is returned!
Below is the trace shown as a graph. The empty set at (i) proves that KB ⊨¬A∧¬B
3. Map Coloring Problem
8.9 This exercise uses the function MapColor and predicates In(x,y), Borders(x,y), and Country(x), whose arguments are geographical regions, along with constant symbols for various regions. In each of the following we give an English sentence and a number of candidate logical expressions. For each of the logical expressions, state whether it (1) correctly expresses the English sentence; (2) is syntactically invalid and therefore meaningless; or (3) is syntactically valid but does not express the meaning of the English sentence (Russell & Norvig, 2010)
- "a. Paris and Marseilles are both in France".
- "(i) In(Paris∧Marseilles,France)" is (2), is syntactically invalid because of the conjunction's placement.
- "(ii) In(Paris,France)∧In(Marseilles,France)" is (1), correctly expressed.
- "(iii) In(Paris,France)∨In(Marseilles,France)" is (3), not expressing English meaning of "both."
- "b. There is a country that borders both Iraq and Pakistan."
- "(i) ∃ c Country(c)∧Border(c,Iraq)∧Border(c,Pakistan)" is (1), correctly expressed.
- "(ii) ∃ c Country(c)⇒[Border(c,Iraq)∧Border(c,Pakistan)]" is (3), not expressing English meaning.
- "(iii) [∃ c Country(c)]⇒[Border(c,Iraq)∧Border(c,Pakistan)]" is (2), is syntactically invalid because of the conjunction's placement.
- "(iv) ∃ c Border(Country(c),Iraq∧Pakistan)" is (2), is syntactically invalid because of the conjunction's placement.
- "c. All countries that border Ecuador are in South America."
- "(i) ∀ c Country(c)∧Border(c,Ecuador)⇒In(c,SouthAmerica)" is (1), correctly expressed.
- "(ii) ∀ c Country(c)⇒[Border(c,Ecuador)⇒In(c,SouthAmerica)]" is (1), correctly expressed.
- "(iii) ∀ c [Country(c)⇒Border(c,Ecuador)]⇒In(c,SouthAmerica)" is (3), not expressing English meaning.
- "(iv) ∀ c Country(c)∧Border(c,Ecuador)∧In(c,SouthAmerica)" is (3), not expressing English meaning.
- "d. No region in South America borders any region in Europe."
- "(i) ¬[∃ c,d In(c,SouthAmerica)∧In(d,Europe)∧Borders(c,d)]" is (1) correctly expressed.
- "(ii) ∀ c,d [In(c,SouthAmerica)∧In(d,Europe)]⇒¬Borders(c,d)]" is (1) correctly expressed.
- "(iii) ¬c In(c,SouthAmerica)⇒∃ d In(d,Europe)∧¬Borders(c,d)" is (3), not expressing English meaning.
- "(iv) ∀ c In(c,SouthAmerica)⇒∀ d In(d,Europe)⇒¬Borders(c,d)" is (1) correctly expressed.
- "e. No two adjacent countries have the same map color."
- "(i) ∀ x,y ¬Country(x)∨¬Country(y)∨¬Borders(x,y)∨¬(MapColor(x)=MapColor(y))" is (1) correctly expressed.
- "(ii) ∀ x,y (Country(x)∧Country(y)∧Borders(x,y)∧¬(x=y))⇒¬(MapColor(x)=MapColor(y))" is (1) correctly expressed but (i) is more simplified (better) since no country can border itself!
- "(iii) ∀ x, y Country(x)∧Country(y)∧Borders(x,y)∧¬(MapColor(x)=MapColor(y))" is (3), not expressing English meaning.
- "(iv) ∀ x,y (Country(x)∧Country(y)∧Borders(x,y))⇒MapColor(x=y)" is (2), is syntactically invalid because of the inequality's placement.
4. Writing Assertions in First-Order Logic
8.10 Consider a vocabulary with the following symbols:
Occupation(p,o): Predicate. Person p has occupation o.
Customer(p1,p2): Predicate. Person p1 is a customer of person p2.
Boss(p1,p2): Predicate. Person p1 is a boss of person p2.
Doctor,Surgeon,Lawyer,Actor: Constants denoting occupations. Emily,Joe: Constants denoting people.
Use these symbols to write the following assertions in first-order logic (Russell & Norvig, 2010):
- "a. Emily is either a surgeon or a lawyer."
- Occupation(Emily, Surgeon)∨Occupation(Emily, Lawyer)
- b. Joe is an actor, but he also holds another job."
- Occupation(Joe, Actor)∧∃ p p=Actor∧Occupation(Joe, p)
- "c. All surgeons are doctors."
- ∀ p Occupation(p, Surgeon)⇒Occupation(p, Doctor)
- "d. Joe does not have a lawyer (i.e., is not a customer of any lawyer)."
- ¬∃ p Customer(Joe, p)∧Occupation(p, Lawyer)
- "e. Emily has a boss who is a lawyer."
- ∃ p Boss(p, Emily)∧Occupation(p, Lawyer)
- "f. There exists a lawyer all of whose customers are doctors."
- ∃ p1 Occupation(p1, Lawyer)∧∀ p2 Customer(p2, p1)⇒Occupation(p2, Doctor)
- "g. Every surgeon has a lawyer."
- ∀ p1 Occupation(p1, Surgeon)⇒∃ p2 Occupation(p2, Lawyer)∧Customer(p1, p2)
References
- Russell, S., & Norvig, P. (2010). Artificial Intelligence: A Modern Approach (3rd ed.). Pearson Prentice Hall.