Prolog
Prolog is a general purpose logic programming language associated with artificial intelligence and computational linguistics.
Prolog has its roots in formal logic, and unlike many other programming languages, Prolog is declarative: The program logic is expressed in terms of relations, represented as facts and rules. A computation is initiated by running a query over these relations.
The language was first conceived by a group around Alain Colmerauer in Marseille, France, in the early 1970s and the first Prolog system was developed in 1972 by Colmerauer with Philippe Roussel.
Prolog was one of the first logic programming languages, and remains among the most popular such languages today, with many free and commercial implementations available. While initially aimed at natural language processing, the language has since then stretched far into other areas like theorem proving, expert systems, games, automated answering systems, ontologies and sophisticated control systems. Modern Prolog environments support creating graphical user interfaces, as well as administrative and networked applications. (taken fromhttp://en.wikipedia.org/wiki/Prolog)
How to Install Prolog
- Firstly you need to run Prolog Installer
- Agree the Public License
- Choose the components you wish to install (just click next of you don't understand the use the components)
- Select the directory for installation
- Select the workspace directory, click Install
- Please wait for completing installation.
- When the installation is complete, click finished (It's easy right? ^_^ )
Basic concept : Facts and Rules
In any programming (in this context Prolog), we will always face problems that needs rules and facts to resolve it. Facts is the basic things to solve, and rules is about 'what to do from the facts' . For example:
food(hamburger).
food(pizza).
food(bread).
food(fried_chicken).
food(cookie).
drink(syrup).
drink(milk).
drink(tea).
(above is the facts)
beverages(X,Y):-food(X),drink(Y).
(above is the rules, it will shows all possible compositions of food and drink)
Exercise: Fact and Rules
- First, we need to make a workspace about rules and facts from notepad.
- Then we need to save it with .pl extension
- Open the Prolog program
- Click File, click Consult. Select the facts & rules file from the directory, Click Open.
- Type beverages(X,Y). and press ; for multiple times to see the results (to show the possible compositions about food and drink)
Thanks :)