# Artificial Intelligence

# Introduction to Artificial Intelligence

# AI: What is it?

  • We call ourselves Homo sapiens (man the wise) because our mental capacities are so important to us

  • For thousands of years, we have tried to understand how we think

  • The field of artificial intelligence (AI) goes further still: it attempts to not just understand but also to build intelligent entities.

4 views of AI

Thinking humanly Thinking rationally
Acting humanly Acting rationally

4 views of AI - Jason & Ketherin Weekly Sync

Thinking humanly Thinking rationally
Acting humanly Acting rationally
  • Thought processes and reasoning versus behaviour.

4 views of AI

Thinking humanly Thinking rationally
Acting humanly Acting rationally
  • Thought processes and reasoning versus behaviour.

  • Human performance versus rationality.

Rationality is an idealised concept of intelligence. A system is rational if it does the "right thing", given what it knows.

# Acting Humanly: Turing Test Approach

Alan Turing (1912-1954)

English mathematician, logician, computer scientist and cryptanalysist

During WW2 worked at the British Government Code and Cypher School, devising number of techniques for breaking German cyphers

After the war he worked in the National Physical Laboratory where he worked on ACE (first designs of program-stored computer)

Prosecuted in 1952, and died by cyanide poising 1954

The Turing Test, proposed by Alan Turing (1950), was designed to provide a satisfactory operational definition of intelligence.

image

  • Measures the performance of an allegedly intelligent machine against that of a human.
  • Machine, human and the interrogator in separate rooms (communication vis computer terminal)
  • The interrogator is asked to distinguish the computer from the human being solely on the basis of their answers to questions asked over the device.

If the interrogator cannot distinguish the machine from the human, then, Turing argues, the machine may be assumed to be intelligent.

The total Turing Test includes a video signal and the interrogator can pass physical objects "through a hatch". To pass the total Turing test, the computer will need the following capabilities:

  1. National language processing: to communicate in English
  2. Knowledge representation: to store what it knows and learn
  3. Automated reasoning: to use the stored information to answer questions and draw new conclusions
  4. Machine learning: to adapt to new circumstances and to detect and extrapolate patterns
  5. Computer vision: to perceive object
  6. Robotics: to manipulate objects and move about

These six disciplines compose most of AI.

Advantages:

  • It attempts to give an objective notion of intelligence that avoids debates over its "true" nature, i.e., the behaviour of a known intelligent being in response to a particular set of questions.

  • Avoids the process/product debate: whether or not the computer uses the appropriate internal processes or whether or not the machine is actually conscious of it actions.

  • Eliminates any bias in favour of living organisms be forcing the interrogator to focus solely of the content of the answers to questions.

Criticisms:

  • Bias towards purely symbolic-solving tasks. It does not test abilities requiring perceptual skill or manual dexterity.

  • Needlessly constrains machine learning intelligence to fit a human model. Perhaps machine intelligence is fundamentally different from human intelligence?

  • Lady Lovelace's Objection: computers can only do as they are told and consequently cannot perform original (hence, intelligent) actions.

  • Argument for Informality of Behaviours: impossible to create a set of rules that will tell an individual exactly what to do under every possible set of circumstances.

# Turing Test: Eugene Goostman

Eugene Goostman - chatbot pretending to be a 13yo boy living in Ukraine

Eugene the Turing test-beating 'human computer' – in 'his' own words (opens new window)

Fooled 33% of the judges in the Turing Test 2014 competition

Criticism: using personality quirks and humour as distraction

# Thinking Humanly: The Cognitive Model Approach

We can analyse the actual workings of human minds in two ways:

  • Introspection (examining our own ideas, thoughts, feelings))
  • Psychological experiments

Trying to build a theory/model which then to implement in a computer program

If the program's input/output and timing behaviours match corresponding human behaviours, that is evidence that some of the program's mechanisms could also be operating in humans.

The field of cognitive science brings together

  • computer models from AI and
  • experimental techniques from psychology, biology, chemistry

# Thinking Rationally: The "laws of thought" approach

Aristotle was the first to attempt to codify "right thinking". His syllogisms provided patterns for argument structures that always yielded the correct conclusions given correct premises:

"Socrates is a man; all men are mortal; therefore, Socrates is mortal".

These laws of thought initiated the field called logic.

In the 19th century logicians has developed a precise notation for statements about all kinds of things in the world and about the relations among them.

By 1965 programs existed that could, in principle, solve any solvable problem described in logical notation

There so called logicist tradition within AI hopes to build on such programs to create intelligent systems.

Problems with the logicist tradition:

  • It is not easy to take informal knowledge and state it in the formal terms required by logical notation, particularly when the knowledge is less than 100% certain.

  • There is a big difference between being able to solve a problem "in principle" and doing so in practice (combinatorial explosion).

    • Even problems with just a few dozen facts can exhaust the computational resources of any computer unless it has some guidance as to which reasoning steps to try first.

# Acting rationally: The rational agent approach

An agent is just something that acts (agent comes from the Laten agrere, to do)

A rational agent is one that acts so as to achieve the best outcome or, when there is uncertainty the best expected outcome.

Limited rationally: acting appropriately when there is not enough time to do all the computations one might like.

Note: AI as rational-agent design is more general that the "laws of thought" approach, because correct inference is just one of several possible mechanisms for achieving rationality (reflex actions do not require inference, yet they can still result in achieving the best outcome!).

# Chinese room experiment

John Searle (1980) - strong AI

You have a program that can process Chinese input and produce replies in Chinese

Does the machine

  • Understand Chinese - strong AI
  • Simulate understanding - weak AI

# AI: What is it? (cont'd)

The branch of computer science that is concerned with the automation of rational behaviour.

It includse:

  • Data structure used in knowledge representation
  • Algorithms needed to apply that knowledge
  • Languages and programming techniques used in their implementation

image

image

# Major successes

Autonomous planning and scheduling: (2020) NASA's Remote Agent program became the first on-board autonomous planning program to control the scheduling or operations for spacecraft.

Game playing: (1997) IBM's Deep Blue became the first computer program to defeat the world champion in a chess match.

Autonomous control: The ALVINN computer vision system was trained to steer a car to keep following a lane and was used to navigate across the US - for 2850 miles it was in control of steering the vehicle 98% of the time.

Diagnosis: Medical diagnosis programs based on probabilistic analysis have been able to perform at the level of an expert physician in several areas of medicine.

Logistics planning: 1991 Persian Gulf crisis - US forces deployed an AI system to do automated logistic planning and scheduling for transportation (coordinating and planning for 50,000 vehicles, cargo and people)

Robotics: many surgeons now use robot assistants in micro-surgery.

Language understanding and problem solving: Proverb (Littman et al. 1999) is a computer program that can solve crossword puzzles better than most humans, using information from a variety of sources.

Watson (IBM 2011) - won on Jeopardy! against previous champions.


# Introduction to Prolog

PROgramming in LOGic

  • Developed from Logical theorem proving (originally used for research in natural language processing)
  • Logical relationships are asserted
  • Prolog is used to determine whether or not certain statements are true, and if true, what variable bindings make them true

Think declaratively, not procedurally

  • Challenging
  • Requires a different mindset

# Prolog: A Declarative language

Doesn't contain statements or instructions:

contains facts and rules

  • Facts
    • state properties which are true of the system we're describing
  • Rules
    • give us ways of deducing new facts form existing ones

Prolog program gives information about a system, which is often called a knowledge base (aka logic base).

Do not "run a program", instead query the knowledge or logic base

  • Ask "Is such-and-such a fact true?"
  • Prolog will then answer "yes" or "no" to the query.

image

# Knowledge Base

Facts:

  • Fluffy is a cat.
  • Ben is a dog.
  • It is raining.
  • ...

Deduction rules:

  • All dogs hate cats
  • If it is raining outside bring umbrella
  • ...

# Knowledge Bases: Facts

cat(fluffy).
cat(lucky).
dog(ben).
hungry(ben).
sunny.

# Knowledge Bases: Queries

?- cat(fluffy).
yes
?-
?- cat(lucky).
yes
?- cat(scratchy).
no
?-
?- hungry(ben).
yes
?- hungry(fluffy).
no
?- eaten(ben).
ERROR: Predicate eaten/1 not defined.
?-

# assert

assert - assert a fact in the KB

?- assert(cat(lucky)).
true

# listing

listing - lists the contents of KB (facts and rules)

listing(:Pred) - Pred can be just the predicate name (atom), or can specify arity as well

?- listing(cat).
cat(lucky).
true.
?-

Documentation (SWI-Prolog) (opens new window)

# Using variables

cat(fluffy).
cat(lucky).
dog(ben).
hungry(ben).
sunny.
?- cat(X).
X = fluffy;
X = lucky.
?-

Note: using ; after each result causes Prolog to backtrack

# asserta vs assertz

asserta - asserts at the start of the KB assertz - asserts at the end of the KB

cat(fluffy).
cat(lucky).
?- asserta(cat(daisy)).
true.
?-
cat(daisy).
cat(fluffy).
cat(lucky).

The order of the facts and rules in the KB is important

  • affects the order in which Prolog will find answers to queries
cat(daisy).
cat(fluffy).
cat(lucky).
?- cat(X).
X = daisy;
X = fluffy;
X = lucky.
?-

# retract

retract - removes a fact or rule from the KB

cat(daisy).
cat(fluffy).
cat(lucky).
?- retract(cat(daisy)).
true.
?- listing(cat).
cat(fluffy);
cat(lucky).

# Syntax: Atoms

All terms that consist of letters, numbers and underscore, and start with a noncapital letter are atoms: fluffy, uncle_ben,...

All terms that are enclosed in single quotes are atoms: 'Atom Mary'

Certain special symbols are also atoms: +,,,...

# Syntax: Complex Terms

Complex Terms have the form: functor(argument1, ...,argumentn)

Functors have to be atoms

Arguments can be any type of Prolog term, e.g., complex terms

# Syntax: Facts and Queries

Facts are complex terms which are followed by a full stop

cat(fluffy).
likes(fluffy, fish).

Queries are also complex terms which are followed by a full stop

image

# Rules

Rules are of the form Head:- Body.

Rules have to end by a full stop (similarly to facts and queries)

Head is a complex term.

Body is a complex term or sequence of complex terms separated by commas.

woman(mary).
woman(mia).
listens2music(mary).
had_lunch(mia).
happy(mary):- listens2music(mary).
not_hungry(X):- had_lunch(X).
?- happy(mary).
true.
?-

# Clauses

woman(mary).
woman(mia).
listens2music(mary).
had_lunch(mia).
happy(mary):- listens2music(mary).
not_hungry(X):- had_lunch(X).

There are six clauses in this KB - four facts and two rules.

Every clause ends with a full stop.

# Predicates

woman(mary).
woman(mia).
listens2music(mary).
had_lunch(mia).
happy(mary):- listens2music(mary).
not_hungry(X):- had_lunch(X).

There are six predicates in this KB

  • woman
  • listens2music
  • had_lunch
  • happy
  • not_hungry

# Arity

The number of arguments a complex term has is called it arity

For example:

  • woman(mary) is a term with arity 1
  • loves(mary, ice-cream) arity 2
  • father(father(bill)) arity 1

In Prolog you can define two predicates with the same functor but with different arity

Prolog would treat this as two different predicates:

makes(ann, cake)
makes(ann, cake, mary)

In Prolog documentation arity of a predicate is usually indicated with the suffix "/" followed by a number to indicate the arity

makes/2
makes/3

# Variables

All terms that consist of letters, numbers and the underscore and start with a capital letter or an underscore are variables: Mary, _john

is an anonymous variable, two occurrences of are different

woman(mary).
woman(mia).
loves(john, mia).
loves(john, beer).
?- loves(john, X).
X = mia;
X = beer.

?- loves(john, X), woman(X).
X = mia;
false.

?-
woman(mary).
woman(mia).
loves(john, mia).
loves(john, beer).
loves(rob, beer).
?- loves(rob, X), woman(X).
false.

?- loves(rob, X).
X = beer.

?-
loves(john, beer).
loves(rob, beer).
loves(mia, oj).

friend(X, Y):- loves(X, Z), loves(Y, Z).
?- friend(X, Y).
X = Y, Y = John;
X = john,
Y = rob;
X = rob,
Y = john;
X = Y, Y = rob;
X = Y, Y = mia.
?-
loves(john, beer).
loves(rob, beer).
loves(mia, oj).

friend(X, Y):- loves(X, Z), loves(Y, Z), dif(X, Y).
?- friend(X, Y).
X = john,
Y = rob;
X = rob,
Y = john.
?-

# Prolog Connectives

Connectives are used to join atomic predicates together to make complex relationships.

The table below lists the main Prolog connectives and their meaning in English and Predicate Calculus

English Predicate Calculus Prolog
and ,
or ;
only if <- :-
not ~ not

# Prolog: ONLY-IF

image

the LHS of :- is evaluated as true when the RHS is proven to be true.

If happy(mia) is true, then happy(mary) is also true.

image

# Prolog: AND

image

friend(X, Y) is true, only when loves(X, Z) is true AND loves(Y, Z) is true.

# Prolog: OR

image

friend(john, X) is true when loves(X, bear) is true OR loves(X, wine) is true.

friend(john, X):- loves(X, beer); loves(X, wine).

is equivalent to

friend(john, X):- loves(X, beer).
friend(john, X):- loves(X, wine).