Friday, June 17, 2011

cs508 Assignment No:3 Solution Spring 2011


Q1: (a) How to define the list in PROLOG Language; also differentiate between facts and patterns?       [3]

Answer:

PROLOG Language:

Basically prolog language is based on predicate logics which use to said as it is closed to the world of assumptions and predictions, it use to cover up knowledge and data base control in the  language it does not support any  distinction between input and output usually PROLOG, since they add the possibility to have a structure that does not have a predefined number of such elements.

Welcome to the Prolog book. This book can serve as a textbook or tutorial for anyone who wants to learn the Prolog programming language. No prior programming experience is required. Some basic knowledge of logic can come in handy. For those new to the subject, a short introduction to logic is given, but this is not required reading.
The first chapters of the book (under Basics) describe the central syntax and features of the language. The next section, Programming, explores additional concepts that are useful when programming in Prolog. The chapters under Basics and Programming are meant to be read in order.




list in PROLOG Language:

According to the List it is basically a structure of the form [t1;t2;::::::::::::::::;tn] where every ti is a prolog term. The first term t1 is called the head of the list. The remaining part of the list, [t2; : : : ; tn] is called the tail. The empty list is denoted by [].


Difference  between facts and patterns

A fact is basically presently what it appears to be , a fact. A fact in everyday language is often a proposition like "It is sunny today'' or "It is summer.''
In Prolog such facts could be represented as follows:
'It is sunny today '.
'It is summer'.
A fact is analogous to a base case in a proof. It is a piece of information that is known and is a special case of a rule. Facts are also known as unconditional Horn Clauses. The general case of a Horn clause is:
P if Q1 and Q2 . . . and Qn
where a fact is simply P with no conditional statements Q1, Q2 . . . .
Facts are used to represent unchanging information about objects and their relationships.
Only facts in the PROLOG database can be used for problem solving.

Patterns:


Consider the following sentence : 'All men are mortal' We can express this thing in Prolog by :
     mortal(X) :- human(X).
The clause can be read as 'X is mortal if X is human'.





(b):  Why this symbol “|” is used in PROLOG language?      [3]

Answer:

The following vertical bar ‘|’ is used in prolog language to separate the head and tail of a list.
Example:
[1 | [2, 3] ]
[1, 2, 3 | [ ] ]




 (c): Write down the two types of Constant that can be defined in                                                         PROLOG language with example?          [4]

Answer:
There are two types of constants in Prolog
·         atoms
·         numbers.
Atoms:

Well there are four types of atom


a)      Alphanumeric atoms - alphabetic character sequence starting with a lower case letter. Examples: apple a1  apple_cart
b)      An atom is a general-purpose name with no inherent meaning. Examples of atoms include x, blue, 'Taco', and 'some atom'.
c)      Quoted atoms - sequence of characters surrounded by single quotes. Examples: ‘Apple’  ‘hello world’
d)     Symbolic atoms - sequence of symbolic characters. Examples: &  <  >  *  -  +  >>
e)      Special atoms. Examples: !  ;  [ ] {}

Numbers
Numbers can be floats or integers.
Well the numbers include integers and floating point numbers. Examples: 0  1  9821  -10  1.3   -1.3E102.



Q2: Write down the drawbacks of PROLOG language.   [5]

Answer:
Welcome to the Prolog book. This book can serve as a textbook or tutorial for anyone who wants to learn the Prolog programming language. No prior programming experience is required. Some basic knowledge of logic can come in handy. For those new to the subject, a short introduction to logic is given, but this is not required reading.
The first chapters of the book (under Basics) describe the central syntax and features of the language. The next section, Programming, explores additional concepts that are useful when programming in Prolog. The chapters under Basics and Programming are meant to be read in order.
The section Built-in Predicates deals with the functions available in many Prolog compilers. These and other chapters can be read in any order.
Prolog is a logical and a declarative programming language. The name itself, Prolog, is short for PROgramming in LOGic. Prolog's heritage includes the research on theorem provers and other automated deduction systems developed in the 1960s and 1970s.
Programming in Prolog is very different from programming in a traditional procedural language like Pascal where as prolog is the major example of a fourth generation programming language supporting the declarative programming paradigm.
Prolog consists of a series of rules and facts. A program is run by presenting some query and seeing if this can be proved against these known rules and facts. A programming language is a formal language for some form of problem solving. It is to be distinguished from design languages such as hardware description languages, and other descriptive languages such as document description languages (e.g. SGML and HTML) or grammars.


Well Prolog is a declarative programming language where we only specify what we need rather than how to do it. It has a simple concise syntax with built-in tree formation and backtracking which generates readable code which is easy to maintain.



No comments:

Post a Comment

Solution Available for following Subjects

BBA, B.Com & BS Assignments Discussion
BA All Subjects Assignment Discussion
ACC501 - Business Finance
CS001 - Computer Proficiency License
CS101 - Introduction to Computing
CS201 - Introduction to Programming
CS304 - Object Oriented Programming
ECO401 - Economics
ECO402 - Microeconomics
ECO403 - Macroeconomics
ENG101 - English Comprehension
ENG201 - Business and Technical English Writing
ENG301 - Business Communication
ETH201 - Ethics (for Non-Muslims)
ISL201 - Islamic Studies
IT430 - E-Commerce
MCM101 - Introduction to Mass Communication
MCM301 - Communication skills
MCM304 - Mass Media in Pakistan
MCM310 - Journalistic Writing
MGMT611 - Human Relations (alt. code=HRM611)
MGT101 - Financial Accounting
MGT111 - Introduction to Public Administration
MGT211 - Introduction To Business
MGT301 - Principles of Marketing
MGT401 - Financial Accounting II
MGT501 - Human Resource Management
MGT502 - Organizational Behaviour
MGT503 - Principles of Management
MGT603 - Strategic Management
MTH302 - Business Mathematics & Statistics
PAK301 - Pakistan Studies
STA301 - Statistics and Probability
PSY101 - Introduction to Psychology
PSY403 - Social Psychology
PSY502 - History & Systems of Psychology
SOC101 - Introduction to Sociology
B.Com All Subjects Assignment Discussion
ACC311 - Fundamentals of Auditing
ACC501 - Business Finance
CS101 - Introduction to Computing
ECO402 - Microeconomics
ECO403 - Macroeconomics
ENG101 - English Comprehension
ENG201 - Business and Technical English Writing
ETH201 - Ethics (for Non-Muslims)
FIN611 - Advanced Financial Accounting
FIN623 - Taxation Management
ISL201 - Islamic Studies
MCM301 - Communication skills
MGT101 - Financial Accounting
MGT211 - Introduction To Business
MGT401 - Financial Accounting II
MGT402 - Cost & Management Accounting
MGT411 - Money & Banking
MGT503 - Principles of Management
MGT611 - Business & Labor Law
MTH302 - Business Mathematics & Statistics
PAK301 - Pakistan Studies
STA301 - Statistics and Probability
B.Sc (Computer Science)
CS101 - Introduction to Computing
CS201 - Introduction to Programming
CS301 - Data Structures
CS302 - Digital Logic Design
CS304 - Object Oriented Programming
CS401 - Computer Architecture and Assembly Language Programming
CS403 - Database Management Systems
CS504 - Software Engineering - I
CS601 - Data Communication
CS610 - Computer Network)
ECO401 - Economics
ENG101 - English Comprehension
ENG201 - Business and Technical English Writing
ETH201 - Ethics (for Non-Muslims)
ISL201 - Islamic Studies
MGT101 - Financial Accounting
MGT301 - Principles of Marketing
MTH101 - Calculus And Analytical Geometry
MTH202 - Discrete Mathematics
MTH301 - Calculus II
MTH401 - Differential Equations
MTH501 - Linear Algebra
PAK301 - Pakistan Studies
PHY101 - Physics
PHY301 - Circuit Theory
STA301 - Statistics and Probability
BS Other subjects Assignments Discussion
MBA, MCS, MIT Assignment Discussion
MBA Compulsory/Required All Subjects
ACC501 - Business Finance
CS001 - VU-Computer Proficiency License
CS101 - Introduction to Computing
CS507 - Information Systems
ECO401 - Economics
ENG301 - Business Communication
MCM301 - Communication skills
MGT101 - Financial Accounting
MGT201 - Financial Management
MGT211 - Introduction To Business
MGT301 - Principles of Marketing
MGT401 - Financial Accounting II
MGT402 - Cost & Management Accounting
MGT411 - Money & Banking
MGT501 - Human Resource Management
MGT502 - Organizational Behaviour
MGT503 - Principles of Management
MGT510 - Total Quality Management (alt. code=MGMT510)
MGT601 - SME Management
MGT602 - Entrepreneurship
MGT603 - Strategic Management
MGT610 - Business Ethics
MGT613 - Production / Operations Management
MKT501 - Marketing Management
MTH001 - Elementary Mathematics
MTH302 - Business Mathematics & Statistics
STA301 - Statistics and Probability
STA630 - Research Methods
IT430 - E-Commerce
MBA All Specializations
Marketing Specialization
MKT610 - Customer Relationship Management
MKT621 - Advertising & Promotion
MKT624 - Brand Management
MKT630 - International Marketing
Finance Specialization
FIN621 - Financial Statement Analysis
FIN622 - Corporate Finance
FIN623 - Taxation Management
FIN630 - Investment Analysis & Portfolio Management
HRM Specialization
MGMT611 - Human Relations (alt. code=HRM611)
HRM624 - Conflict Management
HRM627 - Human Resource Development
MGMT628 - Organizational Development (alt. code=HRM628)
Information Technology Specialization
CS201 - Introduction to Programming
CS403 - Database Management Systems
CS610 - Computer Network
CS615 - Software Project Management
Management Specialization
MGMT623 - Leadership & Team Management (alt. code=HRM623)
MGMT625 - Change Management (alt. code=HRM625 )
MGMT629 - Crisis Management
MGMT630 - Knowledge Management
Banking Specialization
BNK601 - Banking Laws & Practices
BNK603 - Consumer Banking
MGT604 - Management of Financial Institutions (alt. code=BNK604)
FIN625 - Credit & Risk Management
MCS all Semesters Assignments Discussion
CS201 - Introduction to Programming
CS301 - Data Structures
CS302 - Digital Logic Design
CS304 - Object Oriented Programming
CS401 - Computer Architecture and Assembly Language Programming
CS402 - Theory of Automata
CS403 - Database Management Systems
CS501 - Advance Computer Architecture
CS502 - Fundamentals of Algorithms
CS504 - Software Engineering - I
CS506 - Web Design and Development
CS601 - Data Communication
CS604 - Operating Systems
CS605 - Software EngineeringII
CS607 - Artificial Intelligence
CS609 - System Programming
CS610 - Computer Network
CS614 - Data Warehousing
ENG201 - Business and Technical English Writing
MTH202 - Discrete Mathematics
MTH603 - Numerical Analysis
STA301 - Statistics and Probability
MIT All Semesters Subjects Assignments Discussion
CS201 - Introduction to Programming
CS301 - Data Structures
CS304 - Object Oriented Programming
CS401 - Computer Architecture and Assembly Language Programming
CS403 - Database Management Systems
CS408 - Human Computer Interaction
CS410 - Visual Programming
CS502 - Fundamentals of Algorithms
CS504 - Software Engineering - I
CS506 - Web Design and Development
CS601 - Data Communication
CS604 - Operating Systems
CS610 - Computer Network
CS614 - Data Warehousing
CS615 - Software Project Management
ENG201 - Business and Technical English Writing
MGT101 - Financial Accounting
MGT301 - Principles of Marketing
MGT501 - Human Resource Management
MGT502 - Organizational Behaviour
MGT503 - Principles of Management
MGT602 - Entrepreneurship
Proposals, Projects,Internship Reports and Past Papers
Sample Projects & Proposals
General Discussion About proposals & Project
InternShip Repots
Sample Internship Reports
Past & Current Papers
MID TERM Current Papers {May.-2011 Spring}
FINAL TERM Past Papers and pattern {Feb.-2011 Fall}
MID TERM Past Papers and pattern {Dec.-2010 Fall}
FINAL TERM Past Papers and pattern {Aug-2010 Spring}
MID TERM Past Papers and pattern {May-2010 Spring}
FINAL TERM Past Papers and pattern {Feb.-2010 Fall}
MID TERM Past Papers and pattern {Dec.-2009 Fall}
FINAL TERM Past Papers and pattern {JULY-2009 Spring}
MID TERM Past Papers and pattern {April-2009 Spring}
FINAL TERM Past Papers and pattern {Feb-2009 Fall}
MID TERM Past Papers and pattern {Dec.-2008 Fall}
Past Papers and Pattern {2004 to 2007}