Free Essay

Prolog Programming, Chapter 2

In:

Submitted By JunElysa
Words 286
Pages 2
1. Change the following logical statement into Prolog rule.
For all X, X is a large animal if X is large, X is a bear, and X is brown.

1.ans: largeAnimal(X) :- large(X), bear(X), brown(X).

2. Consider the following clauses in the KB (occupation.pl): person(aaron, male, 37). person(soraya, female, 37). person(matin, male, 38). occupation(aaron, doctor). occupation(soraya, doctor). occupation(matin, manager).
a) Extend the KB to include the following logical statement in Prolog rule.
For all Q, Q is a male doctor if there is Q with some R such that R is a male and that Q's occupation is a doctor.
b) Provide an example of a query to illustrate your answer for Question 2a.

2. a) maleDoctor(Q) :- person(Q, R,_) ,occupational(Q, doctor), R=male. b) ?-maleDoctor(Q) Q=Aaron.

3. Write a Prolog program called family.pl which contains information about family of three generations as shown below.
Define the following relations using rules in Prolog.
a. father
b. mother
c. sister
d. aunty
e. cousin 3. female(lin). female(patricia). female(sarah). female(dora). female(betty).

male(tom). male(max). male(david). male(jim). parentsOf(tom,patricia). parentsOf(tom,sarah). parentsOf(tom,max). parentsOf(lin,patricia). parentsOf(lin,sarah). parentsOf(lin,max). parentsOf(jim,james). parentsOf(patricia,james). parentsOf(david,dora). parentsOf(david,betty). parentsOf(sarah,dora). parentsOf(sarah,betty). Rules: father(X,Y) :- parentsOf(X,Y) , male(X). mother(X,Y) :- parentsOf(X,Y) , female(X). sister(X,Y):- parentsOf(Z,X), parentsOf(Z,Y), female(X), male(Z), X \=Z. aunty(X,Y):- mother(Z,Y), sister(X,Z). cousin(X,Y):- aunty(W,X), mother(W,Y).

Similar Documents

Free Essay

Management Lessons from Mayo Clinic

...PRINCIPLES OF PROGRAMMING LANGAUAGES Sub Code: IA Marks: Hrs/Week: 04 Exam Hours: 03 Total Hrs: 42 Exam Marks: 100 UNIT I 1. Introduction 4 Hrs Toward higher level languages, Programming paradigms, Language implementation: Bridging the gap, Expression notations, Abstract syntax trees. 2. Types : Data Representation 6 Hrs Elementary data types – Data objects, Variables and Constants, Data types, Declarations, Type checking and type conversion. Numeric data types, Enumerations, Booleans, characters. Structural data types- Structured data objects and data types, Specification of data structure types, Implementation of data structure types, Vectors and arrays, Records, Type equivalence. UNIT II 3. Imperative Programming 6 Hrs Basic statements, Structured sequence control, Handling special cases in loops, Programming with invariants, Proof rules for partial correctness. Procedure activations – simple call-return subprograms, Parameter passing methods, Scope rules for names...

Words: 403 - Pages: 2

Free Essay

Seven Languages in Seven Weeks

... Venkat Subramaniam Award-winning author and founder, Agile Developer, Inc. As a programmer, the importance of being exposed to new programming languages, paradigms, and techniques cannot be overstated. This book does a marvelous job of introducing seven important and diverse languages in a concise—but nontrivial—manner, revealing their strengths and reasons for being. This book is akin to a dim-sum buffet for any programmer who is interested in exploring new horizons or evaluating emerging languages before committing to studying one in particular. Antonio Cangiano Software engineer and technical evangelist, IBM Fasten your seat belts, because you are in for a fast-paced journey. This book is packed with programming-language-learning action. Bruce puts it all on the line, and the result is an engaging, rewarding book that passionate programmers will thoroughly enjoy. If you love learning new languages, if you want to challenge your mind, if you want to take your programming skills to the next level—this book is for you. You will not be disappointed. Frederic Daoud Author, Stripes ...and Java Web Development Is Fun Again and Getting Started with Apache Click Prepared exclusively for Montelymard Do you want seven kick starts into learning your “language of the year”? Do you want your thinking challenged about programming in general? Look no further than this book. I personally was taken back in time to my...

Words: 85787 - Pages: 344

Free Essay

Concepts of Programming Language Solutions

...Concepts of Programming Languages Tenth Edition R.W. Sebesta ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. Preface Changes for the Tenth Edition T he goals, overall structure, and approach of this tenth edition of Concepts of Programming Languages remain the same as those of the nine earlier editions. The principal goals are to introduce the main constructs of contemporary programming languages and to provide the reader with the tools necessary for the critical evaluation of existing and future programming languages. A secondary goal is to prepare the reader for the study of compiler design, by providing an indepth discussion of programming language structures, presenting a formal method of describing syntax and introducing approaches to lexical and syntatic analysis. The tenth edition evolved from the ninth through several different kinds of changes. To maintain the currency of the material, some of the discussion of older programming languages has been removed. For example, the description of COBOL’s record operations was removed from Chapter 6 and that of Fortran’s Do statement was removed from Chapter 8. Likewise, the description of Ada’s generic subprograms was removed from Chapter 9 and the discussion of Ada’s asynchronous message passing was removed from Chapter 13. On the other hand, a section on closures, a section on calling subprograms indirectly, and a section on generic functions in F# were added to Chapter 9; sections on...

Words: 7025 - Pages: 29

Premium Essay

Computer Programming

...THE INTEGRATION OF BASIC COMPUTER PROGRAMMING IN 5TH & 6TH GRADE OF SILLIMAN UNIVERSITY Management 35: Business Research 1st Semester School Year 2014-2015 TABLE OF CONTENTS Title Page Table of Contents Lists of Charts Lists of Tables CHAPTER 1 THE PROBLEM AND ITS SCOPE Introduction Theoretical Background: I. It will promote computer literacy. A. Computer literacy definition 1. Dictionary definition 2. Operational definition B. Importance of computer literacy 1. Home 2. School 3. Work place C. Applications of computer literacy 1. Home 2. School 3. Work place II. A suitable precursor to advance programming. A. Fundamentals of computer programming 1. Programming languages 2. Application programs B. Relevance to Higher levels of programming 1. Scope of learning 2. Applied learnings C. Relevance to Higher educational levels 1. Theoretical background for computer courses 2. Supplementary learnings III. An asset to latent employment opportunities. A. Improved skill-sets 1. Programming skills 2. Analytical skills 3. Mathematical skills B. Relevance to fields of work C. Real life applications The Problem Statement of the Problem Objectives Significance of the study Scope of the Study Definition of terms Research Methodology Research environment Respondents of the Study Sampling Techniques Research Instruments Data Collection Procedures ...

Words: 3374 - Pages: 14

Free Essay

Weerttghh

...Chapter 2 An Overview of Formal Methods Tools and Techniques The goal of this chapter is to give an overview of the different approaches and tools pertaining to formal methods. We do not attempt to be exhaustive, but focus instead on the main approaches. After reading the chapter the reader will be familiar with the terminology of the area, as well as with the most important concepts and techniques. Moreover the chapter will allow the reader to contextualise and put into perspective the topics that are covered in detail in the book. Why do we need an overview of formal methods? Why not just study one rigorous method for software development? This is a very pertinent and legitimate question. The behavioural essence of software is not captured by a unique unified mathematical theory. Such a general foundation is unlikely to exist. Think for instance about the diversity of programming language paradigms and theories, and the resulting jungle of existing computer programming languages. Is there a definite paradigm (or, even, language) that makes obsolete all the other ones? Clearly not. Different languages will be chosen by different people to solve the same problem, and someone may well use different languages to solve different problems. Similarly, depending on the goals of the software designers and of the verification process, one may prefer a theory over another one, and even use more than one theory (and related formal methods techniques and tools), in the context of the development...

Words: 13418 - Pages: 54

Free Essay

Retrieving Similar Buggy Prolog Programs Using Medd's Student Model

...Chapter 1 INTRODUCTION 1.1 Background of the Study It has been said that modeling the learner is the central aspect of intelligent tutoring systems. This realization spurred the development of student modeling systems or systems that diagnose student errors. These systems proved to be effective in areas like mathematics (subtraction, highschool algebra, differentiation) and computer programming (Pascal, Lisp,C++). The essential elements in constructing a student model are the background knowledge and the student behavior. The first component which is the background knowledge is difficult to acquire automatically and to extend, and in fact one of the major bottlenecks in the development of student modeling systems. The difficulty lies in constructing the bug library, which is the collection of common errors made by the students in a particular domain (Sison,1998). This implies that the background knowledge is a critical component in student modeling construction. Indeed, few systems are able to construct and extend bug libraries. The second component, which is the student behavior can be classified as simple and complex (Sison, 1998). Simple behavior involves classification and complex behavior involves problem solving task. Traditionally, in domains wherein the student behavior is simple (subtraction), student modeling systems used multiple behaviors as the primary input. This is known as synthetic student modeling. One drawback of this is that, the modeling system might construct...

Words: 17544 - Pages: 71

Premium Essay

Oop Intruduction

...except by subscribing to the organization and classification of data which the agreement decrees.” Benjamin Lee Whorf (1897-1941) The genesis of the computer revolution was in a machine. The genesis of our programming languages thus tends to look like that machine. But computers are not so much machines as they are mind amplification tools (“bicycles for the mind,” as Steve Jobs is fond of saying) and a different kind of expressive medium. As a result, the tools are beginning to look less like machines and more like parts of our minds, and also like other forms of expression such as writing, painting, sculpture, animation, and filmmaking. Object-oriented programming (OOP) is part of this movement toward using the computer as an expressive medium. This chapter will introduce you to the basic concepts of OOP, including an overview of development methods. This chapter, and this book, assumes that you have some programming experience, although not necessarily in C. If you think you need more preparation in programming before tackling this book, you should work through the Thinking in C multimedia seminar, downloadable from www.MindView.net. This chapter is background and supplementary material. Many people do not feel comfortable wading into object-oriented programming without understanding the big picture first. Thus, there are many concepts that are introduced here to give you a solid overview of OOP. However, other people may not get the big picture concepts until they’ve...

Words: 2752 - Pages: 12

Premium Essay

Software Engineering

...Introduction to Software Engineering Somnuk Keretho, Assistant Professor Department of Computer Engineering Faculty of Engineering, Kasetsart University Email: sk@nontri.ku.ac.th URL: http://www.cpe.ku.ac.th/~sk Somnuk Keretho/Kasetsart University Outline of this presentation • • • • • • Scope of Software Engineering Object-Oriented Software Development Software Process Software Life-Cycle Models Object Orientation Software Quality Assessment Reference to Chapter 1/2/3 of “Software Engineering with JAVA”, S.R. Schach, McGraw-Hill, 1997. Somnuk Keretho/Kasetsart University 2 Scope of Software Engineering • Software engineering is a discipline whose aim is the production of fault-free software, that is delivered on time, within budget, and satisfies the user’s needs. Somnuk Keretho/Kasetsart University 3 Scope of Software Engineering • Historical Aspects: – 1967, a NATO group coined the term “Software Engineering” – 1968 NATO Software Engineering Conference concurred that “Software production should be an engineering-like activity”. – Using philosophies and paradigms of established engineering disciplines to solve “Software Crisis: that the quality of software was generally unacceptably low and that deadlines and cost limits were not being met”. Somnuk Keretho/Kasetsart University 4 Scope of Software Engineering • Economic Aspects – Software Engineering v.s. Computer Science • The computer scientist investigates...

Words: 1590 - Pages: 7

Premium Essay

Essay

...For Exercises 1- 10 , match the activity with the phase of the object-oriented methodology. A. Brainstorming B. Filtering C. Scenarios D. Responsibility algorithms |1. |Reviewing a list of possible classes, looking for duplicates or missing classes. | | |B | |2. |Asking "what if" questions. | | |C | |3. |Assigning responsibilities to classes. | | |C | |4. |Generating first approximation to the list of classes in a problem. | | |A | |5. |Assigning collaborators to a responsibility. | | |C ...

Words: 2569 - Pages: 11

Free Essay

Concepts of Programming Languages

...CONCEPTS OF PROGRAMMING LANGUAGES TENTH EDITION This page intentionally left blank CONCEPTS OF PROGRAMMING LANGUAGES TENTH EDITION R O B E RT W. S EB ES TA University of Colorado at Colorado Springs Boston Columbus Indianapolis New York San Francisco Upper Saddle River Amsterdam Cape Town Dubai London Madrid Milan Munich Paris Montreal Toronto Delhi Mexico City Sao Paulo Sydney Hong Kong Seoul Singapore Taipei Tokyo Vice President and Editorial Director, ECS: Marcia Horton Editor in Chief: Michael Hirsch Executive Editor: Matt Goldstein Editorial Assistant: Chelsea Kharakozova Vice President Marketing: Patrice Jones Marketing Manager: Yez Alayan Marketing Coordinator: Kathryn Ferranti Marketing Assistant: Emma Snider Vice President and Director of Production: Vince O’Brien Managing Editor: Jeff Holcomb Senior Production Project Manager: Marilyn Lloyd Manufacturing Manager: Nick Sklitsis Operations Specialist: Lisa McDowell Cover Designer: Anthony Gemmellaro Text Designer: Gillian Hall Cover Image: Mountain near Pisac, Peru; Photo by author Media Editor: Dan Sandin Full-Service Vendor: Laserwords Project Management: Gillian Hall Printer/Binder: Courier Westford Cover Printer: Lehigh-Phoenix Color This book was composed in InDesign. Basal font is Janson Text. Display font is ITC Franklin Gothic. Copyright © 2012, 2010, 2008, 2006, 2004 by Pearson Education, Inc., publishing as Addison-Wesley. All rights reserved. Manufactured in the United States...

Words: 142253 - Pages: 570

Free Essay

Student

...CONCEPTS OF PROGRAMMING LANGUAGES TENTH EDITION This page intentionally left blank CONCEPTS OF PROGRAMMING LANGUAGES TENTH EDITION R OB E RT W. S EB ES TA University of Colorado at Colorado Springs Boston Columbus Indianapolis New York San Francisco Upper Saddle River Amsterdam Cape Town Dubai London Madrid Milan Munich Paris Montreal Toronto Delhi Mexico City Sao Paulo Sydney Hong Kong Seoul Singapore Taipei Tokyo Vice President and Editorial Director, ECS: Marcia Horton Editor in Chief: Michael Hirsch Executive Editor: Matt Goldstein Editorial Assistant: Chelsea Kharakozova Vice President Marketing: Patrice Jones Marketing Manager: Yez Alayan Marketing Coordinator: Kathryn Ferranti Marketing Assistant: Emma Snider Vice President and Director of Production: Vince O’Brien Managing Editor: Jeff Holcomb Senior Production Project Manager: Marilyn Lloyd Manufacturing Manager: Nick Sklitsis Operations Specialist: Lisa McDowell Cover Designer: Anthony Gemmellaro Text Designer: Gillian Hall Cover Image: Mountain near Pisac, Peru; Photo by author Media Editor: Dan Sandin Full-Service Vendor: Laserwords Project Management: Gillian Hall Printer/Binder: Courier Westford Cover Printer: Lehigh-Phoenix Color This book was composed in InDesign. Basal font is Janson Text. Display font is ITC Franklin Gothic. Copyright © 2012, 2010, 2008, 2006, 2004 by Pearson Education, Inc., publishing as Addison-Wesley. All rights reserved. Manufactured...

Words: 142312 - Pages: 570

Free Essay

Forex Analyst

...ANALYSIS OF PROGRAMMING LANGUAGE PARADIGMN BY GROUP 4 (M. Sc.) CSC 801 PROGRAMMING LANGUAGE PARADIGMNS TERM PAPER SUBMITTED TO THE DEPARTMENT OF COMPUTER SCIENCE, UNIVERSITY OF LAGOS, AKOKA June, 2015. ABSTRACT This is a survey on the programming languages paradigm: Imperative, Scripting, logic, Functional, object oriented and Markup. Our survey work involves a comparative study of these six programming languages with respect to the above programming paradigm using the following criteria: secure programming practices, web application development, OOP-based abstractions, reflection, Reusability, Portability, Reliability, Readability, Availability of compilers and tools, Familiarity, Expressiveness We study these languages in the context of the above mentioned criteria and the level of support they provide for each one of them. TABLE OF CONTENT 1. OVERVIEW OF PROGRAMMING LANGUAGE PARADIGMS 1.1 INTRODUCTION 1.2 CRITERIA OF LANGUAGE COMPARISON 2. IMPERATIVE LANGUAGES 2.1 Imperative Paradigm 2.1.2 Java as an Imperative Paradigm 2.1.3 Criteria 3. SCRIPTING LANGUAGES 3.1 Scripting Paradigm 3.2 Php as an Scripting Paradigm 3.3 Criteria 4. FUNCTIONAL LANGUAGES 4.1 Functional Paradigm 3.2 Php as an Scripting Paradigm 3.3 Criteria 5.1 LOGIC LANGUAGES 5.1.1 Readability 5.1.2 Ease of Learning 5.1.3 Ease of Maintenance 5.1.4 Extensibility 5.1.5 Pedagogy 5.1.6 Portability 6.1 OBJECT ORIENTED LANGUAGES (OOL) 6.1.1 Readability 6.1.2 Ease of Learning 6.1.3 Ease...

Words: 4013 - Pages: 17

Free Essay

Lan Based Examination

...CHAPTER 1 INTRODUCTION Nowadays the telecommunication technologies become wider and more new features exist to make human life better. These help people to communicate with eachother easier than before. People can communicate by many ways. For this new era, people are most using the wireless technology system to communicate with each other.Wireless technology is known that the communication system is not used the wire. Thistechnology and services have undergone a huge development since the first cellular andcordless telephone systems were introduced in 1980s.The first generation of cellularphone was based on analog FM technology. This generation only has voice serviceonly.Second generation cellular phone next were introduced in the early 1990.Thisgeneration use the digital modulation and have an improvement on spectral efficiencyas well as voice quality. However this second generation still uses the same features asfirst generation technologies According to an investigate by ABI Research, at the end of 2013, 1.4 billion smart phones has been in use: 798 million of them run Android, 294 million run Apple’s iOS, and 45 million run Windows Phone. Smart phone usually support one or more short range wireless technologies such as Bluetooth and infrared, making it possible to transfer data via these wireless connections. Smart phone can provide computer mobility, ubiquitous data access, and pervasive intelligence for almost every aspect of business processes and people’s daily...

Words: 4403 - Pages: 18

Free Essay

Information System

...RISC-Linz, Johannes Kepler University, A-4040 Linz, Austria email: Gabor.Bodnar@risc.uni-linz.ac.at www: http://www.risc.uni-linz.ac.at/people/gbodnar January 23, 2005 2 Contents 0 Introduction 0.1 Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 0.2 Information Sources . . . . . . . . . . . . . . . . . . . . . . . . . 1 Data Modeling 1.1 Introduction . . . . . . . . . . . . . . . . . 1.2 The Entity-Relationship Model . . . . . . 1.2.1 Entities, Attributes, Relationships 1.2.2 Classification of Relationships . . . 1.2.3 Keys . . . . . . . . . . . . . . . . . 1.2.4 Entity-Relationship Diagrams . . . 1.2.5 Entity-Relationship Design . . . . 1.2.6 Exercises . . . . . . . . . . . . . . 1.3 The Relational Model . . . . . . . . . . . 1.3.1 Relational Structure . . . . . . . . 1.3.2 Relational Algebra . . . . . . . . . 1.3.3 Functional Dependencies . . . . . . 1.3.4 Normal forms . . . . . . . . . . . . 1.3.5 Indexing and Hashing . . . . . . . 1.3.6 Exercises . . . . . . . . . . . . . . 1.4 SQL . . . . . . . . . . . . . . . . . . . . . 1.4.1 Data Definition . . . . . . . . . . . 1.4.2 Simple Queries . . . . . . . . . . . 1.4.3 Database Modification . . . . . . . 1.4.4 Views and Joins . . . . . . . . . . 1.4.5 Embedded SQL . . . . . . . . . . . 1.4.6 Exercises . . . . . . . . . . . . . . 2 Information Systems On-Line 2.1 On-Line Databases . . . . . . . . . . . 2.1.1 Security Control . . . . . . . . 2.1.2 Transaction Management . . . 2.1.3 Static Archives . ....

Words: 18634 - Pages: 75

Premium Essay

Rm Avakjll

...Fundamentals of Database Systems, 6th Edition, Addison-Wesley, 2010. 2 Preface This laboratory manual accompanies the popular database textbook Elmasri and Navathe, Fundamentals of Database Systems, 6th Edition, Addison-Wesley, 2010. It provides supplemental materials to enhance the practical coverage of concepts in an introductory database systems course. The material presented in this laboratory manual complement many of the chapters of the Elmasri/Navathe text typically covered in most introductory database systems courses. Chapter Mappings The laboratory manual consists of 8 chapters and the following table shows the mapping to the chapters in the Elmasri/Navathe textbook: Laboratory Manual Chapter Elmasri/Navathe 6th Edition Chapter(s) Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapters 7, 8, and 9 Chapters 3, 6, and 26 Chapters 4, 5, and 13 Chapters 4, 5, and 14 Chapters 15 and 16 Chapter 11 Chapter 12 Chapters 13 and 14 Chapter 1 presents ERWin, a popular data modeling software that allows database designers to represent Entity-Relationship diagrams and automatically generate relational SQL code to create the database in one of several commercial relational database management systems such as Oracle or Microsoft SQLServer. The material presented in this chapter is tutorial in nature and covers the COMPANY database design of the Elmasri/Navathe text in detail. Chapter 2 presents three interpreters that can be used to execute queries...

Words: 18417 - Pages: 74