Advanced Prolog Programming
|
|
- Sophie Lewis
- 6 years ago
- Views:
Transcription
1 1 Introduction CIS335, Assignment 4 Advanced Prolog Programming Geraint Wiggins November 12, 2004 This practical is the second self-assessed exercise for MSc students on the Prolog module. It is intended to reinforce the information taught in the lectures, and to give practice in relatively advanced Prolog programming. Unless otherwise stated, the exercises should be answered first away from the computer, and then the answers checked by running them. Feel free to ask your tutor, me, or your fellow students if you get stuck; if you are a student who is secure in Prolog, remember that explaining to others can be a very good way of reaching a better understanding yourself. To save you pointless typing, example code for the exercises which require it may be found in on my web site. 2 Debugging 2.1 Tracing Use the trace command to follow and compare the execution of the following queries, to predicates whose definitions are given in the examples file. Remember that reverse/2 and reverse/3 are distinct predicates. % call to naive reverse?- reverse( [a,b,c], Answer ) % call to accumulating reverse?- reverse( [a,b,c], [], Answer ). Remember that you will need to see the source code as you use the debugger. Concentrate particularly on the two different approaches to reversing lists, and make sure you understand how the accumulator argument works in the second query.? is the help command when in trace mode. 1
2 2.2 Debugging Use on-paper analysis and the debugger to solve the following problem. I have implemented some prolog predicates according to the following specification. Most of them seem to work, but one or more is/are apparently faulty. Work out, from the specification and supplied code, which of the predicates is/are incorrect, then set a spy point on it/them, and use the debugger to work out what is wrong. It seems fairly likely that at least the quicksort/2 predicate is faulty. Specification This is a specification for a piece of Prolog code which interfaces between two other programs. In other words, it converts the output format of one (a planning program, for storage of shop goods) into the input format of the other (an inventory database system). The output format (ie the input to our program) is a list of terms of the form identifier( reference number, size ) where identifier is one of box, lid, bottle, tin, bag, the referencenumber is an integer, and the size is small, medium, or large. The order of the list is the order in which the planning program has chosen to store the goods. The input format (ie the output of our program) is a list of terms of the form reference numbersize/type, which are sorted by reference number. Type is the same value as the identifier in the output format; size is 1, 2, or 3. A predicate is supplied which will give you some sample output (sample output/1); use it in a query to pass that output to your conversion routine, which will give a result like this when the program works correctly:?- sample output(x),conversion(x,y). X = [box(1,large),lid(1,large),bottle(3,small),bottle(12,sma ll),tin(5,small),lid(5,small),bag(20,large),bag(8,small),bag (6,medium)], Y = [1-box/3,1-lid/3,3-bottle/1,5-tin/1,5-lid/1,6-bag/2,8-ba g/1,12-bottle/1,20-bag/3] 3 Cut 3.1 Coloured cuts Decide which of these predicates contain red or green cuts. If you are unsure, check, by removing the cut and seeing if the logical behaviour is the same (especially when backtracking). % which is the maximum of two numbers? max( X, Y, X ) :- X > Y,!. max( X, Y, Y ) :- X =< Y. 2
3 % is a value a or not? test( a ). a only( X, yes ) :-!,test( X ). a only( X, no ) :- \+ test( X ). % is a value a or not? (version 2) test( a ) :-!. a only( X, yes ) :- test( X ). a only( X, no ) :-!, \+ test( X ). 3.2 Committing to solutions How many solutions will the following programs/queries yield on exhaustive backtracking (ie using ; until we get no)? In what order will they appear? % commit 1 p(c).?- p(x). % commit 2 p(b) :-!. p(c).?- p(x). % commit 3?- p(x),!. 3
4 % commit 4 q(b).?- p(x),!,q(x). 4 Operators Refer to the SWIProlog manual and look up how to use the predicates op/3 and current op/3 to define and check Prolog operators. Use op/3 to define an operator ++ so that the following goals are true. Note that you will redefine ++ for each example, so don t expect all of them to work at once. You will need to use current op/3 to look up the details of the existing operators, like + and =. % op1? = ( 1 + ( 2 ++ )). % op2? = (( ) ++). % op3?- a - ++ b = ( a - ( ++ b )). % op4?- ++ a - b = (++ ( a - b )). % op5?- a = ( a ++ ( - 3 )). % op6?- a ++ b ++ c = ( a ++ ( b ++ c )). % op7?- a ++ b ++ c = (( a ++ b ) ++ c )). % op8?- a c = ( a ++ ( ++ c )). % op9?- a c = (( a ++ ) ++ c ). 4
5 5 Meta-programming Using the meta-programming facilities of Prolog, we can write a simple Prolog interpreter. We use the built-in predicate clause to give us access to the database look it up in the manual if you are not sure how it works. The basic interpreter (usually called solve/1) looks like this. It deals only with conjunctions in clauses and disjunctions between (but not within) clauses. solve( true ). solve( Goal ) :- \+ Goal = (, ), clause( Goal, Body ), solve( Body ). solve(( Goal1, Goal2 )) :- solve( Goal1 ), solve( Goal2 ). Use this basic program (in the examples file) to explore the operation of the append/3 program in the examples file. Compare the trace of solve calling append with that of a direct call at the prompt, and verify that the effect is the same. If you wish to try any other predicates with solve/1 remember that you must declare them as dynamic before you can do so. Remember also that if you wish to use conjunctions in your call to solve/1 you must put them in () otherwise they will be mistaken as calls to solve/2 or solve/3 because of the comma operator. Having understood the operation of the program, add a further two clauses so that the interpreter can solve disjunctive goals, to achieve the following behaviour:?- solve(( append( [a,b], [c], D ); append( [x], [y,z], D ))). D = [a,b,c]? ; D = [x,y,z]? ; no Hint: consider how conjunction is implemented, by taking the meta-level comma and replacing it by an object-level one. You will need to make minor modifications to some of the other clauses too, because ;/2 is defined as a built-in, static (not dynamic) predicate. Finally, rewrite the clause that deals with looking up the program clause (clause 2 of solve/1) as follows. It is often (though not always) the case that executing goals with fewer uninstantiated variables first can lead to a more efficient execution. Here s an example: 5
6 q(b).?- p(x),q(a). In this case, q(a) always fails, and because it is determinate that is, there is no choice to be made in its arguments it might as well be executed first. The examples file contains a predicate called conjunction to list/2 which will be helpful here. Use it to unpack the clause body returned to solve/1 by clause/2 into a list, and then write a predicate which will split the list into two lists, one of ground conjuncts and one of non-ground conjuncts (use the meta-predicate ground/1 to test this). You may like to look at the split/4 predicate, above, to get some hints on how to do the splitting up. Put the two lists back together again, the ground ones at the front, and convert them back into a goal using conjunction to list backwards. Then pass that new goal to solve/1. Now use the debugger to investigate the behaviour of the following query:?- solve(( p( X ), p( Y ), append( [x,y], [X], [x,y,d] ))). When you run this, it should fail. Work out why, using the normal Prolog left-to-right computation rule. Then compare the usual behaviour with that of the solve version, above. You should find that your new computation rule never bothers with p(y), because the other two goals can never succeed together. 6
More Non-logical Features of Prolog
More Non-logical Features of Prolog Prof. Geraint A. Wiggins Centre for Cognition, Computation and Culture Goldsmiths College, University of London Contents Commit operators Implementing Negation as Failure
More informationExercises on the Fundamentals of Prolog
1 Introduction Exercises on the Fundamentals of Prolog These exercises are intended to help reinforce material taught in the lectures of CIS335 course in Prolog. They do not contribute any marks to the
More informationTopic B: Backtracking and Lists
Topic B: Backtracking and Lists 1 Recommended Exercises and Readings From Programming in Prolog (5 th Ed.) Readings: Chapter 3 2 Searching for the Answer In order for a Prolog program to report the correct
More informationPart I Logic programming paradigm
Part I Logic programming paradigm 1 Logic programming and pure Prolog 1.1 Introduction 3 1.2 Syntax 4 1.3 The meaning of a program 7 1.4 Computing with equations 9 1.5 Prolog: the first steps 15 1.6 Two
More informationCS 360: Programming Languages Lecture 10: Logic Programming with Prolog
CS 360: Programming Languages Lecture 10: Logic Programming with Prolog Geoffrey Mainland Drexel University Section 1 Administrivia Midterm Tuesday Midterm is Tuesday, February 14! Study guide is on the
More informationCombining Lists & Built-in Predicates
Combining Lists & Built-in Predicates Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 6 11/10/04 11/10/04 AIPP Lecture 6: Built-in Predicates 1 Collecting Results Last time we
More informationLING/C SC/PSYC 438/538. Lecture 20 Sandiway Fong
LING/C SC/PSYC 438/538 Lecture 20 Sandiway Fong Today's Topics SWI-Prolog installed? We will start to write grammars today Quick Homework 8 SWI Prolog Cheatsheet At the prompt?- 1. halt. 2. listing. listing(name).
More informationProject 5 - The Meta-Circular Evaluator
MASSACHVSETTS INSTITVTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science 6.001 Structure and Interpretation of Computer Programs Fall Semester, 2005 Project 5 - The Meta-Circular
More informationFundamentals of Prolog
Fundamentals of Prolog Prof. Geraint A. Wiggins Centre for Cognition, Computation and Culture Goldsmiths College, University of London Contents Summary of Lecture 1 What makes a good Prolog program? What
More informationINTRODUCTION TO PROLOG
INTRODUCTION TO PROLOG PRINCIPLES OF PROGRAMMING LANGUAGES Norbert Zeh Winter 2018 Dalhousie University 1/44 STRUCTURE OF A PROLOG PROGRAM Where, declaratively, Haskell expresses a computation as a system
More informationCSC384: Intro to Artificial Intelligence Prolog Tutorials 3&4. Hojjat Ghaderi, Fall 2006, University of Toronto
CSC384: Intro to Artificial Intelligence Prolog Tutorials 3&4 1 Debugging Programs in Prolog We talked about the graphical debugger under Windows. Now, the text-based debugger: You can put a breakpoint
More informationProlog-2 nd Lecture. Prolog Predicate - Box Model
Prolog-2 nd Lecture Tracing in Prolog Procedural interpretation of execution Box model of Prolog predicate rule How to follow a Prolog trace? Trees in Prolog use nested terms Unification Informally Formal
More informationLING/C SC/PSYC 438/538. Lecture 15 Sandiway Fong
LING/C SC/PSYC 438/538 Lecture 15 Sandiway Fong Did you install SWI Prolog? SWI Prolog Cheatsheet At the prompt?- Everything typed at the 1. halt. prompt must end in a period. 2. listing. listing(name).
More information1. M,M sequential composition: try tactic M; if it succeeds try tactic M. sequential composition (, )
Dipl.-Inf. Achim D. Brucker Dr. Burkhart Wolff Computer-supported Modeling and Reasoning http://www.infsec.ethz.ch/ education/permanent/csmr/ (rev. 16802) Submission date: FOL with Equality: Equational
More informationIntro to Bottom-up Parsing. Lecture 9
Intro to Bottom-up Parsing Lecture 9 Bottom-Up Parsing Bottom-up parsing is more general than topdown parsing And just as efficient Builds on ideas in top-down parsing Bottom-up is the preferred method
More informationOperators (2A) Young Won Lim 10/2/13
Operators (2A) Copyright (c) 2013 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version
More informationOperational Semantics
15-819K: Logic Programming Lecture 4 Operational Semantics Frank Pfenning September 7, 2006 In this lecture we begin in the quest to formally capture the operational semantics in order to prove properties
More informationBachelor/Master Exam Version V3B
Prof. aadr. Jürgen Giesl Carsten Otto Bachelor/Master Exam Version V3B First Name: Last Name: Course of Studies (please mark exactly one): Informatik Bachelor TK Master Mathematik Master Other: Maximal
More informationBacktracking. Backtracking. Backtracking. Backtracking. Backtracking. Backtracking. Functional & Logic Programming - Backtracking October, 01
Functional & Logic Programming - October, 01 already seen how to control execution ordering the clauses and goals can affect the speed of execution and the order of evaluation of the clauses now going
More informationSoftware Testing Prof. Meenakshi D Souza Department of Computer Science and Engineering International Institute of Information Technology, Bangalore
Software Testing Prof. Meenakshi D Souza Department of Computer Science and Engineering International Institute of Information Technology, Bangalore Lecture 04 Software Test Automation: JUnit as an example
More informationProject 5 - The Meta-Circular Evaluator
MASSACHVSETTS INSTITVTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science 6.001 Structure and Interpretation of Computer Programs Spring Semester, 2005 Project 5 - The Meta-Circular
More informationBacktrack control. Chapter 5
Chapter 5 Backtrack control Prolog will automatically backtrack to satisfy a goal. This relieves the programmer of the burden of putting in backtrack explicitly. On the negative side, this might lead to
More informationOperators (2A) Young Won Lim 10/5/13
Operators (2A) Copyright (c) 2013 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version
More informationRELATIONAL OPERATORS #1
RELATIONAL OPERATORS #1 CS 564- Spring 2018 ACKs: Jeff Naughton, Jignesh Patel, AnHai Doan WHAT IS THIS LECTURE ABOUT? Algorithms for relational operators: select project 2 ARCHITECTURE OF A DBMS query
More informationIntroduction to Bottom-Up Parsing
Introduction to Bottom-Up Parsing Lecture 11 CS 536 Spring 2001 1 Outline he strategy: shift-reduce parsing Ambiguity and precedence declarations Next lecture: bottom-up parsing algorithms CS 536 Spring
More informationProlog. Intro to Logic Programming
Prolog Logic programming (declarative) Goals and subgoals Prolog Syntax Database example rule order, subgoal order, argument invertibility, backtracking model of execution, negation by failure, variables
More informationTests, Backtracking, and Recursion
Tests, Backtracking, and Recursion Artificial Intelligence Programming in Prolog Lecture 3 30/09/04 30/09/04 AIPP Lecture 3: Rules, Results, and Backtracking 1 Re-cap A Prolog program consists of predicate
More informationCAP 5602 Summer, Lesson 4: Loops. The topics 1. the cut and some of its uses 2. the while loop 3. the do until loop
CAP 5602 Summer, 2011 Lesson 4: Loops The topics 1. the cut and some of its uses 2. the while loop 3. the do until loop 1. The cut The cut (!) is a way of controlling backtracking. If a rule contains a
More informationIntroduction to Prolog Paper Refs. Prolog tutor. Julian Verdurmen. Seminar Softw. tech. for teaching and learning. September 30, 2009
Seminar Softw. tech. for teaching and learning September 30, 2009 Outline 1 Introduction to Prolog Basics Simple example 2 Basics Simple example Outline 1 Introduction to Prolog Basics Simple example 2
More informationInfinite Derivations as Failures
Infinite Derivations as Failures Andrea Corradi and Federico Frassetto DIBRIS, Università di Genova, Italy name.surname@dibris.unige.it Abstract. When operating on cyclic data, programmers have to take
More informationAgenda. CS301 Session 20. A logic programming trick. A simple Prolog program. Introduction to logic programming Examples Semantics
CS301 Session 20 Introduction to logic programming Examples Semantics Agenda 1 2 A logic programming trick A two-way translator in two lines of code: translate([],[]). translate([word Words],[Mot Mots])
More informationThe object level in Prolog. Meta-level predicates and operators. Contents. The flow of computation. The meta level in Prolog
Lecture 8 Meta-level predicates and operators Contents Object level vs. meta level Controlling flow of computation Checking and dismantling expressions Comparison operators The object level in Prolog Prolog
More information6.001 Notes: Section 6.1
6.001 Notes: Section 6.1 Slide 6.1.1 When we first starting talking about Scheme expressions, you may recall we said that (almost) every Scheme expression had three components, a syntax (legal ways of
More informationProgramming Paradigms
PP 2017/18 Unit 9 Prolog: Accumulators, Order of Goals/Clauses, and the Cut 1/38 Programming Paradigms Unit 9 Prolog: Accumulators, Order of Goals/Clauses, and the Cut J. Gamper Free University of Bozen-Bolzano
More informationLecture 11: Feb. 10, 2016
CS323: AI (Hands on with Prolog) Spring 2016 Lecturer: K.R. Chowdhary Lecture 11: Feb. 10, 2016 : Professor of CS (VF) Disclaimer: These notes have not been subjected to the usual scrutiny reserved for
More informationMatrices. Chapter Matrix A Mathematical Definition Matrix Dimensions and Notation
Chapter 7 Introduction to Matrices This chapter introduces the theory and application of matrices. It is divided into two main sections. Section 7.1 discusses some of the basic properties and operations
More informationHardware Description and Verification Lava Exam
Hardware Description and Verification Lava Exam Mary Sheeran Revised by Thomas Hallgren hallgren@chalmers.se May 16, 2010 Introduction The purpose of this take-home exam is to give you further practice
More informationWhat is Prolog? - 1. A Prolog Tutorial. What is Prolog? - 2. Prolog Programming. » Declaring some facts about objects and their relationships
What is Prolog? - 1 Prolog is an example of a logic programming language Invented by Alain Colmeraurer in 1972 A Prolog Tutorial Based on Clocksin and Mellish Chapter 1 The version implemented at the University
More informationWhat is Prolog? - 1. A Prolog Tutorial. Prolog Programming. What is Prolog? - 2. » Declaring some facts about objects and their relationships
What is Prolog? - 1 Prolog is an example of a logic programming language A Prolog Tutorial Based on Clocksin and Mellish Chapter 1 Invented by Alain Colmeraurer in 1972 The version implemented at the University
More informationIP Routing Lab Assignment Configuring Basic Aspects of IP IGP Routing Protocols
IP Routing Lab Assignment Configuring Basic Aspects of IP IGP Routing Protocols 1 PURPOSE AND GOALS This lab assignment will give you a hands-on experience in configuring and managing routers and particularly
More informationProlog Assessed Exercise
Prolog Assessed Exercise David Eyers 21st April 2009 The purpose of this exercise is to implement in Prolog the Bellman-Ford algorithm for computing singlesource shortest paths
More informationCOMPUTER SCIENCE TRIPOS
CST.2011.3.1 COMPUTER SCIENCE TRIPOS Part IB Monday 6 June 2011 1.30 to 4.30 COMPUTER SCIENCE Paper 3 Answer five questions. Submit the answers in five separate bundles, each with its own cover sheet.
More informationCSE Theory of Computing Fall 2017 Project 1-SAT Solving
CSE 30151 Theory of Computing Fall 2017 Project 1-SAT Solving Version 3: Sept. 21, 2017 The purpose of this project is to gain an understanding of one of the most central problems of computing: Boolean
More information3 Lists. List Operations (I)
3 Lists. List Operations (I) The list is the simplest yet the most useful Prolog structure. A list is a sequence of any number of objects. Example 3.1: L = [1, 2, 3], R = [a, b, c], T = [john, marry, tim,
More informationThis lecture covers: Prolog s execution strategy explained more precisely. Revision of the elementary Prolog data types
This lecture covers: Prolog s execution strategy explained more precisely The execution strategy has been presented as simply placing all matching clauses onto the stack. In fact, Prolog is slightly more
More informationChapter 16. Logic Programming. Topics. Unification. Resolution. Prolog s Search Strategy. Prolog s Search Strategy
Topics Chapter 16 Logic Programming Summary (resolution, unification, Prolog search strategy ) Disjoint goals The cut operator Negative goals Predicate fail Debugger / tracer Lists 2 Resolution Resolution
More informationAn Interesting Way to Combine Numbers
An Interesting Way to Combine Numbers Joshua Zucker and Tom Davis October 12, 2016 Abstract This exercise can be used for middle school students and older. The original problem seems almost impossibly
More informationBachelor/Master Exam Version V3B
Prof aadr Jürgen Giesl Carsten Otto Bachelor/Master Exam Version V3B First Name: Last Name: Immatriculation Number: Course of Studies (please mark exactly one): Informatik Bachelor TK Master Mathematik
More informationChapter 5. Pure PROLOG. Foundations of Logic Programming
Chapter 5 1 Outline vs. logic programming Lists in Adding Arithmetics to Adding the Cut to 2 Syntax of Pure Prolog p(x,a) :- q(x), r(x,yi). p(x, a) q(x), r(x,y i ) % Comment Ambivalent syntax: p(p(a,b),
More informationLogic Programming. Efficiency Issues. Temur Kutsia
Logic Programming Efficiency Issues Temur Kutsia Research Institute for Symbolic Computation Johannes Kepler University of Linz, Austria kutsia@risc.uni-linz.ac.at Efficiency Issues in Prolog Narrow the
More informationIntroduction to Algorithms 6.046J/18.401J
Introduction to Algorithms 6.046J/18.401J Menu for Today Show that Θ (n lg n) is the best possible running time for a sorting algorithm. Design an algorithm that sorts in linear time. Hint: maybe the models
More informationGenerative and accumulative recursion. What is generative recursion? Example revisited: GCD. Readings: Sections 25, 26, 27, 30, 31
Generative and accumulative recursion Readings: Sections 25, 26, 27, 30, 31 Some subsections not explicitly covered in lecture Section 27.2 technique applied to strings CS 135 Fall 2017 11: Generative
More informationEECS 140 Laboratory Exercise 5 Prime Number Recognition
1. Objectives EECS 140 Laboratory Exercise 5 Prime Number Recognition A. Become familiar with a design process B. Practice designing, building, and testing a simple combinational circuit 2. Discussion
More informationMORE SCHEME. 1 What Would Scheme Print? COMPUTER SCIENCE MENTORS 61A. October 30 to November 3, Solution: Solutions begin on the following page.
MORE SCHEME COMPUTER SCIENCE MENTORS 61A October 30 to November 3, 2017 1 What Would Scheme Print? Solutions begin on the following page. 1. What will Scheme output? Draw box-and-pointer diagrams to help
More informationPage 1 of 5. University of Toronto CSC326 Programming Languages, Fall 2009
University of Toronto CSC326 Programming Languages, Fall 2009 Assignment # 4 Part B (Due: Monday, Dec. 7rd 2009, 11:00am sharp) Details: - Programming in Prolog. This is the Part B of assignment 4, and
More informationDifference lists in Prolog
tmcs-csenki 2010/4/12 23:38 page 73 #1 8/1 (2010), 73 87 Difference lists in Prolog Attila Csenki Abstract. Prolog is taught at Bradford University within the two-semester module Symbolic and Declarative
More informationLecture Notes on Prolog
Lecture Notes on Prolog 15-317: Constructive Logic Frank Pfenning Lecture 14 October 15, 2009 In this lecture we introduce some simple data structures such as lists, and simple algorithms on them such
More informationDepartment of Electrical Engineering and Computer Sciences Fall 2000 Instructor: Dan Garcia CS 3 Final Exam
University of California, Berkeley College of Engineering Department of Electrical Engineering and Computer Sciences Fall 2000 Instructor: Dan Garcia 2000-12-15 CS 3 Final Exam Last name First name SID
More informationCOMP2411 Lecture 20: Logic Programming Examples. (This material not in the book)
COMP2411 Lecture 20: Logic Programming Examples (This material not in the book) There are several distinct but often equivalent ways to think about logic programs 1. As computing logical consequences of
More information815338A Principles of Programming Languages. Exercise 7 answers
815338A Principles of Programming Languages. Exercise 7 answers The topic of this exercise is logic programming in Prolog. Prolog programs can be executed at https://ideone.com/ or http://www.tutorialspoint.com/codingground.htm.
More informationLaboratory 5: Implementing Loops and Loop Control Strategies
Laboratory 5: Implementing Loops and Loop Control Strategies Overview: Objectives: C++ has three control structures that are designed exclusively for iteration: the while, for and do statements. In today's
More informationComputer Science 236 Fall Nov. 11, 2010
Computer Science 26 Fall Nov 11, 2010 St George Campus University of Toronto Assignment Due Date: 2nd December, 2010 1 (10 marks) Assume that you are given a file of arbitrary length that contains student
More informationReview Functions Subroutines Flow Control Summary
OUTLINE 1 REVIEW 2 FUNCTIONS Why use functions How do they work 3 SUBROUTINES Why use subroutines? How do they work 4 FLOW CONTROL Logical Control Looping 5 SUMMARY OUTLINE 1 REVIEW 2 FUNCTIONS Why use
More informationSymbolic Computation Example Programming Exercises for Prolog
2001 July 16 3401 Prolog Programming Exercises Page 1 of 8 Symbolic Computation Example Programming Exercises for Prolog 1. Write a Prolog predicate countbt(tree, Count) to count the number of des in a
More informationCSSE2002/7023 The University of Queensland
CSSE2002 / CSSE7023 Semester 1, 2016 Assignment 1 Goal: The goal of this assignment is to gain practical experience with data abstraction, unit testing and using the Java class libraries (the Java 8 SE
More informationRecursion, Structures, and Lists
Recursion, Structures, and Lists Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 4 04/10/04 30/09/04 AIPP Lecture 3: Recursion, Structures, and Lists 1 The central ideas of Prolog
More informationApril 2 to April 4, 2018
MORE SCHEME COMPUTER SCIENCE MENTORS 61A April 2 to April 4, 2018 1 Scheme 1. What will Scheme output? Draw box-and-pointer diagrams to help determine this. (a) (cons (cons 1 nil) (cons 2 (cons (cons 3
More informationLecture 6: More Lists
Lecture 6: More Lists Theory Define append/3, a predicate for concatenating two lists, and illustrate what can be done with it Discuss two ways of reversing a list A naïve way using append/3 A more efficient
More informationSo what does studying PL buy me?
So what does studying PL buy me? Enables you to better choose the right language but isn t that decided by libraries, standards, and my boss? Yes. Chicken-and-egg. My goal: educate tomorrow s tech leaders
More informationLogic Programming Languages
Logic Programming Languages Introduction Logic programming languages, sometimes called declarative programming languages Express programs in a form of symbolic logic Use a logical inferencing process to
More informationStatistics Case Study 2000 M. J. Clancy and M. C. Linn
Statistics Case Study 2000 M. J. Clancy and M. C. Linn Problem Write and test functions to compute the following statistics for a nonempty list of numeric values: The mean, or average value, is computed
More informationProlog. Logic Programming vs Prolog
Language constructs Prolog Facts, rules, queries through examples Horn clauses Goal-oriented semantics Procedural semantics How computation is performed? Comparison to logic programming 1 Logic Programming
More informationProlog - 3 Prolog search trees + traces
Prolog - 3 Prolog search trees + traces 1 Review member(a, [A B]). member(a, [B C]) :- member (A,C). goal-oriented semantics: can get value assignment for goal member(a,[b C]) by showing truth of subgoal
More informationWeek 5 Tutorial Structural Induction
Department of Computer Science, Australian National University COMP2600 / COMP6260 Formal Methods in Software Engineering Semester 2, 2016 Week 5 Tutorial Structural Induction You should hand in attempts
More informationCourse on Artificial Intelligence and Intelligent Systems. A short introduction to CHR and its application for rule-based expert systems
Course on Artificial Intelligence and Intelligent Systems A short introduction to CHR and its application for rule-based expert systems A course note Henning Christiansen Roskilde University, Computer
More informationIntroduction to predicate calculus
Logic Programming Languages Logic programming systems allow the programmer to state a collection of axioms from which theorems can be proven. Express programs in a form of symbolic logic Use a logical
More informationPart III Appendices 165
Part III Appendices 165 Appendix A Technical Instructions Learning Outcomes This material will help you learn how to use the software you need to do your work in this course. You won t be tested on it.
More informationIntroduction to Logic Programming. Ambrose
Introduction to Logic Programming Ambrose Bonnaire-Sergeant @ambrosebs abonnairesergeant@gmail.com Introduction to Logic Programming Fundamental Logic Programming concepts Related to FP General implementation
More informationAnnouncements for this Lecture
Lecture 6 Objects Announcements for this Lecture Last Call Quiz: About the Course Take it by tomorrow Also remember survey Assignment 1 Assignment 1 is live Posted on web page Due Thur, Sep. 18 th Due
More informationTurtle Graphics and L-systems Informatics 1 Functional Programming: Tutorial 7
Turtle Graphics and L-systems Informatics 1 Functional Programming: Tutorial 7 Heijltjes, Wadler Due: The tutorial of week 9 (20/21 Nov.) Reading assignment: Chapters 15 17 (pp. 280 382) Please attempt
More informationQ1:a. Best first search algorithm:
Q1:a Best first search algorithm: 1. Open=[A10]; closed=[] 2. Evaluate A10; open=[c20,b30,d40];closed=[a10] 3. Evaluate C20; open=[b30,g35,d40,h40]; closed=[c20, A10] 4. Evaluate B30; open=[e10,f20,g35,d40,h40];
More information6.S189 Homework 1. What to turn in. Exercise 1.1 Installing Python. Exercise 1.2 Hello, world!
6.S189 Homework 1 http://web.mit.edu/6.189/www/materials.html What to turn in Do the warm-up problems for Days 1 & 2 on the online tutor. Complete the problems below on your computer and get a checkoff
More informationBTEC Nationals IT - Unit2 FAQs
BTEC Nationals IT - Unit2 FAQs Q1 Q2 I need more clarity on what is required in the design task Is it expected that the race officials are entering times as raw times and then the table is set up so it
More informationProgramming Paradigms Written Exam (6 CPs)
Programming Paradigms Written Exam (6 CPs) 22.06.2017 First name Student number Last name Signature Instructions for Students Write your name and student number on the exam sheet and on every solution
More informationBacktracking. Ch. 5 Controlling Backtracking. Backtracking. Backtracking Example. Example. Example
Backtracking Ch. 5 Controlling Backtracking Backtracking is the attempt to (re)satisfy a goal by exploring alternative ways to satisfy it. Chronological backtracking is backtracking in which we always
More informationWe first learn one useful option of gcc. Copy the following C source file to your
Lecture 5 p.1 Faculty of Computer Science, Dalhousie University CSCI 2132 Software Development Lab 5: gcc and gdb tools 10-Oct-2018 Location: Teaching Labs Time: Thursday Instructor: Vlado Keselj Lab 5:
More informationNotes for Chapter 12 Logic Programming. The AI War Basic Concepts of Logic Programming Prolog Review questions
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions The AI War How machines should learn: inductive or deductive? Deductive: Expert => rules =>
More informationIntegrity Constraints (Chapter 7.3) Overview. Bottom-Up. Top-Down. Integrity Constraint. Disjunctive & Negative Knowledge. Proof by Refutation
CSE560 Class 10: 1 c P. Heeman, 2010 Integrity Constraints Overview Disjunctive & Negative Knowledge Resolution Rule Bottom-Up Proof by Refutation Top-Down CSE560 Class 10: 2 c P. Heeman, 2010 Integrity
More informationScheme of work Cambridge International AS & A Level Computing (9691)
Scheme of work Cambridge International AS & A Level Computing (9691) Unit 2: Practical programming techniques Recommended prior knowledge Students beginning this course are not expected to have studied
More informationAbout these slides Prolog programming hints
About these slides Prolog programming hints COMP9414-2008 Semester 1 Ronnie Taib (ronniet@cse.unsw.edu.au)! Practical notes on using Prolog! Some hints for better code! LECTURE NOTES ALWAYS PREVAIL!! The
More informationLecture Notes on Prolog
Lecture Notes on Prolog 15-317: Constructive Logic Frank Pfenning Lecture 14 October 27, 2015 In this lecture we introduce some simple data structures such as lists, and simple algorithms on them such
More informationPlan (next 4 weeks) 1. Fast forward. 2. Rewind. 3. Slow motion. Rapid introduction to what s in OCaml. Go over the pieces individually
Plan (next 4 weeks) 1. Fast forward Rapid introduction to what s in OCaml 2. Rewind 3. Slow motion Go over the pieces individually History, Variants Meta Language Designed by Robin Milner @ Edinburgh Language
More informationVariables and Constants
87 Chapter 5 Variables and Constants 5.1 Storing Information in the Computer 5.2 Declaring Variables 5.3 Inputting Character Strings 5.4 Mistakes in Programs 5.5 Inputting Numbers 5.6 Inputting Real Numbers
More informationChapter 16. Logic Programming Languages
Chapter 16 Logic Programming Languages Chapter 16 Topics Introduction A Brief Introduction to Predicate Calculus Predicate Calculus and Proving Theorems An Overview of Logic Programming The Origins of
More informationLecture 16: Logic Programming in Prolog
Lecture 16: Logic Programming in Prolog COMP 524 Programming Language Concepts Stephen Olivier March 26, 2009 Based on slides by A. Block, notes by N. Fisher, F. Hernandez-Campos, and D. Stotts Goal of
More informationIntroduction to Prolog
Introduction to Prolog David Woods dwoods@scss.tcd.ie Week 3 - HT Declarative Logic The Prolog programming language is, at its theoretical core, a declarative language. This is unlike more commonly used
More informationAn Explicit Continuation Evaluator for Scheme
Massachusetts Institute of Technology Course Notes 2 6.844, Spring 05: Computability Theory of and with Scheme February 17 Prof. Albert R. Meyer revised March 3, 2005, 1265 minutes An Explicit Continuation
More informationBuilding a system for symbolic differentiation
Computer Science 21b Structure and Interpretation of Computer Programs Building a system for symbolic differentiation Selectors, constructors and predicates: (constant? e) Is e a constant? (variable? e)
More informationProf. Dr. A. Podelski, Sommersemester 2017 Dr. B. Westphal. Softwaretechnik/Software Engineering
Prof. Dr. A. Podelski, Sommersemester 2017 Dr. B. Westphal Softwaretechnik/Software Engineering http://swt.informatik.uni-freiburg.de/teaching/ss2017/swtvl Exercise Sheet 6 Early submission: Wednesday,
More informationMenu. Algebraic Simplification - Boolean Algebra EEL3701 EEL3701. MSOP, MPOS, Simplification
Menu Minterms & Maxterms SOP & POS MSOP & MPOS Simplification using the theorems/laws/axioms Look into my... 1 Definitions (Review) Algebraic Simplification - Boolean Algebra Minterms (written as m i ):
More information