人工智能课 。做题存档点,自己做的,非标准答案。持续更新。
如果我有做的不对或不标准的地方,欢迎指出!(b( ̄▽ ̄)d)
匹配教材:《人工智能:复杂问题求解的结构和策略》
PS:有的童靴可能跟我一个专业,建议大家看的时候不要照抄,多想想,给我debug……
我有时候也是深受没有思路之苦,刚开始也完全没有头绪,那时候想如果有参考对象就好啦。因此我经常花费不少时间查资料,很烦人。
emmm本文就是个参考对象。。。希望大家节省时间,更有效率的学习。
人工智能课后题存档点(自娱向)(一)
人工智能课后题存档点(自娱向)(二)
第二部分: 作为表示和搜索的人工智能
第2章:谓词演算
2020年3月4日
一、
1、E = foo(X, a, goo(Y)) ,
s = { Z / X, moo(Z) / Y },
Es = ?
解:
2、Using predicate calculus to represent the following statement :
"All natural numbers are integers and greater than zero. "
(就是写所有自然数都是大于0的整数)
解:定义谓词如下:
N(x) :x是自然数
I(x) :x是整数
B(x) :x大于0
则可表示为:
(∀x) (N(x) ->(I(x)∧B(x)))
3、Compose the substitution sets { a/X, Y/Z } and { X/W, b/Y }
解:
4、Given two substitution sets as follows :
S1 = { f(W)/X, Z/Y }
S2 = { a/W, g(b)/Z }
Compose S1 and S2 .
解:
2020年3月7日
1、Attempt to unify the following pair of expressions. Either show their most general unifiers or explain why they will not unify :
p(X, a, Y). and p(Z, Z, b).
解:{Z/X,a/Z,b/Y}
2、Attempt to unify the following pair of expressions. Either show their most general unifiers or explain why they will not unify :
p(X, X) and p(a, b)
解:
they will not unify
a,b 均为常量且a≠b
3、Trace the unification algorithm on the following two expressions to obtain the most general unifier of E1 and E2 . ( Generating the search tree like figure 2.6 P.72 )
E1 = q(g(a), Z, Z)
E2 = q(Y, X, f(Y))
解:(错解:
这题做错了,X/Z要替换为(f(g a))/Z,我只是相加而没有复合,没做到最一般合一。
最后结果: { g(a)/Y, f(g(a))/Z, f(g(a))/X }
4、
Jane Doe has four dependents, a steady income of 30,000, and 15,000 in her savings account. Add the appropriate predicates describing her situation to the general investment advisor of the example in Section 2.4 and perform the unifications and inferences needed to determine her suggested investment.
Fill in the blanks to complete the following solution :
1. saving_account(inadequate) → investment( savings )
2. saving_account(adequate) ۸income(adequate) → investment( stocks )
3. saving_account(adequate) ۸income(inadequate) → investment( combination )
4. ∀X amount_saved(X) ۸∃Y(dependents(Y) ۸greater(X, minsavings(Y)))
→ saving_account( adequate )
5. ∀Xamount_saved(X) ۸∃Y(dependents(Y) ۸¬greater(X, minsavings(Y)))
→ saving_account( inadequate )
6. ∀X earnings(X, steady) ۸∃Y(dependents(Y) ۸greater(X, minincome(Y)))
→ income( adequate )
7. ∀X earnings(X, steady) ۸∃Y(dependents(Y) ۸¬greater(X, minincome(Y)))
→ income( inadequate )
8. ∀X earnings(X, unsteady) → income( inadequate )
9. amount_saved( 15000 )
10. earnings( 30000 , steady )
11. dependents( 4 )
Where: minsavings(X) ≡ 5000*X
minincome(X) ≡ 15000 + 4000*X
Ø step 1
The first two elements of the premises of the implication 5 :
amount_saved(X) ۸ dependents(Y)
unifies with the facts :
amount_saved(15000) ۸ dependents(4)
under the substitution { 15000 / X , 4 / Y }
yielding the implication 5’ :
amount_saved( 15000 ) ۸ dependents( 4 )
۸¬greater( 15000, minsavings( 4 ) ) )
→ saving_account( inadequate )
Where minsavings( 4 ) = 5000*4 = 20000
Using modus ponens, we get :
12. saving_account( inadequate )
Ø Step 2
The first two elements of the premises of the implication 7 :
earnings(X, steady) ۸(dependents(Y)
unifies with the facts :
earnings(30000,steady)۸ dependents(4)
under the substitution { 30000/X , 4/Y },
this yeilds a new implication 7’ :
earnings( 30000 , steady ) ۸ dependents( 4 )
۸¬greater( 30000 , minincome( 4 ))
→ income( inadequate )
Where minincome(4) = 15000+4000*4=31000
Using modus ponens, we get :
13. income(inadequate)
Ø Step 3
From 1, 12, we can get the following conclusion:
14. investment(saving)
(所以存款不够了还考虑工资干嘛……wtf?)
第3章:状态空间搜索的结构和策略
2020年3月10日
1、
Give the graph representation for the farmer, wolf, goat, and cabbage problem .
(假设从东岸到西岸,说明每个状态的表示方法,给出所有合法状态以及它们之间的转换关系图,即状态空间图。)
(就是经典的农夫、狼、羊、菜 过河问题)
解:(一开始还以为是谓词演算的问题……卡了好久)
2、
“Hand run” the backtrack algorithm on the graph in Figure 3.29. Begin from state A. Keep track of the successive values of NSL, SL, CS, etc.
Assume that G is the goal state .
解:(少加了一个E,出栈才是结束条件
正解:
CS SL NSL DE
0 A [A] [A] [ ]
1 B [BA] [BCDA] [ ]
2 E [EBA] [EFGBCDA] [ ]
3 J [JEBA] [JKLEFGBCDA] [ ]
4 K [KEBA] [KLEFGBCDA] [ J ]
5 L [LEBA] [LEFGBCDA] [ KJ ]
6 E [EBA] [EFGBCDA] [ LKJ ]
7 F [FBA] [FGBCDA] [ EL KJ ]
8 G [GBA] [GBCDA] [ FELKJ ]
9 CS=goal, return SL
3、
“Hand run” the depth_first_search algorithm on the graph in Figure 3.29. Begin from state A. Keep track of the successive values of open and closed.
Assume that G is the goal state .
正解:
1. open=[A]; closed=[ ]
2. open=[B,C,D]; closed=[A]
3. open=[E,F,G,C,D]; closed=[B,A]
4. open=[J,K,L,F,G,C,D]; closed=[E,B,A]
5. open=[K,L,F,G,C,D]; closed=[J,E,B,A]
6. open=[L,F,G,C,D]; closed=[K,J,E,B,A]
7. open=[F,G,C,D]; closed=[L,K,J,E,B,A]
8. open=[G,C,D]; closed=[F,L,K,J,E,B,A]
9. 找到目标,return success