princevalentino
Dec 10, 2011, 06:33 PM
1.
A. Using the predicates provided below, translate the following formulae of predicate logic into English:
L6CMS(x): x is a student at Level 6 in CMS.
BelowC(x): x's English grade is below C.
Study(x, y): x studies why.
Know(x, y): x knows why.
(I) x(L6CMS(x) Know(x, JixinMa) ® Study(x, AI))
(ii) xy(L6CMS(x) BelowC(x) ® Study(x, Extra-English))
(iii) xy(L6CMS(x) ¬BelowC(x) Study(x, Extra-English))
(iv) x((L6CMS(x) Study(x, AI)) ® ¬y(L6CMS(y) BelowC(x) ¬Know(x, y))
(v) xyz(¬(x = y) ¬(x = z) ¬(y = z) L6CMS(x) L6CMS(y) L6CMS(z)
Know(x, Jixin) Know(y, Jixin) Know(z, Jixin))
B. Using the same predicates provided above in question a, translate the following English sentences into formulae of predicate logic:
(I) No CMS students at Level 6 studies Chinese.
(ii) All CMS students at Level 6 study at least three courses.
(iii) Jixin Ma knows all those CMS students at Level 6 who study AI.
(iv) Some CMS students at Level 6 do not study Extra-English.
(v) There are at least two CMS students at Level 6 study both AI and extra-English.
2.
A. Let the world of discourse be the set of integers. “Translate” each of the following expressions into English, state whether they are true or false, and give your justifications for each of them:
• nm(n = m n > m n < m)
• n(n = 8 n < 8 n > 8)
• nm(n m = 8)
• nm(n * m = 8)
• nm( n m = 8)
B. Use truth table to verify the following equivalence:
(I) ~(A ® B) A B
(ii) ~(A B A C) (A B) (A C)
3.
Use your own words, explain your understanding of the actual meaning of “A materially implies B”, that is, A B, in propositional logic. Use your own example to show the difference between the use of A B in propositional logic and the use of “If A then B” in instructions or commands.
4.
Use natural deduction to prove:
A B C ╞ C B A
5.
Suppose we have the following parent database in prolog:
Parent(tom, harry).
Parent(mary, harry).
Parent(steve, emma).
Parent(helen, emma).
Parent(harry, ed).
Parent(harry, roger).
Parent(emma, ed).
A. Write a query to find Tom's children who have children of their own, and their children's names (Hint: use letter variables such as X and Y).
B. Write a query to find Tom's children who have children of their own, but without listing their children's names (Hint: use both letter variable and anonymous variable “_”).
C. Is the following query:
?- parent(mary, _), parent(_, _).
The same as the query:
?- parent(mary, X), parent(X, _).
Justify your answer.
D. Write a query to which the query:
?- parent(mary, _), parent(_, _).
Is equivalent.
6.
Unify each of the following pairs where possible and give the unifying substitutions. In the case where unification is impossible, justify your answer.
A. [tom, liz, sandy] = [H | T]
B. [ [tom, liz], sandy] = [H | T]
C. [ [tom, liz, X], sandy] = [H | [X]]
D. [ [tom, liz | X], why, sandy] = [H | X]
E. [ [tom], [liz,sandy] ] = [ X , why | Z]
7.
Consider the following list-membership program:
MemberCheck(X,[X|_]).
MemberCheck(X,[_|T]) :- memberCheck(X,T).
A. What happens with the following queries?
?- memberCheck(1, X).
?- memberCheck(X, Y).
B. Prolog is not a typed language, e.g. The following queries perhaps should give type errors, but they don't:
?- memberCheck(a, [a|b]).
True (Yes)
?- memberCheck(b, [a|b]).
False (No)
How does Prolog come to the above two conclusions?
C. Suppose we define a predicate “list”, where list(X) would be true if X is a list.
List([]).
List([X|T]) :- list(T).
How could we then make the memberCheck predicate more type safe? Write a revised type safer program memberCheck2 for list-membership checking, which will make the queries in b. Behave as expected, that is:
?- memberCheck(a, [a|b]).
False (No)
?- memberCheck(b, [a|b]).
False (No)
A. Using the predicates provided below, translate the following formulae of predicate logic into English:
L6CMS(x): x is a student at Level 6 in CMS.
BelowC(x): x's English grade is below C.
Study(x, y): x studies why.
Know(x, y): x knows why.
(I) x(L6CMS(x) Know(x, JixinMa) ® Study(x, AI))
(ii) xy(L6CMS(x) BelowC(x) ® Study(x, Extra-English))
(iii) xy(L6CMS(x) ¬BelowC(x) Study(x, Extra-English))
(iv) x((L6CMS(x) Study(x, AI)) ® ¬y(L6CMS(y) BelowC(x) ¬Know(x, y))
(v) xyz(¬(x = y) ¬(x = z) ¬(y = z) L6CMS(x) L6CMS(y) L6CMS(z)
Know(x, Jixin) Know(y, Jixin) Know(z, Jixin))
B. Using the same predicates provided above in question a, translate the following English sentences into formulae of predicate logic:
(I) No CMS students at Level 6 studies Chinese.
(ii) All CMS students at Level 6 study at least three courses.
(iii) Jixin Ma knows all those CMS students at Level 6 who study AI.
(iv) Some CMS students at Level 6 do not study Extra-English.
(v) There are at least two CMS students at Level 6 study both AI and extra-English.
2.
A. Let the world of discourse be the set of integers. “Translate” each of the following expressions into English, state whether they are true or false, and give your justifications for each of them:
• nm(n = m n > m n < m)
• n(n = 8 n < 8 n > 8)
• nm(n m = 8)
• nm(n * m = 8)
• nm( n m = 8)
B. Use truth table to verify the following equivalence:
(I) ~(A ® B) A B
(ii) ~(A B A C) (A B) (A C)
3.
Use your own words, explain your understanding of the actual meaning of “A materially implies B”, that is, A B, in propositional logic. Use your own example to show the difference between the use of A B in propositional logic and the use of “If A then B” in instructions or commands.
4.
Use natural deduction to prove:
A B C ╞ C B A
5.
Suppose we have the following parent database in prolog:
Parent(tom, harry).
Parent(mary, harry).
Parent(steve, emma).
Parent(helen, emma).
Parent(harry, ed).
Parent(harry, roger).
Parent(emma, ed).
A. Write a query to find Tom's children who have children of their own, and their children's names (Hint: use letter variables such as X and Y).
B. Write a query to find Tom's children who have children of their own, but without listing their children's names (Hint: use both letter variable and anonymous variable “_”).
C. Is the following query:
?- parent(mary, _), parent(_, _).
The same as the query:
?- parent(mary, X), parent(X, _).
Justify your answer.
D. Write a query to which the query:
?- parent(mary, _), parent(_, _).
Is equivalent.
6.
Unify each of the following pairs where possible and give the unifying substitutions. In the case where unification is impossible, justify your answer.
A. [tom, liz, sandy] = [H | T]
B. [ [tom, liz], sandy] = [H | T]
C. [ [tom, liz, X], sandy] = [H | [X]]
D. [ [tom, liz | X], why, sandy] = [H | X]
E. [ [tom], [liz,sandy] ] = [ X , why | Z]
7.
Consider the following list-membership program:
MemberCheck(X,[X|_]).
MemberCheck(X,[_|T]) :- memberCheck(X,T).
A. What happens with the following queries?
?- memberCheck(1, X).
?- memberCheck(X, Y).
B. Prolog is not a typed language, e.g. The following queries perhaps should give type errors, but they don't:
?- memberCheck(a, [a|b]).
True (Yes)
?- memberCheck(b, [a|b]).
False (No)
How does Prolog come to the above two conclusions?
C. Suppose we define a predicate “list”, where list(X) would be true if X is a list.
List([]).
List([X|T]) :- list(T).
How could we then make the memberCheck predicate more type safe? Write a revised type safer program memberCheck2 for list-membership checking, which will make the queries in b. Behave as expected, that is:
?- memberCheck(a, [a|b]).
False (No)
?- memberCheck(b, [a|b]).
False (No)