Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed all duplicate exercises in Chapter 7 #922

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions markdown/7-Logical-Agents/exercises/ex_10/question.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@


We have defined four binary logical connectives.<br>

1. Are there any others that might be useful?<br>

2. How many binary connectives can there be?<br>

3. Why are some of them not very useful?<br>
Using a method of your choice, verify
each of the equivalences in
Table <a class="insideBookFigRef" target="_blank" href="https://aimacode.github.io/aima-exercises/figures/logical-equivalence-table.png">logical-equivalence-table</a> (page <a class="pageRef" title="" href="#">logical-equivalence-table</a>).
20 changes: 18 additions & 2 deletions markdown/7-Logical-Agents/exercises/ex_11/question.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@


Using a method of your choice, verify
each of the equivalences in
Decide whether each of the following
sentences is valid, unsatisfiable, or neither. Verify your decisions
using truth tables or the equivalence rules of
Table <a class="insideBookFigRef" target="_blank" href="https://aimacode.github.io/aima-exercises/figures/logical-equivalence-table.png">logical-equivalence-table</a> (page <a class="pageRef" title="" href="#">logical-equivalence-table</a>).

1. ${Smoke} {\:\;{\Rightarrow}\:\;}{Smoke}$<br>

2. ${Smoke} {\:\;{\Rightarrow}\:\;}{Fire}$<br>

3. $({Smoke} {\:\;{\Rightarrow}\:\;}{Fire}) {\:\;{\Rightarrow}\:\;}(\lnot {Smoke} {\:\;{\Rightarrow}\:\;}\lnot {Fire})$<br>

4. ${Smoke} \lor {Fire} \lor \lnot {Fire}$<br>

5. $(({Smoke} \land {Heat}) {\:\;{\Rightarrow}\:\;}{Fire})
{\;\;{\Leftrightarrow}\;\;}(({Smoke} {\:\;{\Rightarrow}\:\;}{Fire}) \lor ({Heat} {\:\;{\Rightarrow}\:\;}{Fire}))$<br>

6. $({Smoke} {\:\;{\Rightarrow}\:\;}{Fire}) {\:\;{\Rightarrow}\:\;}(({Smoke} \land {Heat}) {\:\;{\Rightarrow}\:\;}{Fire}) $<br>

7. ${Big} \lor {Dumb} \lor ({Big} {\:\;{\Rightarrow}\:\;}{Dumb})$<br>
23 changes: 4 additions & 19 deletions markdown/7-Logical-Agents/exercises/ex_12/question.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@


Decide whether each of the following
sentences is valid, unsatisfiable, or neither. Verify your decisions
using truth tables or the equivalence rules of
Table <a class="insideBookFigRef" target="_blank" href="https://aimacode.github.io/aima-exercises/figures/logical-equivalence-table.png">logical-equivalence-table</a> (page <a class="pageRef" title="" href="#">logical-equivalence-table</a>).

1. ${Smoke} {\:\;{\Rightarrow}\:\;}{Smoke}$<br>

2. ${Smoke} {\:\;{\Rightarrow}\:\;}{Fire}$<br>

3. $({Smoke} {\:\;{\Rightarrow}\:\;}{Fire}) {\:\;{\Rightarrow}\:\;}(\lnot {Smoke} {\:\;{\Rightarrow}\:\;}\lnot {Fire})$<br>

4. ${Smoke} \lor {Fire} \lor \lnot {Fire}$<br>

5. $(({Smoke} \land {Heat}) {\:\;{\Rightarrow}\:\;}{Fire})
{\;\;{\Leftrightarrow}\;\;}(({Smoke} {\:\;{\Rightarrow}\:\;}{Fire}) \lor ({Heat} {\:\;{\Rightarrow}\:\;}{Fire}))$<br>

6. $({Smoke} {\:\;{\Rightarrow}\:\;}{Fire}) {\:\;{\Rightarrow}\:\;}(({Smoke} \land {Heat}) {\:\;{\Rightarrow}\:\;}{Fire}) $<br>

7. ${Big} \lor {Dumb} \lor ({Big} {\:\;{\Rightarrow}\:\;}{Dumb})$<br>
Any propositional logic sentence is logically
equivalent to the assertion that each possible world in which it would
be false is not the case. From this observation, prove that any sentence
can be written in CNF.
21 changes: 2 additions & 19 deletions markdown/7-Logical-Agents/exercises/ex_13/question.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@


Decide whether each of the following
sentences is valid, unsatisfiable, or neither. Verify your decisions
using truth tables or the equivalence rules of
Table <a class="insideBookFigRef" target="_blank" href="https://aimacode.github.io/aima-exercises/figures/logical-equivalence-table.png">logical-equivalence-table</a> (page <a class="pageRef" title="" href="#">logical-equivalence-table</a>).<br>

1. ${Smoke} {\:\;{\Rightarrow}\:\;}{Smoke}$<br>

2. ${Smoke} {\:\;{\Rightarrow}\:\;}{Fire}$<br>

3. $({Smoke} {\:\;{\Rightarrow}\:\;}{Fire}) {\:\;{\Rightarrow}\:\;}(\lnot {Smoke} {\:\;{\Rightarrow}\:\;}\lnot {Fire})$<br>

4. ${Smoke} \lor {Fire} \lor \lnot {Fire}$<br>

5. $(({Smoke} \land {Heat}) {\:\;{\Rightarrow}\:\;}{Fire})
{\;\;{\Leftrightarrow}\;\;}(({Smoke} {\:\;{\Rightarrow}\:\;}{Fire}) \lor ({Heat} {\:\;{\Rightarrow}\:\;}{Fire}))$<br>

6. ${Big} \lor {Dumb} \lor ({Big} {\:\;{\Rightarrow}\:\;}{Dumb})$<br>

7. $({Big} \land {Dumb}) \lor \lnot {Dumb}$<br>
Use resolution to prove the sentence $\lnot A \land \lnot B$ from the
clauses in Exercise <a class="exerciseRef" href="{{ site.baseurl }}/knowledge-logic-exercises/ex_25/">convert-clausal-exercise</a>.
20 changes: 16 additions & 4 deletions markdown/7-Logical-Agents/exercises/ex_14/question.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@


Any propositional logic sentence is logically
equivalent to the assertion that each possible world in which it would
be false is not the case. From this observation, prove that any sentence
can be written in CNF.
This exercise looks into the relationship between
clauses and implication sentences.<br>

1. Show that the clause $(\lnot P_1 \lor \cdots \lor \lnot P_m \lor Q)$
is logically equivalent to the implication sentence
$(P_1 \land \cdots \land P_m) {\;{\Rightarrow}\;}Q$.<br>

2. Show that every clause (regardless of the number of
positive literals) can be written in the form
$(P_1 \land \cdots \land P_m) {\;{\Rightarrow}\;}(Q_1 \lor \cdots \lor Q_n)$,
where the $P$s and $Q$s are proposition symbols. A knowledge base
consisting of such sentences is in implicative normal form or <b>Kowalski
form</b> <a class="paperRef" title="" href="">Kowalski:1979</a>.<br>

3. Write down the full resolution rule for sentences in implicative
normal form.<br>
15 changes: 13 additions & 2 deletions markdown/7-Logical-Agents/exercises/ex_15/question.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@

According to some political pundits, a person who is radical ($R$) is
electable ($E$) if he/she is conservative ($C$), but otherwise is not
electable.<br>

Use resolution to prove the sentence $\lnot A \land \lnot B$ from the
clauses in Exercise <a class="exerciseRef" href="{{ site.baseurl }}/knowledge-logic-exercises/ex_25/">convert-clausal-exercise</a>.
1. Which of the following are correct representations of this
assertion?<br>

1. $(R\land E)\iff C$<br>

2. $R{\:\;{\Rightarrow}\:\;}(E\iff C)$<br>

3. $R{\:\;{\Rightarrow}\:\;}((C{\:\;{\Rightarrow}\:\;}E) \lor \lnot E)$<br>

2. Which of the sentences in (a) can be expressed in Horn form?
2 changes: 1 addition & 1 deletion markdown/7-Logical-Agents/exercises/ex_16/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ layout: exercise
title: Exercise 7.16
permalink: /knowledge-logic-exercises/ex_16/
breadcrumb: 7-Logical-Agents
canonical_id: ch7ex16
home: "true"
canonical_id: ch7ex16
---

{% include mathjax_support %}
Expand Down
34 changes: 21 additions & 13 deletions markdown/7-Logical-Agents/exercises/ex_16/question.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@


This exercise looks into the relationship between
clauses and implication sentences.<br>
This question considers representing satisfiability (SAT) problems as
CSPs.<br>

1. Show that the clause $(\lnot P_1 \lor \cdots \lor \lnot P_m \lor Q)$
is logically equivalent to the implication sentence
$(P_1 \land \cdots \land P_m) {\;{\Rightarrow}\;}Q$.<br>
1. Draw the constraint graph corresponding to the SAT problem
$$(\lnot X_1 \lor X_2) \land (\lnot X_2 \lor X_3) \land \ldots \land (\lnot X_{n-1} \lor X_n)$$
for the particular case $n{{\,=\,}}5$.<br>

2. Show that every clause (regardless of the number of
positive literals) can be written in the form
$(P_1 \land \cdots \land P_m) {\;{\Rightarrow}\;}(Q_1 \lor \cdots \lor Q_n)$,
where the $P$s and $Q$s are proposition symbols. A knowledge base
consisting of such sentences is in implicative normal form or <b>Kowalski
form</b> <a class="paperRef" title="" href="">Kowalski:1979</a>.<br>
2. How many solutions are there for this general SAT problem as a
function of $n$?<br>

3. Write down the full resolution rule for sentences in implicative
normal form.<br>
3. Suppose we apply {Backtracking-Search} (page <a class="pageRef" title="" href="#">backtracking-search-algorithm</a>) to find <i>all</i>
solutions to a SAT CSP of the type given in (a). (To find
<i>all</i> solutions to a CSP, we simply modify the basic
algorithm so it continues searching after each solution is found.)
Assume that variables are ordered $X_1,\ldots,X_n$ and ${false}$
is ordered before ${true}$. How much time will the algorithm take
to terminate? (Write an $O(\cdot)$ expression as a function of $n$.)<br>

4. We know that SAT problems in Horn form can be solved in linear time
by forward chaining (unit propagation). We also know that every
tree-structured binary CSP with discrete, finite domains can be
solved in time linear in the number of variables
(Section <a class="sectionRef" title="" href="#">csp-structure-section</a>). Are these two
facts connected? Discuss.<br>
18 changes: 5 additions & 13 deletions markdown/7-Logical-Agents/exercises/ex_17/question.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@

According to some political pundits, a person who is radical ($R$) is
electable ($E$) if he/she is conservative ($C$), but otherwise is not
electable.<br>

1. Which of the following are correct representations of this
assertion?<br>

1. $(R\land E)\iff C$<br>

2. $R{\:\;{\Rightarrow}\:\;}(E\iff C)$<br>

3. $R{\:\;{\Rightarrow}\:\;}((C{\:\;{\Rightarrow}\:\;}E) \lor \lnot E)$<br>

2. Which of the sentences in (a) can be expressed in Horn form?
Explain why every nonempty propositional clause, by itself, is
satisfiable. Prove rigorously that every set of five 3-SAT clauses is
satisfiable, provided that each clause mentions exactly three distinct
variables. What is the smallest set of such clauses that is
unsatisfiable? Construct such a set.
5 changes: 2 additions & 3 deletions markdown/7-Logical-Agents/exercises/ex_18/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ layout: exercise
title: Exercise 7.18
permalink: /knowledge-logic-exercises/ex_18/
breadcrumb: 7-Logical-Agents
home: "true"
canonical_id: ch7ex18
home: "true"
---

{% include mathjax_support %}
<div id="hiddden">{% include_relative question.md %}</div>


<div id="hiddden">{% include_relative question.md %}</div>
32 changes: 12 additions & 20 deletions markdown/7-Logical-Agents/exercises/ex_18/question.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@


This question considers representing satisfiability (SAT) problems as
CSPs.<br>
A propositional <i>2-CNF</i> expression is a conjunction of
clauses, each containing <i>exactly 2</i> literals, e.g.,
$$(A\lor B) \land (\lnot A \lor C) \land (\lnot B \lor D) \land (\lnot
C \lor G) \land (\lnot D \lor G)\ .$$<br>

1. Draw the constraint graph corresponding to the SAT problem
$$(\lnot X_1 \lor X_2) \land (\lnot X_2 \lor X_3) \land \ldots \land (\lnot X_{n-1} \lor X_n)$$
for the particular case $n{{\,=\,}}5$.<br>
1. Prove using resolution that the above sentence entails $G$.<br>

2. How many solutions are there for this general SAT problem as a
function of $n$?<br>
2. Two clauses are <i>semantically distinct</i> if they are not
logically equivalent. How many semantically distinct 2-CNF clauses
can be constructed from $n$ proposition symbols?<br>

3. Suppose we apply {Backtracking-Search} (page <a class="pageRef" title="" href="#">backtracking-search-algorithm</a>) to find <i>all</i>
solutions to a SAT CSP of the type given in (a). (To find
<i>all</i> solutions to a CSP, we simply modify the basic
algorithm so it continues searching after each solution is found.)
Assume that variables are ordered $X_1,\ldots,X_n$ and ${false}$
is ordered before ${true}$. How much time will the algorithm take
to terminate? (Write an $O(\cdot)$ expression as a function of $n$.)<br>
3. Using your answer to (b), prove that propositional resolution always
terminates in time polynomial in $n$ given a 2-CNF sentence
containing no more than $n$ distinct symbols.<br>

4. We know that SAT problems in Horn form can be solved in linear time
by forward chaining (unit propagation). We also know that every
tree-structured binary CSP with discrete, finite domains can be
solved in time linear in the number of variables
(Section <a class="sectionRef" title="" href="#">csp-structure-section</a>). Are these two
facts connected? Discuss.<br>
4. Explain why your argument in (c) does not apply to 3-CNF.<br>
3 changes: 1 addition & 2 deletions markdown/7-Logical-Agents/exercises/ex_19/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ home: "true"

{% include mathjax_support %}


<div id="hiddden">{% include_relative question.md %}</div>
<div id="hiddden">{% include_relative question.md %}</div>
28 changes: 7 additions & 21 deletions markdown/7-Logical-Agents/exercises/ex_19/question.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@


This question considers representing satisfiability (SAT) problems as
CSPs.<br>
Prove each of the following assertions:<br>

1. Draw the constraint graph corresponding to the SAT problem
$$(\lnot X_1 \lor X_2) \land (\lnot X_2 \lor X_3) \land \ldots \land (\lnot X_{n-1} \lor X_n)$$
for the particular case $n{{\,=\,}}4$.<br>
1. Every pair of propositional clauses either has no resolvents, or all
their resolvents are logically equivalent.<br>

2. How many solutions are there for this general SAT problem as a
function of $n$?<br>
2. There is no clause that, when resolved with itself, yields
(after factoring) the clause $(\lnot P \lor \lnot Q)$.<br>

3. Suppose we apply {Backtracking-Search} (page <a class="pageRef" title="" href="#">backtracking-search-algorithm</a>) to find <i>all</i>
solutions to a SAT CSP of the type given in (a). (To find
<i>all</i> solutions to a CSP, we simply modify the basic
algorithm so it continues searching after each solution is found.)
Assume that variables are ordered $X_1,\ldots,X_n$ and ${false}$
is ordered before ${true}$. How much time will the algorithm take
to terminate? (Write an $O(\cdot)$ expression as a function of $n$.)<br>

4. We know that SAT problems in Horn form can be solved in linear time
by forward chaining (unit propagation). We also know that every
tree-structured binary CSP with discrete, finite domains can be
solved in time linear in the number of variables
(Section <a class="sectionRef" title="" href="#">csp-structure-section</a>). Are these two
facts connected? Discuss.
3. If a propositional clause $C$ can be resolved with a copy of itself,
it must be logically equivalent to $ True $.<br>
5 changes: 2 additions & 3 deletions markdown/7-Logical-Agents/exercises/ex_20/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ layout: exercise
title: Exercise 7.20
permalink: /knowledge-logic-exercises/ex_20/
breadcrumb: 7-Logical-Agents
canonical_id: ch7ex20
home: "true"
canonical_id: ch7ex20
---

{% include mathjax_support %}


<div id="hiddden">{% include_relative question.md %}</div>
<div id="hiddden">{% include_relative question.md %}</div>
16 changes: 11 additions & 5 deletions markdown/7-Logical-Agents/exercises/ex_20/question.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@


Explain why every nonempty propositional clause, by itself, is
satisfiable. Prove rigorously that every set of five 3-SAT clauses is
satisfiable, provided that each clause mentions exactly three distinct
variables. What is the smallest set of such clauses that is
unsatisfiable? Construct such a set.
Consider the following sentence:<br>
$$[ ({Food} {\:\;{\Rightarrow}\:\;}{Party}) \lor ({Drinks} {\:\;{\Rightarrow}\:\;}{Party}) ] {\:\;{\Rightarrow}\:\;}[ ( {Food} \land {Drinks} ) {\:\;{\Rightarrow}\:\;}{Party}]\ .$$<br>

1. Determine, using enumeration, whether this sentence is valid,
satisfiable (but not valid), or unsatisfiable.<br>

2. Convert the left-hand and right-hand sides of the main implication
into CNF, showing each step, and explain how the results confirm
your answer to (a).<br>

3. Prove your answer to (a) using resolution.
5 changes: 3 additions & 2 deletions markdown/7-Logical-Agents/exercises/ex_21/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ layout: exercise
title: Exercise 7.21
permalink: /knowledge-logic-exercises/ex_21/
breadcrumb: 7-Logical-Agents
canonical_id: ch7ex21
home: "true"
canonical_id: ch7ex21
---

{% include mathjax_support %}
<div id="hiddden">{% include_relative question.md %}</div>


<div id="hiddden">{% include_relative question.md %}</div>
40 changes: 28 additions & 12 deletions markdown/7-Logical-Agents/exercises/ex_21/question.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@


A propositional <i>2-CNF</i> expression is a conjunction of
clauses, each containing <i>exactly 2</i> literals, e.g.,
$$(A\lor B) \land (\lnot A \lor C) \land (\lnot B \lor D) \land (\lnot
C \lor G) \land (\lnot D \lor G)\ .$$<br>
A sentence is in disjunctive normal form(DNF) if it is the disjunction of
conjunctions of literals. For example, the sentence
$(A \land B \land \lnot C) \lor (\lnot A \land C) \lor (B \land \lnot C)$
is in DNF.<br>

1. Prove using resolution that the above sentence entails $G$.<br>
1. Any propositional logic sentence is logically equivalent to the
assertion that some possible world in which it would be true is in
fact the case. From this observation, prove that any sentence can be
written in DNF.<br>

2. Two clauses are <i>semantically distinct</i> if they are not
logically equivalent. How many semantically distinct 2-CNF clauses
can be constructed from $n$ proposition symbols?<br>
2. Construct an algorithm that converts any sentence in propositional
logic into DNF. (<i>Hint</i>: The algorithm is similar to
the algorithm for conversion to CNF iven in
Sectio <a class="sectionRef" title="" href="#">pl-resolution-section</a>.)<br>

3. Using your answer to (b), prove that propositional resolution always
terminates in time polynomial in $n$ given a 2-CNF sentence
containing no more than $n$ distinct symbols.<br>
3. Construct a simple algorithm that takes as input a sentence in DNF
and returns a satisfying assignment if one exists, or reports that
no satisfying assignment exists.<br>

4. Explain why your argument in (c) does not apply to 3-CNF.<br>
4. Apply the algorithms in (b) and (c) to the following set of
sentences:<br>

$A {\Rightarrow} B$<bR>

$B {\Rightarrow} C$<br>

$C {\Rightarrow} A$<br>

5. Since the algorithm in (b) is very similar to the algorithm for
conversion to CNF, and since the algorithm in (c) is much simpler
than any algorithm for solving a set of sentences in CNF, why is
this technique not used in automated reasoning?
Loading