0% found this document useful (0 votes)
88 views5 pages

Samara University: College of Engineering &technology Department of Computer Science

The document discusses procedural vs declarative programming. Procedural programming specifies step-by-step instructions to solve a problem, while declarative programming specifies what the results should be without describing how to achieve them. It provides examples of procedural languages like FORTRAN and declarative languages like Prolog. Expert systems are also discussed, which are computer systems that emulate human experts using knowledge bases and inference engines to solve complex problems.

Uploaded by

Teze Tade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views5 pages

Samara University: College of Engineering &technology Department of Computer Science

The document discusses procedural vs declarative programming. Procedural programming specifies step-by-step instructions to solve a problem, while declarative programming specifies what the results should be without describing how to achieve them. It provides examples of procedural languages like FORTRAN and declarative languages like Prolog. Expert systems are also discussed, which are computer systems that emulate human experts using knowledge bases and inference engines to solve complex problems.

Uploaded by

Teze Tade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

SAMARA UNIVERSITY

College of Engineering &Technology


Department of Computer Science

NAME ID SECTION

Tibebu Bekele 1101134 B

Course Title:Logic In Computer Science


Course Code:CoSc3141
Assignment:Individual

Year:3rd

Semester:2nd

Submit date 11/9/2013

1
1, Procedural vs Declarative Programming

procedural languages

In procedural languages, the program code is written as a sequence of instructions. User has to specify
“what to do” and also “how to do” (step by step procedure). These instructions are executed in the
sequential order. These instructions are written to solve specific problems.

Examples of Procedural languages:

FORTRAN, COBOL, ALGOL, BASIC, C and Pascal

Which executes code lines as directed, and a developer is fully in charge of the flow. Some repetitive
works might be automated within methods/tactics like OOP, AOP, etc., but at the end, it is a thing that
developer have to manage and configure regardless. This paradigm emphasizes on procedure in terms
of under lying machine model. There is no difference in between procedural and imperative approach. It
has the ability to reuse the code and it was boon at that time when it was in use because of its
reusability. Example:

#include <iostream>

using namespace std;

int main()

int i, fact = 1, num;

cout << "Enter any Number: ";

cin >> number;

for (i = 1; i <= num; i++) {

fact = fact * i;

Cout << "Factorial of " << num << " is: " << fact << endl;

Return 0;

2
Declarative programming language

Decla tive programming is a style of building the structure and elements of computer programs that
expresses the logic of a computation without describing its control flow¹. It is unfortunate that this kind
definitions don’t explain how both approach impact developers to their daily routine. It is divided as
Logic, Functional, Database. In computer science the declarative programming is a style of building
programs that expresses logic of computation without talking about its control flow. It often considers
programs as theories of some logic.It may simplify writing parallel programs. The focus is on what needs
to be done rather how it should be done basically emphasize on what code code is actually doing. It just
declare the result we want rather how it has be produced. This is the only difference between imperative
(how to do) and declarative (what to do) programming paradigms. Getting into deeper we would see logic,
functional and database.
In logical programming the main emphasize is on knowledge base and the problem. The execution of the
program is very much like proof of mathematical statement, e.g., Prolog

1. sum of two number in prolog:


2.
3. predicates
4. sumoftwonumber(integer, integer)
5. clauses
6.
7. Sum (0, 0).
8. sum(n, r):-
9. n1=n-1,
10. sum(n1, r1),

r=r1+n

Difference between Procedural and Declarative language:


Procedural Language Declarative Language

It is command-driven language. It is a function-driven language

It works through the mathematical


It works through the state of machine. functions.

Its semantics are quite tough. Its semantics are very simple.

It returns only restricted data types and allowed


values. It can return any data type or value

Overall efficiency is very high. Overall efficiency is low as compared to

3
Procedural Language.

Size of the program written in Procedural Size of the Declarative language


language is large. programs is small.

It is not suitable for time critical applications. It is suitable for time critical applications.

Iterative loops and Recursive calls both are used Recursive calls are used in declarative
in the Procedural languages. languages.

The main difference between two programming languages are, in procedural programming, we
tell the computer how to solve the problem and in declarative programming, we tell the
computer what problem we want solved.

In generally, both programming styles play significant roles while programming. In high-level
programming, especially, in data-driven applications, Declarative runtime may automate repetitive flow
along with simplifying code structure, and at the same time, imperative programming gives full control to
developer especially it is very important in low-level programming or mission-critical jobs. Clearly,
popularity of declarative and functional programming is arising, but as of today, imperative programming
including its libraries, tooling, etc. heavily dominates programming languages.

2, Expert Systems
An expert system is a computer system emulating the decision-making ability of a human expert. Expert
systems are designed to solve complex problems by reasoning through bodies of knowledge, represented
mainly as if–then rules rather than through conventional procedural code Expert systems are computer
applications which embody some non-algorithmic expertise for solving certain types of problems. For
example, expert systems are used in diagnostic applications servicing both people and machinery. They
also play chess, make financial planning decisions, configure computers, monitor real time systems,

4
underwrite insurance policies, and perform many other services which previously required human

expertise.

• Knowledge base – a declarative representation of the expertise, often in IF THEN rules;

• Working storage – the data that is specific to a problem being solved;

• Inference engine – the code at the core of the system, which derives recommendations from the
knowledge base and problem-specific data in working storage;

• User interface – the code that controls the dialog between the user and the system. To understand expert
system design, it is also necessary to understand the major roles of individuals who interact with the
system. These are:

• Domain expert – the individual or individuals who currently are experts solving the problems the system
is intended to solve;

• Knowledge engineer – the individual who encodes the expert's knowledge in a declarative form that can
be used by the expert system;

• User – the individual who will be consulting with the system to get advice that would have been
provided by the domain expert. Many expert systems are built with products called expert system shells.
The shell is a piece of software which contains the user interface, a format for declarative knowledge in
the knowledge base, and an inference engine. The knowledge engineer uses the shell to build a system for
a particular problem domain. Expert systems are also built with shells that are custom developed for
particular applications. In this case there is another key individual.

• System engineer – the individual who builds the user interface, designs the declarative

format of the knowledge base, and implements the inference engine.

You might also like