Length: 1h40min (100min).
This cps721 midterm test will be available from D2L on Friday, October 29, 2021, between 4pm and 6pm. Make sure you connect to a cps721 course shell on D2L a few minutes before 4pm, and go to Assessment/Quizzes section. Find the General Exam Related Rules at the bottom of this file. Note this is a closed book exam, and you cannot use any aids. You need the following.
· Computer: A computer running Windows (10, 8, 7) or Mac (OS X 10.10 or higher).
· Web browser: Ensure that you are using the latest version of either Google Chrome or Mozilla Firefox. Other web browsers are not recommended.
Copyright By PowCoder代写 加微信 powcoder
· A pencil, eraser, a pen, paper to write: you may need them to solve some of the questions. Once you have solved a problem, you have to type a few words or numbers into text fields. You do not need calculators.
· Make sure you have a stable Internet connection: wired connection is better than wireless. If your Internet connection breaks for more than 5min, or more than once, then you will have to take a makeup exam and/or an oral exam as mentioned in the CMF. In any case, you will not be given any extra time, if you lost a few minutes during the exam due to poor Internet connection.
The duration of the midterm test is 100min. You can expect questions similar to quizzes, assignments and similar to exercises that were discussed (or mentioned) in class. Also, practice to solve yourself all questions from quizzes. If you worked with partners to solve exercises from homework, read your partner’s solutions and ask your partner to explain them to you. In addition, you can download sample midterm tests from my.ryerson.ca – follow cps721 link, see the folder “Course Documents”. It is strongly recommended to review a few Prolog library predicates such as member(X,List), append(L1,L2,L3).
· Formulate queries in Prolog using a few given predicates (as in A1, Part 1). The queries are conjunctions of predicates that can be negated. Negation can be applied not only to a single predicate, but to a conjunction of predicates as well, e.g.,
· ?- predicate1(X), not ( predicate1(Y), predicate2(Y), X > Y ).
The latter is a common query pattern in Prolog that allows to retrieve from the data base an element characterized by super-lative adjectives such as the oldest, the largest, the cheapest, and so on.
· Back-chaining procedure (how it works, when we need “fresh” variables and how to do backtracking). Write an evaluation tree (mention every step), including backtracking, that corresponds to Prolog’s evaluation of a query. Read your notes and similar questions in the slides posted on D2L. Practice a lot: trace the back-chaining procedure yourself on simple examples from the posted notes (download PDF files from my.ryerson.ca ), and then compare your back-chaining tree with the evaluation trees in the notes. You can also practice with the following queries:
? – length([a,b,c,d],N).
? – sum([1,10,100],S).
? – member(r, [q,p,r]).
· Lists (A2, Part 1). State which pairs of lists can be made identical, and which cannot. You have to write a brief proof to get all marks for this question: show transformations from one list to another or argue why lists do not match. Do not skip any steps. Note it is wrong to guess values. You get marks mostly for correct transformations. You get no credit for wrong answers or for missing, or incorrect transformations.
· Recursive programs, recursion over lists (as in A2, Part2 and Part4), recursion and simple arithmetics; read all posted handouts. How to write recursive programs by doing case analysis: read the handout on D2L. You are expected to know how to write programs for predicates “append(L1,L2,L3)” and “member(Element,List)”. If you use them in your solution, write programs for these helping predicates. However, the actual test questions about recursion may not require using “append” and “member”, and it is possible that programs must be developed without these predicates. E.g., we can easily write recursive programs for “length(L,N)”, “sum(List,S)” without using “append” and “member”. Read your lecture notes and Handouts on recursion. All handouts are posted on my.ryerson.ca (check Course Documents folder).
· Structures in Prolog: how to use terms inside predicates, how to write recursive programs with terms, examples of queries using terms. You can read your notes about examples considered in class. Read the handout about terms (see Course Documents folder on my.ryerson.ca ) that includes an exercise related to a binary tree example (as in A2). Recursive programs with terms: do recursion over structure of a term.
· Constraints (review A3). You have to know 2 approaches to solving problems with constraints: “pure generate and test” and “smart interleaving of generate and test” (including dependency graph). Read your lecture notes and copies of the posted slides. Pay attention to the common pattern in the examples. Start solving this kind of exercises with writing facts that characterize all elements in the given finite domain. This can be done by writing a few atomic statements using a given predicate. The same predicate should be used throughout your program to retrieve values for variables (i.e., to “generate” values for variables). Next, think how many variables you need. This is always stated informally in English in the problem: the number of the variables depend on how many unknowns you have. Then, write the Prolog rule implementing the predicate solve(List). In this rule, implement all of the constraints. Sometimes, you need helping predicates that you can use in this rule. Occasionally, a constraint is stated implicitly: be careful.
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com