AAI1 02 Logic

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 29

Algorithms for AI 1

Logic

Prof. Dr. Torsten Schön, SS 2022

12.11.2022
Logic
A (small) Comic Story

Ahh, you play with the little AI!

Oh, babies love horror stories, I


know a good one…

Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön


Logic
A (small) Comic Story

… and then there was a huge scary Wumpus monster…

Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön


Logic
A (small) Comic Story

Auuuuww…

Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön


Logic
What we learn today….

1. You know what deductive systems are


2. You know the basic terms and operations of logic and its inference
3. You are able to solve a simple game like problem using model checking

Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön


Logic
What is logic?

TASK: 5 min

Discuss with your neighbor:


• What is Logic?
• Where did we use logic in Programming 1?

Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön


Deductive Systems
Overview

Deductive and knowledge based systems


We call a deductive system a knowledge based system, that can generate new rules from
an existing well formed set of knowledge based on inference mechanisms.

Advantages Disadvantages
• Known structure, no black box • Often high time complexity
• Results are traceable or even • Knowledge has to be given
provable manually
• Good for formal problems • Not suitable for many real world
problems

7 Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön


Logic
Where to use

• Formulating formal facts


• Boolean Algebra
• Semantics of programming languages
• Verification of computer programs
• Knowledge representation
• Logic Programming (e.g. PROLOG)
• Automatic mathematical proving

Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön


Logic
Motivation

• Human beings are able to infer/reason new knowledge from existing knowledge
• Logic makes it possible to formalise this procedure
• That is important to automate reasoning on computers
• To do so, we need:
• A formal and unique representation
• Syntax
• Semantics
• Inference rules
Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön
Logic
A formal and unique representation

• Knowledge base (KB) is a set of “sentences”


• Each sentence is represented in a knowledge representation language and
represents some assertions about the world
• When the sentence is taken as being given, its called axiom. An axiom is not
derived from any other sentence
• Deriving a new sentence from an old one is called inference.
• Each sentence in classical logic is either True or False!

Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön


Logic
The Wumpus World

Source: Artificial Intelligence, a modern approach.


Russel & Norwig, Page 229 ff
Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön
Logic
The Wumpus World

Source: Artificial Intelligence, a modern approach.


Russel & Norwig, Page 229 ff
Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön
Logic
The Wumpus World

Source: Artificial Intelligence, a modern approach.


Russel & Norwig, Page 229 ff
Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön
Logic
The Wumpus World

Sensor percepts are given in the form of a list of 5 symbols:


[Stench, Breeze, Glitter, Bump, Scream]
Source: Artificial Intelligence, a modern approach.
Russel & Norwig, Page 229 ff
Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön
Logic
The Wumpus World

Let‘s solve the given


Wumpus world

15 Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön


Logic
The Wumpus World

Source: Artificial Intelligence, a modern approach.


Russel & Norwig, Page 229 ff
Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön
Logic
The Wumpus World

Source: Artificial Intelligence, a modern approach.


Russel & Norwig, Page 229 ff
Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön
Logic

Short Break: 5 min

Take a minute to think of the Wumpus world


problem.

You can try to draw a scary Wumpus during the


break to relax

Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön


Logic
Formal representation

• The knowledge base consists of sentences


• Sentences are expressed according to the Syntax of the representation language
• Specifies all the sentences that are well formed

Example from arithmetic:

Well formed: Not well formed:

Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön


Logic
Formal representation

• Further Logic must define the Semantics (meanings) of sentences


• The semantics define the truth of each sentence with respect to each possible world (=model)
• Every sentence must be either True or False

Example from arithmetic:


The sentence 𝑥+ 𝑦 =5 is… True for False for

Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön


Logic
Formal representation

• If a sentence α is true in model m, we say that m satisfies α or m is a model of α


• The set of all models of α is given by notation M(α)
• The idea that one sentence follows logically from another one is called Entailment with
mathematical notation:
𝛼⊨ 𝛽

• α entails β if and only if , in every model in which α is true, β is also true:

𝛼 ⊨ 𝛽𝑖𝑓 𝑎𝑛𝑑 𝑜𝑛𝑙𝑦 𝑖𝑓 𝑀(𝛼)⊆ 𝑀 (𝛽)

Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön


Logic
Formal representation applied to the Wumpus world

• Let’s apply the new knowledge to the Wumpus world, consider the following state:

KB:
1. Agents knowledge about the
worlds rules
2. Nothing in [1,1]
3. Breeze in [2,1]

Question:
1. Pitt in [1,2], [2,2] or [3,1] ???

Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön


Logic
Formal representation applied to the Wumpus world

Consider 2 conclusions: What models are


There is no pit in [1,2]
possible?
There is no pit in [2,2]

23 Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön


Logic
Formal representation applied to the Wumpus world

Source: Artificial Intelligence, a modern approach.


Russel & Norwig, Page 229 ff
Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön
Logic
Formal representation applied to the Wumpus world

From the models we see:

• In every model in which KB is true, is also true, thus there is no pit in [1,2],
• In some models where KB is true, is false, hence, KB does not entail
 We cannot conclude that there is no pit in [2,2] !

This procedure is called model checking


The procedure enumerates all possible models to check that α is true in all models in which
KB is true

Source: Artificial Intelligence, a modern approach.


Russel & Norwig, Page 229 ff
Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön
Logic
Formal representation

Let‘s have a look at two more helpful definitions regarding inference machisms:

Sound (or truth preserving)


An inference mechanism that derives only entailed sentences is called sound.
Soundness is a highly desirable property!

Completeness
An inference algorithm is complete if it can derive any sentence that is entailed.

Source: Artificial Intelligence, a modern approach.


Russel & Norwig, Page 229 ff
Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön
Logic
Formal representation applied to the Wumpus world

Task: 10 min

Let’s consider the following conclusion:

There is no pit in [3,1]

Perform model checking to see if

Source: Artificial Intelligence, a modern approach.


Russel & Norwig, Page 229 ff
Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön
Logic
Summary….

1. You know what deductive systems are


a knowledge based system, that can generate new rules from an existing well formed set of
knowledge based on inference mechanisms

2. You know the basic terms and operations of logic and its inference
knowledge base, sentences, axioms, inference, entailment

3. You are able to solve a simple game like problem using model checking
we solved the first steps of the Wumpus world using model checking

Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön


Logic
You should now be able to solve the following exam questions

(1) What does logical entailment mean?

(2) Solve a given Wumpus World step by step and illustrate the current knowledge base for each
step. Can the agent reach the gold safely?

(3) Expect that the smell of a Wumpus is not at same strength in different months of the year.
Would an agent based on the described logical inference be able to learn this over time?
Justify your answer.

29 Technische Hochschule Ingolstadt | Algorithms for AI 1 | Prof. Dr. Torsten Schön

You might also like