What are the various programming paradigms
I’ve used so far?
2 CSED Computational Intelligence
February 26, 2013
PROGRAMMING PARADIGMS
Imperative
Procedural Declarative Functional LISt Processing C, Pascal
Logical
Object Oriented
PROgramming in LOGic
C++
3 CSED Computational Intelligence
February 26, 2013
PROLOG :: COMPONENTS
FACTS
RULES QUESTIONS/QUERIES
4 CSED Computational Intelligence
February 26, 2013
PROLOG :: COMPONENTS :: FACTS attacks (tom, jerry) relationship object_1 object_2
; round(earth) relationship object
The names of relationship and objects start with lowercase letters.
The relationship should be written first and the objects should be separated by commas.
5 CSED Computational Intelligence
February 26, 2013
PROLOG :: COMPONENTS :: FACTS example_01 : Directed Graph edge (a, b). edge (a, e). edge (b, d).
edge (b, c). edge (c, a). edge (e, b).
6 CSED Computational Intelligence
February 26, 2013
PROLOG :: COMPONENTS :: RULES
Rule is a general way to say when a predicate is true.
With rules we can state that a predicate is true,
provided that other predicates are true. example: a :- b, c, d. {a is true if b, c, d are true} a :- b, c, d. b. c. d :- e e. example_01 : Directed Graph :: Rule for “Path of length two” tedge(Node1, Node2) :- edge (Node1, X), edge (X, Node2).
7 CSED Computational Intelligence
February 26, 2013
PROLOG :: COMPONENTS :: QUESTIONS
Look for FACTS from database
?- attacks (tom, jerry). ?- edge (a, b).
True or False
8 CSED Computational Intelligence
February 26, 2013
SWI PROLOG :: INSTALL & COMPILE
1) Download SWI Prolog: http://www.swi-prolog.org/download/devel 2) Create a new file with an extension .pl :
3) Write a sample Prolog program and save the file as test01.pl 4) To compile the program type the following in the prompt: ?- [test01].
(don’t