Bachelor/Master Exam Version V3B

Similar documents
Bachelor/Master Exam Version V3B

Closed Book Examination. Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. M.Sc. in Advanced Computer Science


Propositional and Predicate Logic - V

Propositional Logic: Models and Proofs

Two hours. Examination definition sheet is available at the back of the examination. UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE

Top-Down Execution CS240B Notes

First-Order Predicate Logic. Basics

Technische Universität München Summer term 2011 Theoretische Informatik Prof. Dr. Dr. h.c J. Esparza / M. Luttenberger / R.

SLD-Resolution And Logic Programming (PROLOG)

Predicate Logic: Sematics Part 1

First-Order Theorem Proving and Vampire. Laura Kovács (Chalmers University of Technology) Andrei Voronkov (The University of Manchester)

Strong AI vs. Weak AI Automated Reasoning

Logic (3A) Young W. Lim 12/5/13

3 Propositional Logic

CS2742 midterm test 2 study sheet. Boolean circuits: Predicate logic:

Outline. Formale Methoden der Informatik First-Order Logic for Forgetters. Why PL1? Why PL1? Cont d. Motivation

COMP219: Artificial Intelligence. Lecture 20: Propositional Reasoning

First-Order Theorem Proving and Vampire

Foundations of Logic Programming

Practice Test III, Math 314, Spring 2016

CS 514, Mathematics for Computer Science Mid-semester Exam, Autumn 2017 Department of Computer Science and Engineering IIT Guwahati

First-Order Logic (FOL)

Advanced Topics in LP and FP

Supplementary exercises in propositional logic

Propositional logic. First order logic. Alexander Clark. Autumn 2014

Theory Combination. Clark Barrett. New York University. CS357, Stanford University, Nov 2, p. 1/24

Computational Logic Fundamentals (of Definite Programs): Syntax and Semantics

Predicate Logic - Semantic Tableau

First-Order Logic. Chapter Overview Syntax

Propositional Reasoning

Herbrand Theorem, Equality, and Compactness

Comp487/587 - Boolean Formulas

Introduction to Sets and Logic (MATH 1190)

First-Order Logic First-Order Theories. Roopsha Samanta. Partly based on slides by Aaron Bradley and Isil Dillig

Part 2: First-Order Logic

Propositional Logic Language

Deductive Systems. Lecture - 3

CSE507. Satisfiability Modulo Theories. Computer-Aided Reasoning for Software. Emina Torlak

Unification and occur check. The programming language Prolog

Logic. Knowledge Representation & Reasoning Mechanisms. Logic. Propositional Logic Predicate Logic (predicate Calculus) Automated Reasoning

Preparing for the CS 173 (A) Fall 2018 Midterm 1

Resolution for mixed Post logic

Knowledge base (KB) = set of sentences in a formal language Declarative approach to building an agent (or other system):

Introduction to Logic in Computer Science: Autumn 2006

Computational Logic. Recall of First-Order Logic. Damiano Zanardini

Logik für Informatiker: PROLOG Part 6: Cuts & Negation

TDDD08 Tutorial 1. Who? From? When? 6 september Victor Lagerkvist (& Wªodek Drabent)

First-Order Logic. Resolution

The non-logical symbols determine a specific F OL language and consists of the following sets. Σ = {Σ n } n<ω

Logic + control: An example of program construction and verification

Math Introduction to Logic Final Exam

Spring 2018 Exam 2 MARK BOX HAND IN PART NAME: PIN: INSTRUCTIONS

AAA615: Formal Methods. Lecture 2 First-Order Logic

Propositional and Predicate Logic - XIII

Definite Logic Programs

Foundations of Artificial Intelligence

The exam is closed book, closed calculator, and closed notes except your one-page crib sheet.

NP-Completeness Part II

A Collection of Problems in Propositional Logic

INTRODUCTION TO LOGIC

First Order Logic (FOL) 1 znj/dm2017

1 Propositional Logic

20.1 2SAT. CS125 Lecture 20 Fall 2016

Announcements. Friday Four Square! Problem Set 8 due right now. Problem Set 9 out, due next Friday at 2:15PM. Did you lose a phone in my office?

arxiv:cs/ v1 [cs.lo] 25 Jan 2005

Propositional and Predicate Logic

Mid-Semester Quiz Second Semester, 2012

Predicate Calculus lecture 1

Computer-Aided Program Design

Resolution (14A) Young W. Lim 8/15/14

Handout Proof Methods in Computer Science

Mathematical Logic. Reasoning in First Order Logic. Chiara Ghidini. FBK-IRST, Trento, Italy

Formal Modeling with Propositional Logic

Paucity, abundance, and the theory of number: Online Appendices

Lecture 10: Even more on predicate logic" Prerequisites for lifted inference: Skolemization and Unification" Inference in predicate logic"

Adam Blank Spring 2017 CSE 311. Foundations of Computing I

Halting and Equivalence of Program Schemes in Models of Arbitrary Theories

List of errors in and suggested modifications for First-Order Modal Logic Melvin Fitting and Richard L. Mendelsohn August 11, 2013

Propositional and Predicate Logic - II

Notes. Corneliu Popeea. May 3, 2013

Introduction to Metalogic

Preliminaries. Introduction to EF-games. Inexpressivity results for first-order logic. Normal forms for first-order logic

An Introduction to SAT Solving

185.A09 Advanced Mathematical Logic

Overview. CS389L: Automated Logical Reasoning. Lecture 7: Validity Proofs and Properties of FOL. Motivation for semantic argument method

(c) Give a proof of or a counterexample to the following statement: (3n 2)= n(3n 1) 2

An Introduction to Z3

DO NOT OPEN THIS QUESTION BOOKLET UNTIL YOU ARE TOLD TO DO SO

Outline. Logic. Definition. Theorem (Gödel s Completeness Theorem) Summary of Previous Week. Undecidability. Unification

Tutorial 1: Modern SMT Solvers and Verification

Loop Formulas for Description Logic Programs

Exam 3, Math Fall 2016 October 19, 2016

Conjunctive Normal Form and SAT

CS 5114: Theory of Algorithms. Tractable Problems. Tractable Problems (cont) Decision Problems. Clifford A. Shaffer. Spring 2014

Propositional Resolution Introduction

Extensions to the Logic of All x are y: Verbs, Relative Clauses, and Only

Propositional Resolution Part 1. Short Review Professor Anita Wasilewska CSE 352 Artificial Intelligence

CogSysI Lecture 8: Automated Theorem Proving

Lecture 9: The Splitting Method for SAT

Transcription:

Prof aadr Jürgen Giesl Carsten Fuhs, Carsten Otto, Thomas Ströder Bachelor/Master Exam Version V3B First Name: Last Name: Immatriculation Number: Course of Studies (please mark exactly one): Informatik Bachelor Mathematik Bachelor Mathematik Master Other: Maximal Points Achieved Points Exercise 1 10 Exercise 2 16 Exercise 3 10 Exercise 4 10 Exercise 5 9 Exercise 6 5 Total 60 Grade - Instructions: On every sheet please give your first name, last name, and immatriculation number You must solve the exam without consulting any extra documents (eg, course notes) Make sure your answers are readable Do not use red or green pens or pencils Please answer the exercises on the exercise sheets If needed, also use the back sides of the exercise sheets Answers on extra sheets can only be accepted if they are clearly marked with your name, your immatriculation number, and the exercise number Cross out text that should not be considered in the evaluation Students that try to cheat do not pass the exam At the end of the exam, please return all sheets together with the exercise sheets 1

Exercise 1 (Theoretical Foundations): (3 + 3 + 4 = 10 points) Let ϕ = q(0, s(0)) X, Y (q(x, Y ) q(s(x), s(y ))) and ψ = Z q(s(z), s(s(z))) be formulas over the signature (Σ, ) with Σ = Σ 0 Σ 1, Σ 0 = {0}, Σ 1 = {s}, and = 2 = {q} a) Prove that ϕ = ψ by means of resolution Hint: First transform the formula ϕ ψ into an equivalent clause set b) Explicitly give a Herbrand model of the formula ϕ (ie, specify a carrier and a meaning for all function and predicate symbols) You do not have to provide a proof for your answer c) Prove or disprove that input resolution is complete for arbitrary clause sets a) ϕ ψ = q(0, s(0)) X, Y (q(x, Y ) q(s(x), s(y ))) Z q(s(z), s(s(z))) = q(0, s(0)) X, Y ( q(x, Y ) q(s(x), s(y ))) Z q(s(z), s(s(z))) = q(0, s(0)) X, Y ( q(x, Y ) q(s(x), s(y ))) Z q(s(z), s(s(z))) = X, Y, Z (q(0, s(0)) ( q(x, Y ) q(s(x), s(y ))) q(s(z), s(s(z)))) Thus, the equivalent clause set for ϕ ψ is {{q(0, s(0))}, { q(x, Y ), q(s(x), s(y ))}, { q(s(z), s(s(z)))}} We perform resolution on this clause set to show ϕ = ψ {q(0, s(0))} { q(x, Y ), q(s(x), s(y ))} { q(s(z), s(s(z)))} { q(z, s(z))} X/Z, Y/s(Z) Z/0 Hence, we have proven ϕ = ψ b) We have S = ϕ for the Herbrand structure S = (T (Σ), α) with α 0 = 0, α s (t) = s(t), and α q = {(s i (0), s i+1 (0)) i 0} c) Consider the clause set {{p, q}, {p, q}, { p, q}, { p, q}} Using input resolution, we obtain the following resolution proof 2

{p, q} {p, q} { p, q} { p, q} {p} {q} {p, p} {q, q} { q} { p} All further input resolution steps lead to already existing clauses and the empty clause cannot be derived However, using full resolution, we obtain the following derivation of the empty clause {p, q} {p, q} { p, q} { p, q} {p} { p} Hence, input resolution is incomplete 3

Exercise 2 (Procedural Semantics, SLD tree): (7 + 9 = 16 points) Consider the following Prolog program P which can be used to sort a list of numbers using the bubblesort algorithm: bubble(l, R) :- swap(l, N),!, bubble(n, R) bubble(l, L) swap([a,b L]), [B,A L]) :- B < A swap([a L], [A N]) :- swap(l, N) Hint: As usual, you should treat < as if it were defined by the infinitely many facts 0 < 1 1 < 2 0 < 2 a) The program P results from P by removing the cut Consider the following query:?- bubble([2,1,0], [1,2,X]) For the logic program P, ie without the cut, please show a successful computation for the query above (ie, a computation of the form (G, ) + P (, σ) where G = { bubble([2, 1, 0], [1, 2, X])}) It suffices to give substitutions only for those variables which are used to define the value of the variable X in the query 4

b) Please give a graphical representation of the SLD tree for the query?- bubble([2, 1], X) in the program P (ie, with the cut) a) ({ bubble([2, 1, 0], [1, 2, X])}, ) P ({ swap([2, 1, 0], N), bubble(n, [1, 2, X])}, ) P ({ (1 < 2), bubble([1, 2, 0], [1, 2, X])}, ) P ({ bubble([1, 2, 0], [1, 2, X])}, ) P (, {X/0}) b) 5

In this representation, the nodes and edges deleted by the cut are shown with a gray background and dashed edges, respectively bubble([2,1], X) X/[2,1] swap([2,1], N1),!, bubble(n1, X) N1/[2 N2] 1 < 2,!, bubble([1,2], X) swap([1], N2),!, bubble([2 N2], X) N2/[1 N3]!, bubble([1,2], X) swap([], N3),!, bubble([2,1 N3], X) bubble([1,2], X) X/[1,2] swap([1,2], N5),!, bubble(n5, X) N5/[2,1] 2 < 1,!, bubble([2,1], X) N5/[1 N6] swap([2], N6),!, bubble([1 N6], X) N6/[2 N7] swap([], N7),!, bubble([1,2 N7], X) 6

Exercise 3 (Definite Logic Programming): (10 points) Implement the predicate solve/1 in Prolog This predicate can be used as a primitive SAT-solver for clause sets represented as lists of lists of literals More precisely, a clause set is a list t of the form [[l 1 1, l 1 2,, l 1 k 1 ], [l 2 1, l 2 2,, l 2 k 2 ],, [l n 1, l n 2,, l n k n ]] where all l j i are of the form pos(x) or neg(x) for some Prolog variables X The list t represents a set of clauses where pos(x) stands for the propositional variable X while neg(x) stands for its negation A call solve(t) succeeds with a substitution satisfying the represented clause set t (by setting the variables to 1 or 0) if this set is satisfiable or fails if this set is unsatisfiable If t does not represent a clause set as described above, then solve(t) may behave arbitrarily You must not use any built-in predicates in this exercise The following example calls to solve/1 illustrate its definition:?- solve([[pos(a),pos(b)],[neg(a),neg(b)]]) has the two answer substitutions A = 1, B = 0 and A = 0, B = 1 (the order of the solutions is up to your implementation)?- solve([[pos(a)],[neg(a)]]) fails Hint: In this representation, a clause is satisfied if it contains at least one literal of the form pos(1) or neg(0) Moreover, a clause set is satisfied if all its clauses are satisfied It might be useful to implement this predicate in a way that the following example calls work as described below, although this is not mandatory succeeds with the empty answer substi-?- solve([[pos(1),pos(b)],[neg(1),neg(b)]]) B = 0?- solve([[pos(1),pos(0)],[neg(1),neg(0)]]) tution succeeds with the answer substitution solve([]) solve([c CS]) :- solveclause(c), solve(cs) solveclause([pos(1) _]) solveclause([neg(0) _]) solveclause([_ XS]) :- solveclause(xs) 7

Exercise 4 (Meta-Programming): (10 points) Implement the predicate map/2 in Prolog A call of map(t 1,t 2 ) works as follows If t 1 is a constant f Σ 0 and t 2 has the form [a 1,, a n ], then the calls f (a 1 ),, f (a n ) are executed That means we assume that there is also a predicate symbol f 1 (with the same name as f Σ 0 ) Thus, map(f,[a 1,, a n ]) succeeds iff the query f (a 1 ),, f (a n ) succeeds If t 1 or t 2 are not of the form described above, map/2 may behave arbitrarily For example, the query?- map(foo,[a,b,c]) is evaluated by executing the three calls foo(a), foo(b) and foo(c), while the query?- map(foo,[]) succeeds immediately Hint: You may use the built-in predicate =/2 map(_,[]) map(p,[x XS]) :- G = [P,X], call(g), map(p,xs) 8

Exercise 5 (Difference Lists): (9 points) Consider the following logic program P q(x) :- p(x - []) p(x - X) p([x Y] - Z) :- p(y - [X Z]) Explicitly give the set of all ground terms t for which the query?- q(t) succeeds You do not have to provide a proof for your answer {[t 1,, t n, t n,, t 1 ] n 0, t i is a ground term for all i {1,, n}} 9

Exercise 6 (Arithmetic): (5 points) Implement the predicate binomial/3 in Prolog A call of binomial(t 1,t 2,t 3 ) works as follows If t 1 and t 2 are integers with t 1 < t 2 or at least one of t 1 or t 2 is negative, then it fails ( If) t 1 and t 2 are t1 non-negative integers with t 1 t 2, then t 3 is unified with the integer resulting from If t 1 or t 2 is no integer, binomial/3 may behave arbitrarily ( ) n Remember that the binomial coefficient for non-negative integers n and k with n k is defined k ( ) n n! as = with 0! = 1 k k!(n k)! The following example calls to binomial/3 illustrate its definition: t 2?- binomial(-3,2,x)?- binomial(2,3,x) fails fails?- binomial(3,2,x) succeeds with the answer substitution X = 3?- binomial(3,2,1) fails binomial(x,y,z) :- Y >= 0, X >= Y, factorial(x,xf), factorial(y,yf), D is X - Y, factorial(d,df), Z is (XF // (DF * YF)) factorial(0,1) :-! factorial(n,f) :- N1 is N - 1, factorial(n1,f1), F is F1 * N 10