Sei sulla pagina 1di 40

Knowledge Representation

Most artificial intelligence systems are made up of two parts: 1) Knowledge base

It contains fact about objects and their relationship. It is a set of procedures that are used to examine the knowledge base in an orderly manner to answer questions, solve problems or make decisions within the domain

2) Inference mechanism

Knowledge representation schemes

The 1st step in constructing an AI program is to build a knowledge base. In order to act intelligently, a computer must have a knowledge about the domain of interest. The process of collecting and organizing the knowledge is called knowledge engineering.

Types of knowledge representation Scheme

Knowledge representation scheme have generally been categorized as either declarative or procedural. A declarative scheme is one used to represent facts and assertions. A procedure representation scheme deals with the action or procedure.

Continue

Declarative knowledge representation methods include logic, semantic networks, frames and scripts. Procedural knowledge representation scheme include procedure or subroutine and production rules

Four General Representation Types

Logical Representations

Semantic Networks
Production Rules Frames

4.1 Logical Representations What is a Logic?


Logic is the oldest form of knowledge representation Logic is the study of the methods and principles used to distinguish correct from incorrect reasoning. The scientific study of the process of reasoning and system of rules and procedures that aid in the reasoning process. There are two types of reasoning

Deductive reasoning Inductive reasoning

Continued.

Deductive Reasoning

When a general premises are used to obtain a specific inference, the process is called deductive reasoning or deduction. Inductive Reasoning uses a number of establishes facts or premises in order to draw some general conclusion.

Inductive Reasoning

Syntax and Semantics of Logics

Syntax

How we can construct legal sentences in the logic Which symbols we can use (English: letters, punctuation) How we are allowed to write down those symbols How we interpret (read) sentences in the logic i.e., what the meaning of a sentence is Perfectly valid sentence (syntax) And we can understand the meaning (semantics) This sentence happens to be false (there is a counterexample)

Semantics

Example: All lecturers are six foot tall


Propositional Logic

Syntax

Connectives: and, or, not, implies, equivalent

Brackets, T (true) and F (false)


How to work out the truth of a sentence

Semantics

Need to know how connectives affect truth E.g., P and Q is true if and only if P is true and Q is true P implies Q is true if P and Q are true or if P is false

Can draw up truth tables to work out the truth of statements

What language should we use?

Natural language, ie English, Too ambiguous. Programming Language, ie C++ Lisp. Not very expressive. We will use logic! Actually there are many different logics. We will start by considering Propositional Logic. We will find that has some drawbacks so we will consider the more generalFirst-Order Logic Predicate Logic. This too, has limitations, so we will consider the Propositional Logic more general Predicate Logic First-Order Logic.

A logic language consists of semantics and syntax

Semantics: What the sentences mean.

Syntax: How sentences can be assembled.

Propositional Logic: Syntax I

Vocabulary A set of propositional symbols P, Q, R, . A set of logical connectives , , , , (and) (or) (not) (implication) (equivalence) Parenthesis (for grouping) () Logical constants True, False

Propositional Logic: Syntax II

Each symbol P, Q, R etc is a (atomic) sentence Both True and False are (atomic) sentences A sentence wrapped in parentheses is a sentence

If and are sentences, then so are conjunction disjunction negation implication equivalence
The above are complex sentences

Precedence is

, , , ,

Truth Tables

Sample Sentences
P True (P Q)

(P Q) R (P Q) (Q P) (P R )

What do the sentences mean? The meaning depends on user defined semantics. If P is defined as it is hot and Q is defined as it is raining, then P PQ Q means it is hot means either is is hot or it is raining (or both) means that it is not raining

An inference procedure for proposition logic


Suppose we want to prove (P Q) (P Q)

Construct a truth table, if (P Q) (P Q) is true for all values of P and Q, then we have proved it.
For any sentence, no matter how complex, we can always prove or disprove it this way. In other words, truth table construction is complete.

Irish Hot, Irish

|-

Hot

If we know Irish implies hot is true, and know Irish is true, we can infer Hot is true. Read as

Irish implies Hot, Irish, Therefore Hot

Irish Blue

|-

Blue

If we know Irish and Blue is true, we can infer that Blue is true. Read as

Irish and Blue Therefore Blue

Irish, Red

|-

Irish Red

If we know Irish is true, and we know Red is true, we can infer that Irish and Red is true. Read as

Irish , Red Therefore Irish and Red

Irish

|- Irish Green

If we know Irish is true, then we know that Irish or Green is true. Read as

Irish, Therefore Irish or Green

Irish |- Irish
If we know not not Irish is true, we can infer that Irish is true. Read as

Not not Irish, Therefore Irish

Irish Red, Red Fast |-

Irish Fast

If we know Irish or Red is true, and we know not Red or Fast is true, we can infer that Irish or Fast must be true. Read as

Irish or Red, not Red or Fast, Therefore Irish or Fast

Limitations of Propositional Logic

Many kinds of inference cannot be formalized in propositional logic. For example, most useful inference involve applying a general rule to a specific case. But general-to-specific inferences like the following cannot be formalized in propositional logic. All men are mortal Socrates is a man Therefore, Socrates is mortal This inference cannot be formalized in propositional logic because it refers to individual men, such as Socrates, and make generalizations about all men.

First-Order Logic (FOL)


Propositional logic has only sentences, which represent facts. First-order logic extends propositional logic in two directions It provides an inner structure for sentences. They are viewed as expressing relations between objects or individuals. It provides a means to express, and reason with, generalizations. It makes it possible to say that a certain property holds of all objects, of some objects, or of no object.

Terms
First-order logic has terms that represent objects or individuals.
Terms are built using constant, variable, and function symbols. Constants(designate specific object): A, B, John, Red, etc. Variables (designate unspecified object): x, y, z, et Functions(designate a specific object related in a certain way to another object, or objects): FatherOf, ColorOf, etc. Examples of terms: ColorOf(CarOf(Bill)), CostOf(TextbookOf(CMPSCI383)), etc. Ground terms are terms that include no variables.

Predicates
Predicates

have a value of true or false A predicate can take arguments, which are terms A predicate with one argument expresses a property of an object Student(Bob) A predicate with two or more arguments expresses a relation between objects likes(Bob, Mary) likes(Bob, school-of (Bob)) A predicate with no arguments is a simple proposition, as in propositional logic

Universal Quantifier
x P(x) means for all x, P of x is true Example: x Happy(x) If the universe of discourse is people, then this means that everyone is happy. Other examples: x y Knows(x,y) => Knows(y,x) x y Knows(x,y) ^ Knows(y,x) x y Knows(x,y) => Likes(y,x)

Existential Quantifier
x P(x) means there exists at least one x for which P of x is true Example: x Happy(x) If the universe of discourse is people, then this means there is at least one happy person. Other examples: x y Knows(x,y) x y Knows(x,y) ^ Knows(y,x) x y Knows(x,y) => Likes(y,x)

First Order Predicate Logic

More expressive logic than propositional

And one we will use a lot in this course

Later lecture all about first order predicate logic

Syntax allows

Constants, variables, predicates, functions and quantifiers Or something is true for at least one object (existential) Working out the truth of statement

So, we say something is true for all objects (universal)

Semantics

This can be done using rules of deduction

Examples of predicate logic statements :


1. "Wonder" is a name of a dog : 2. All dogs belong to the class of animals : 3. All animals either live on land or in water : dog (wonder) x : dog (x) animal(x)

x : animal(x) live (x, land) V live (x, water)


From these three statements we can infer that : " Wonder lives either on land or on water ." Note : If more information is made available about these objects and their relations, then more knowledge can be inferred.

Example Sentence

In English:

Every Monday and Wednesday I go to Johns house for dinner

In first order predicate logic:


X ((day_of_week(X, monday) day_of_week(X, weds))

(go_to(me, house_of(john)

eat(me, dinner))).

Note the change from and to or

Translating is problematic

Higher Order Predicate Logic


More expressive than first order predicate logic Allows quantification over functions and predicates, as well as objects For example

We can say that all our polynomials have a zero at 17: f (f(17)=0). Important to AI, but not often used

Working at the meta-level

Other Logics

Fuzzy logic

Use probabilities, rather than truth values Assertions other than true and false allowed

Multi-valued logics

E.g., unknown

Modal logics

Include beliefs about the world Incorporate considerations of time

Temporal logics

Semantic Networks

Logic is not the only fruit Humans draw diagrams all the time, e.g.,

E.g. causal relationships:

And relationships between ideas:

Graphical Representations

Graphs are very easy to store inside a computer For information to be of any use

We must impose a formalism on the graphs

Jason is 15, Bryan is 40, Arthur is 70, Jim is 74 How old is Julia?

Better Graphical Representation

Because the formalism is the same

We can guess that Julias age is similar to Bryans

Limited the syntax to impose formalism

Semantic Network Formalisms

Used a lot for natural language understanding

Represent two sentences by graphs

Sentences with same meaning have exactly same graphs

Conceptual Dependency Theory


Roger Schanks brainchild Concepts are nodes, relationships are edges Narrow down labels for edges to a very few possibilities Problem:

Not clear whether reduction to graphs can be automated for all sentences in a natural language

Conceptual Graphs

John Sowa Each graph represents a single proposition Concept nodes can be:

Concrete (visualisable) such as restaurant, my dog spot Abstract (not easily visualisable) such as anger Instead, we introduce conceptual relation nodes See Russell and Norvig for details

Edges do not have labels

Many other considerations in the formalism

Example Conceptual Graph

Advantage:

Single relationship between multiple concepts is easily representable

Production Rule Representations


Consists of <condition,action> pairs Agent checks if a condition holds

If so, the production rule fires and the action is carried out This is a recognize-act cycle Multiple production rules will fire at once Call this the conflict set Agent must choose from this set

Given a new situation (state)


Call this conflict resolution

Production system is any agent

Which performs using recognize-act cycles

Example Production Rule

As reported in Doug Lenats PhD thesis

102. After creating a new generalization G of Concept C Consider looking for non-examples of G

This was paraphrased

In general, we have to be more concrete

About exactly when to fire and what to do

Frame Representations

Information retrieval when facing a new situation

The information is stored in frames with slots


Some of the slots trigger actions, causing new situations Which are to be filled-in in a situation Filling them in causes an agent to

Frames are templates


Undertake actions and retrieve other frames

Frames are extensions of record datatype in databases

Also very similar to objects in OOP

Flexibility in Frames

Slots in a frame can contain


Information for choosing a frame in a situation Relationships between this and other frames Procedures to carry out after various slots filled Default information to use where input is missing Blank slots - left blank unless required for a task Other frames, which gives a hierarchy

Example Frame

Potrebbero piacerti anche