Sem 7‎ > ‎AI‎ > ‎

0 Intro

posted Aug 5, 2013, 11:40 PM by Neil Mathew   [ updated Aug 6, 2013, 12:01 AM ]
To transform an English sentence to Predicate Logic, we remove unnecessary terms.
This leaves only the relationship and the entities involved, known as arguments.

Predicate Logic
Ex:  A pie is good   =   good(pie)
The relation is ‘good’, the relation’s argument is ‘pie’.

Prolog Rules
To infer facts from other facts, Prolog uses Rules. 
Ex:  Bill likes cars if they are red =          
      likes(bill, cars):- red(cars).

By the way, in prolog, ‘:-’ is pronounced ‘if’.

Prolog Queries
 We may want to ask, “What does ali like?”
In Prolog syntax, we ask:  
likes(ali,What).  
Note: capital W on what

Examples:
a_kind_of(aa,ship).
a_kind_of(bb,ship).

part_of(aa,jordanian_navy).
part_of(bb,jordanian_navy).

part_of(jordanian_navy,jordanian_government). a_kind_of(jordanian_government,government).

color(ship,red). a_kind_of(aa,ship). 

a_kind_of(bb,ship).

part_of(aa,jordanian_navy).
part_of(bb,jordanian_navy).
part_of(jordanian_navy,jordanian_government). 

a_kind_of(jordanian_government,government).
color(ship,red).



Parts of a Prolog Program

All programs written in Prolog contain at least 4 parts:
  • DOMAINS 
  • PREDICATES 
  • CLAUSES 
  • GOALS 

Domains:

The section of code where we define the legal values for any type that is not defined as a standard type.  

Predicates:

The predicate section is where we define predicates to be used in the CLAUSES section and define the domains for their arguments. 

Symbolic name of a relation
We found it best to think of predicate declarations as function prototypes
Ex:  age(string, integer)

Clauses:
Clauses are the heart of the program.
A clause is an instance of a predicate, followed by a period.
Clauses are of two types:
  • Facts
  • Rules

>> Facts:
Facts in the CLAUSE section are relations that are known to be true by the programmer. A property of an object or a relation between objects. 
Ex: red(car)

>> Rules:
Used to infer other facts. Property or relation known given the fact that some other set of relations are known.

Ex: Jane can eat food if it is a vegetable on the doctor’s list.
Can_eat(jane, X):- food(X), vegetable(X), doc_list(X).

Goals:
Part of program where queries are made.
Can be singular or compound.

Each part of a compound goal is known as a subgoal. 
To satisfy a compound goal (or query) each subgoal must itself be satisfied by the system

Ex:  What are the things do Bill and Cindy both like (in common)?
In Prolog:
likes(bill, What), likes(cindy, What).


Attached a ppt with more information on the AI page.

Comments