Prolog programming Introduction to Prolog (part2)

Slides:



Advertisements
Similar presentations
© Johan Bos Logic Programming About the course –Taught in English –Tuesday: mostly theory –Thursday: practical work [lab] Teaching material –Learn Prolog.
Advertisements

Logic Programming Lecture 1: Getting started. Getting started We’ll use SICStus Prolog Free for UofE students Available on all DICE machines
Lecturer: Dr. Abeer Mahmoud Logic Programming in Prolog.
1. An Overview of Prolog.
1 Part 1 The Prolog Language Chapter 2 Syntax and Meaning of Prolog programs.
Prolog.
PROLOG SYNTAX AND MEANING Ivan Bratko University of Ljubljana Faculty of Computer and Info. Sc. Ljubljana, Slovenia.
Introduction to PROLOG ME 409 Lab - 1. Introduction to PROLOG.
1 Introduction to Prolog References: – – Bratko, I., Prolog Programming.
1 Logic Programming. 2 A little bit of Prolog Objects and relations between objects Facts and rules. Upper case are variables. parent(pam, bob).parent(tom,bob).
2. Syntax and Meaning. Contents Data Objects Matching Declarative meaning of Prolog Procedural meaning Example: monkey and banana Order of clauses and.
1 COMP313A Programming Languages Logic Programming (3)
Prolog Programming for Artificial Intelligence Three edition 2001
Prolog programming Introduction to Prolog (part4) CS 370 – CS461.
Prolog programming Introduction to Prolog
About prolog  History  Symbolic Programming Language  Logic Programming Language  Declarative Programming Language.
4. PROLOG Data Objects And PROLOG Arithmetic
For Friday Read “lectures” 1-5 of Learn Prolog Now: prolog-now/
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
1 Artificial Intelligence CSC 361 Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Riyadh, Saudi Arabia
Prolog programming Introduction to Prolog CS370d - CS 461.
PROLOG KAIST Gunwoo Park 1. What’s Prolog? 2  General purpose logic programming language  Declarative, which means that the program logic is.
Formal Models of Computation Part II The Logic Model
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
Logic Programming Module 2AIT202 Website Lecturer: Dave Sharp Room: AG15
Primitive Variables.
Introduction to Prolog Facts, Questions & Rules Atoms & Variables.
BASICS CONCEPTS OF ‘C’.  C Character Set C Character Set  Tokens in C Tokens in C  Constants Constants  Variables Variables  Global Variables Global.
PROLOG SYNTAX AND MEANING Ivan Bratko University of Ljubljana Faculty of Computer and Info. Sc. Ljubljana, Slovenia.
CS 603: Programming Languages Lecture 25 Spring 2004 Department of Computer Science University of Alabama Joel Jones.
Introduction to Prolog. Outline What is Prolog? Prolog basics Prolog Demo Syntax: –Atoms and Variables –Complex Terms –Facts & Queries –Rules Examples.
CS 337 Programming Languages Logic Programming I (Logic, Intro to Prolog)
Logic Programming Dr. Yasser Ahmed Nada Fall 2010/2011 Lecture 2 1 Logic Programming.
Ajmer Singh PGT(IP) Programming Fundamentals. Ajmer Singh PGT(IP) Java Character Set Character set is a set of valid characters that a language can recognize.
CS 403: Programming Languages Lecture 18 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
MB: 26 Feb 2001CS Lecture 11 Introduction Reading: Read Chapter 1 of Bratko Programming in Logic: Prolog.
1 09/03/04CS150 Introduction to Computer Science 1 What Data Do We Have.
Artificial Intelligence CS370D
12/14/2016CS150 Introduction to Computer Science 1 Announcements  Website is up!   All lecture slides, assignments,
Artificial Intelligence CIS 342 The College of Saint Rose David Goldschmidt, Ph.D.
For Friday No reading Prolog Handout 2. Homework.
Thinking about programming Intro to Computer Science CS1510 Dr. Sarah Diesburg.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Introduction to Logic Programming: Prolog Notes for CSCE 190 Based on Bratko,
Logic Programming Logic programming Candidates should be familiar with the concept of logic programming for declaring logical relationships.
1 Artificial Intelligence CS370D Prolog programming Introduction to Prolog.
Constants, Data Types and Variables
علمتني الثلوج أن أكون كبياض الثلج لا يحمل قلبي غير الحب والعطف والرحمة لا أسيئ الظن بالأخرين ولا أحكم عليهم من مظهرهم فإذا لم تعاشرهم فأنت تجهلهم !
INTRODUCTION TO C LANGUAGE
Thinking about programming
By P. S. Suryateja Asst. Professor, CSE Vishnu Institute of Technology
For Friday No reading Prolog handout 3 Chapter 9, exercises 9-11.
For Wednesday Read “lectures” 7-10 of Learn Prolog Now:
Variables and Primative Types
Prolog programming Introduction to Prolog
Thinking about programming
String Encodings and Penny Math
CS150 Introduction to Computer Science 1
Prolog programming Introduction to Prolog
Prolog programming Introduction to Prolog (part3)
CPSC 322 Introduction to Artificial Intelligence
Chapter Two: Syntax and Meaning of Prolog Programs
Prolog programming Introduction to Prolog (part4)
String Encodings and Penny Math
Understanding Variables
DATA TYPES AND OPERATIONS
Chapter 2: Prolog (Introduction and Basic Concepts)
Basic Programming Lab C.
Representations & Reasoning Systems (RRS) (2.2)
Truth tables.
Constants, Variables and Data Types
Presentation transcript:

Prolog programming Introduction to Prolog (part2) CS 370 – CS461

Data Objects The arguments of relation can be: Constant objects (such as bob and 12). General objects (such as X and Y). Structure objects ( such as date and time). data objects variables constants structures simple objects numbers atoms

Atoms Characters: Atoms can be constructed in three ways: Upper-case letter A, B,…, Z Lower-case letter a, b,…, z Digits 0,1,2,…,9 Special characters such as +-*/<>=:.&_~ Atoms can be constructed in three ways: Strings of letters, digits and the underscore character,’_’, starting with a lower case letter, such as : anna, x25, x_35AB, x___y, miss_Jones. Strings of special characters such as: <--->, ===>, …,::=,.:., (except :- ). Strings of characters enclosed in single quotes, such as: ‘Tom’, ‘South_America’, ‘Sarah Jones’.

Numbers and Variables Number Numbers used in Prolog include integer numbers and real numbers. Integer numbers: 1313, 0, -97 Real numbers: 3.14, -0.0035, 100.2 In symbolic computation, integers are often used. Variables are start with an upper-case letter or an underscore character. Examples: X, Result, _x23, _23

Questions in prolog. Another question can be asked in Prolog: pam tom bob liz ann pat jim Another question can be asked in Prolog: Who is Liz’s parent? ?- parent(X, liz). The answer here will not be true/false, rather, prolog will find the value of X. So the answer is : X= tom.

Class exercise(1) Who are bob’s children? pam tom bob liz ann pat jim

Class exercise(2) Who is parent of whom? pam tom bob liz ann pat jim

Questions in prolog. In prolog, we can ask more complicated questions such as: Who is a grandparent of jim? ?- parent(Y,jim) , parent( X,Y). The answer will be: Y = pat, X = bob. X Parent Y grandparent Parent jim

Class exercise(3) Who are Tom’s grandchildren?

Some important points A prolog program consists of clauses, each clause ends with a full stop. Questions in prolog consist of one or more goals. ?-parent(X,ann),parent(X,pat) . means the conjunctions of the goals: X is parent of ann , and X is parent of pat.

Homework Who is bob’s father? Who is bob’s sister? Formulate the following questions and find Prolog answers : Who is bob’s father? Who is bob’s sister? Do ann and pat have a common parents?