Download prolog - Electronics and Computer Science

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Enactivism wikipedia , lookup

Speech synthesis wikipedia , lookup

AI winter wikipedia , lookup

Ecological interface design wikipedia , lookup

Computer vision wikipedia , lookup

Computer Go wikipedia , lookup

Intelligence explosion wikipedia , lookup

Human–computer interaction wikipedia , lookup

Existential risk from artificial general intelligence wikipedia , lookup

Personal knowledge base wikipedia , lookup

Ethics of artificial intelligence wikipedia , lookup

Logic programming wikipedia , lookup

Embodied cognitive science wikipedia , lookup

Philosophy of artificial intelligence wikipedia , lookup

History of artificial intelligence wikipedia , lookup

Knowledge representation and reasoning wikipedia , lookup

Transcript
Aspects of Artificial Intelligence
Paul Lewis
What is AI?
• One definition
-the application of computers to areas normally
regarded as requiring human intelligence
Some dictionary games
• Intelligence: quickness of understanding
• Understanding: ability to perceive the meaning
• Meaning: that which is intended to be conveyed
• Intelligence is quickness of ability to perceive that
which is intended to be conveyed !!
Are these intelligent?
• a simple calculator
• a program to find a path through a network
• a system which 'sees' a component and controls a
robot arm to build it into an assembly
Yes/No--- some say AI is the study of how to make
computers do things which at the moment humans
are better!!!!!
If a computer can do it, it isn't AI
Another definition
• AI is the study of computations that make it
possible to
- perceive
- reason
- act
AI
• AI is concerned with modelling both the activities
of the brain and the functions of other parts of
human beings
• brain -> recall and reasoning
• ears -> speech recognition
• mouth -> speech synthesis
• eyes-> vision
• arms and legs -> robotics
AI is multidisciplinary!
Interested parties
• Computer scientists, mathematicians and
electronic engineers - to build more useful
systems
• Psychologists, neurophysiologists and
philosophers - to understand (using computer
models) the principles which make intelligence
possible
• NB AI is still very much a research area.
Strong vs Weak AI
• Will it ever be possible to build a complete computer model of the
human brain (mind) ?
• Would such a model actually understand the meaning of anything?
Would it be conscious and self conscious or are these mental qualities
peculiar to humans?
• The strong view says:
the brain is a very complicated information processing machine .
Consciousness, understanding etc are by-products of the complicated
symbol manipulation. We will be able to model it.
• The weak view says:
it will not be possible to model all the properties of the human brain
Central Issues in AI
•
•
•
•
•
•
Knowledge representation
Reasoning and control
Learning (Knowledge acquisition)
Handling uncertainty
Forming plans
Vision (object recognition, motion and video analysis,
scene understanding)
• Speech (recognition, synthesis, story comprehension)
Knowledge Representation
•
•
•
•
Symbolic verses sub symbolic
cf your brain.
Conscious processing tends to be symbolic
Low level activity is electrochemical…
sub-symbolic
Rules for knowledge Representation
RULES
• IF a person P complains of symptom S
AND drug D relieves symptom S
THEN person P should take drug D
FACTS
GLOBAL
aspirin relieves headache
LOCAL
john complains of headache
REASONING with RULES
• involves forward and backward chaining through
rules
• forward: data driven
• backward: goal driven
Knowledge Rep: Semantic Nets
Semantic Nets
Knowledge Rep: Semantic Nets
• nodes are objects or concepts
• arcs are relations
• Reasoning involves graph search and graph subgraph matching
Typical AI Applications
• Expert Systems
medical diagnosis
legal systems
financial advisors
fault diagnosis
• Intelligent software agents
personalised information retrieval agents
financial agents (automated share dealing)
• Robotics
automated assembly
autonomous vehicles
Typical AI Applications (cont)
• Speech systems
telephone answering systems
(use speech recognition and speech synthesis|)
• Vision systems
industrial inspection
robot guidance
medical image analysis
remotely sensed image analysis
PROLOG
A Symbolic Approach to AI
Paul Lewis
Logic and Computer-Based
Reasoning
Logic - invented by the Greeks to formalise reasoning
• How to spot false arguments
• How to put sound arguments
• How to INFER
Mathematical Logic
• Propositional Calculus
A^B C
• Predicate Calculus
complains_of(P,S) ^ relieves(D,S) ^ ¬ unsuitable_for(D,P)
 should_take(P,D)
PROLOG
• PROgramming in LOGic
• A declarative programming language
(cf imperative languages like Basic, Pascal, C)
• Based on the predicate calculus
• Developed in about 1970 by Alain Colmerauer
• Uses resolution, a general rule of inference
Programming in PROLOG
• Involves declaring facts and rules about objects and their
relationships (predicates) by placing them in a computer
file (the knowledge base)
• Then asking questions of the knowledge base
(i.e. asking PROLOG to satisfy goals)
• PROLOG uses its own built in reasoning mechanism to do
this
• PROLOG programs are backward chaining (goal driven)
rule-based systems
Facts and Rules in Prolog
Facts and rules are expressed as clauses in Prolog.
plays(john,football).
designed to mean “john plays football”
The interpretation is defined by the writer.
parent(jim, jack).
“Jim is the parent of jack”
Constants begin with lowercase, variables with upper case.
Rules have a head and a body e.g head:-body. If the body can
be shown to be true, the head is true. body  head.
older_than(X,Y) :age_of(X,AX),
age_of(Y,AY),
AX > AY.
A small PROLOG Knowledge
Base
male(john).
/* john is male */
?- consult(knowledgebase).
male(paul).
yes
?- male(john).
female(emma).
yes
/* emma is female */
?- female(paul).
female(cath).
likes(paul,cycling).
/* paul likes cycling */
no
?- likes(paul,Y).
Y=cycling
more(y/n) y
no
likes(cath,cycling).
?- likes(john,Something).
likes(john,X) :- female(x),likes(X,cycling).
Something=cath
more(y/n) y
/* john likes X if X is female and X likes
cycling */
no
?-
Recursion in Prolog
parent(bill,fred).
/* bill is a parent of fred */
parent(jack,bill).
parent(jim,jack).
ancestor(X, Y) :- parent(X,Y).
ancestor(X,Y) :- parent(Z,Y), ancestor(X,Z).
------------------------------------------------------?- ancestor(jim,fred).
yes
?-
Lists in Prolog
A list consists of a collection of items.
[john,jack,fred,jim]
A list has a head (first element)
and a tail (LIST of all the other elements)
[Head|Tail]
For list above Head=john
Tail=[jack,fred,jim]
A Prolog rule defining list membership.
/* member(X,L) means X is a member of list L */
member( X , [X | _ ] ).
member( X , [ _ | T ] ) :- member ( X , T ).
Slightly Larger Knowledgebase
/* Global Facts */
/* Knowledge Base of Pain Killers */
relieves(aspirin,headache).
relieves(wonderdrug,headache).
relieves(aspirin,toothache).
relieves(penecillin,pneumonia).
aggravates(aspirin,asthma).
/* Global Rules */
should_take{Person,Drug):complains_of(Person,Symptom),
relieves(Drug,Symptom),
not(unsuitable_for(Drug,Person)).
unsuitable_for(Drug,Person):aggravates(Drug,Symptom),
suffers_from(Person,Symptom).
/* Local Facts */
complains_of(john,headache).
suffers_from(john,asthma).
?- consult(filename).
yes
?- should_take(john,D).
D=wonderdrug
more(y/n) y
no
?-
A Typical “Expert” System