Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 1 out of 2 pages
Exam (elaborations)

Department of Computer Science Midterm Examination 2 Computer Science 312 Functional and Logic Programming

Document preview thumbnail
Preview 1 out of 2 pages

Question 1 [12 marks] Department of Computer Science Midterm Examination 2 Computer Science 312 Functional and Logic Programming (a) [4 marks] In the semantic web, a URI is a “Uniform Resource Identifier”. What is a URI? Why are URIs useful? (b) [4 marks] Explain what “Triples are universal representations of relations” means, and why it is true. (c) [4 marks] Suppose you are told the triples using prop(Subject, Verb, Object): prop(bread,’rdfs:domain’,’ This entails that: i) p123 is a ii) b764 is a Question 2 [10 marks] (a) [3 marks] Give Clark’s completion (using explicit quantification) of del1(E, [E|R], R). del1(E, [H|T], [H|R]) :- del1(E,T,R). (b) [5 marks] Given the logic program: del1(E, [E|R], R). del1(E, [H|T], [H|R]) :- del1(E,T,R). Give a proof for the first answer that Prolog finds for the query: ?- del1(a(X),[b(c),e(f),a(d),a(c)],Y). You need to show the answer clause and an appropriately renamed cause to resolve against, but you do not need to show substitutions. (c) [2 marks] What is the first answer that Prolog gives for this query? Question 3 [10 marks] (a) [6 marks] Define the relation shuffle(L1, L2, L3) that is true if L3 is an interleaving of the elements of S1 and S2 (i.e., some elements of one, followed by some elements of the other, followed by some elements of the first, etc. The orders of elements in S1 and S2 should be preserved). For example, it should work as follows: ?- shuffle([a,b],[1,2],S). S = [a, b, 1, 2] ; S = [a, 1, b, 2] ; S = [a, 1, 2, b] ; S = [1, a, b, 2] ; S = [1, a, 2, b] ; S = [1, 2, a, b] ; false. ?- shuffle([a,b,c],[],S). S = [a, b, c] ; false. (b) [4 marks] What are all of the answers to the following query? (You should be able to answer this even if you cannot answer part (a)). ? shuffle([a,e],L,[a,v,e,r,a,g,e]). Question 4 [10 marks] (a) [6 marks] For each the following pairs of terms, either give their most general unifier or say why no most general unifier exists. i) [3 marks] p(f (h(X, d)), h(X, Y), Y) and p(f (Z), Z, c). ii) [3 marks] k([u, n, f , u, n], R) and k([u, n|Z], [n, o|Z]). (b) [4 marks] Consider the code: noun_phrase(T1,T3,Obj,C1,C3) :- adjectives(T1,T2,Obj,C1,C2), noun(T2,T3,Obj,C2,C3). adjectives(T,T,_,C,C). adjectives(T0,T2,Obj,C0,C2) :- adj(T0,T1,Obj,C0,C1), adjectives(T1,T2,Obj,C1,C2). adj([Lang,speaking | T],T,Obj,C,[language(Obj,Lang)|C]). noun([country | T],T,Obj,C,[country(Obj)|C]). What is the answer to the query: ?- noun_phrase([french,speaking,country,borders,a, spanish, speaking, country],L,Ind,[large(Ind)],R).


Document information

Uploaded on
December 5, 2022
Number of pages
2
Written in
2022/2023
Type
Exam (elaborations)
Contains
Questions & answers
$8.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
SmartMind
3.5
(22)
Sold
110
Followers
112
Items
1680
Last sold
1 year ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions

Whoops! We can’t load your doc right now. Try again or contact support.