knowledge representation praveen paritosh cogsci 207: fall 2003: week 1 thu, sep 30, 2004

44
Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Upload: ethel-cook

Post on 17-Dec-2015

221 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Knowledge Representation

Praveen ParitoshCogSci 207: Fall 2003: Week 1

Thu, Sep 30, 2004

Page 2: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Some Representations

Page 3: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Elements of a Representation

• Represented world: about what? • Representing world: using what? • Representing rules: how to map? • Process that uses the representation: conventions

and systems that use the representations resulting from above.

• Analog versus Symbolic

Page 4: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Marr’s levels of description

• Computational: What is the goal of the computation, why is it appropriate, and what is the logic of the strategy by which it can be carried out?

• Algorithmic: How can this computational theory be implemented? In particular, what is the representation for the input and output, and what is the algorithm for the transformation?

• Implementation: How can the representation and algorithm be realized physically?

Page 5: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Marr’s levels of description – 2

• Computational: a lot of cognitive psychology• Algorithmic: a lot of cognitive science• Implementation: neuroscience

Page 6: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

A closer look

Page 7: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Overview

• How knowledge representation works– Basics of logic (connectives, model theory, meaning)

• Basics of knowledge representation– Why use logic instead of natural language?

– Quantifiers

– Organizing large knowledge bases

• Ontology

• Microtheories

• Resource: OpenCyc tutorial materials

Page 8: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

How Knowledge Representation Works

• Intelligence requires knowledge• Computational models of intelligence require

models of knowledge• Use formalisms to write down knowledge

– Expressive enough to capture human knowledge

– Precise enough to be understood by machines

• Separate knowledge from computational mechanisms that process it– Important part of cognitive model is what the organism

knows

Page 9: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

How knowledge representations are used in cognitive models

• Contents of KB is part of cognitive model

• Some models hypothesize multiple knowledge bases.

KnowledgeBase

InferenceMechanism(s)

LearningMechanism(s)

Examples,Statements

Questions,requests

Answers,analyses

Page 10: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

What’s in the knowledge base?

• Facts about the specifics of the world– Northwestern is a private university

– The first thing I did at the party was talk to John.

• Rules (aka axioms) that describe ways to infer new facts from existing facts– All triangles have three sides

– All elephants are grey

• Facts and rules are stated in a formal language– Generally some form of logic (aka predicate calculus)

Page 11: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Propositional logic

• A step towards understanding predicate calculus• Statements are just atomic propositions, with no

structure– Propositions can be true or false

• Statements can be made into larger statements via logical connectives.

• Examples:– C = “It’s cold outside” ; C is a proposition– O = “It’s October” ; O is a proposition– If O then C ;if it’s October then it’s cold outside

Page 12: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Symbols for logical connectives

• Negation: not, , ~• Conjunction: and, • Disjunction: or, • Implication: implies, , • Biconditional: iff,

------------------------------------------------------------• Universal quantifier: forall, • Existential quantifier: exists,

Page 13: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Semantics of connectives

• For propositional logic, can define in terms of truth tables

A B ABF F F

F T F

T F F

T T T

A B ABF F

F T

T F

T T

Page 14: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Implication and biconditional

A B AB

F F

F T

T F

T T

A B AB

F F T

F T T

T F F

T T T

AB AB AB (AB)(BA)

Page 15: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Rules of inference

• There are many rules that enable new propositions to be derived from existing propositions– Modus Ponens: PQ, P, derive Q

– deMorgan’s law: (AB), derive AB

• Some properties of inference rules– Soundness: An inference rule is sound if it always

produces valid results given valid premises

– Completeness: A system of inference rules is complete if it derives everything that logically follows from the axioms.

Page 16: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Predicate calculus

• Same connectives

• Propositions have structure: Predicate/Function + arguments. – R, 2 ; Terms. Terms are not individuals, not propositions

– Red(R), (Red R) ; A proposition, written in two ways

– (southOf UnicornCafe UniHall) ;a proposition

– (+ 2 2) ; Term, since the function + ranges over numbers

• Quantifiers enable general axioms to be written– (forall ?x

(iff (Triangle ?x) (and (polygon ?x) (numberOfSides ?x 3)))

Page 17: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Model Theory

• Meaning of a theory = set of models that satisfy it.– Model = set of objects and relationships

– If statement is true in KB, then the corresponding relationship(s) hold between the corresponding objects in the modeled world

– The objects and relationships in a model can be formal constructs, or pieces of the physical world, or whatever

• Meaning of a predicate = set of things in the models for that theory which correspond to it.– E.g., above means “above”, sort of

Page 18: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Caution: Meaning pertains to simplest model

• There is usually an intended model, i.e., what one is representing.

• A sparse set of axioms can be satisfied by dramatically simpler worlds than those intended– Example: Classic blocks world axioms have ordered

pairs of integers as a model

• (<position on table> <height>) block

• (on A B) p(A) = p(B) & h(A) = h(B)+1

• (above A B) p(A) = p(B) & h(A) > h(B)

• Moral: Use dense, rich set of axioms

Page 19: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Misconceptions about meaning

• “Predicates have definitions”– Most don’t. Their meaning is constrained by the sum

total of axioms that mention them.

• “Logic is too discrete to capture the dynamic fluidity of how our concepts change as we learn”– If you think of the set of axioms that constrain the

meaning of a predicate as large, then adding (and removing) elements of that set leads to changes in its models.

– Sometimes small changes in the set of axioms can lead to large changes in the set of models. This is the logical version of a discontinuity.

Page 20: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Representations as Sculptures

• How does one make a statue of an elephant?– Start with a marble block. Carve away everything that

does not look like an elephant.

• How does one represent a concept?– Start with a vocabulary of predicates and other axioms.

Add axioms involving the new predicate until it fits your intended model well.

• Knowledge representation is an evolutionary process– It isn’t quick, but incremental additions lead to incremental

progress– All representations are by their nature imperfect

Page 21: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Introduction to Cyc’s KR system

• These materials are based on tutorial materials developed by Cycorp, for training knowledge entry people and ontological engineers

• For this class, we have simplified them somewhat.• In examinations, you will only be responsible for

the simplified versions

Page 22: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

NL vs. Logic: Expressiveness

NL:Jim’s injury resulted from his falling.

Jim’s falling caused his injury.

Jim’s injury was a consequence of his falling.

Jim’s falling occurred before his injury.

Logic: identify the common concepts, e.g.

the relation: x caused y

Write rules about the common concepts, e.g.

x caused y x temporally precedes y

NL: Write the rule for every expression?

Page 23: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

NL vs. Logic: Ambiguity and Precision

x is running-InMotion x is changing location

x is running-DeviceOperating x is operating

x is running-AsCandidate x is a candidate

•x is at the bank.

•river bank?

•financial institution?

NL:Ambiguous

Logic:

Precise

•x is running.

•changing location?

•operating?

•a candidate for office?

Reasoning: Figuring out what must be true, given what is known. Requires precision of meaning.

Page 24: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

NL vs. Logic:Calculus of Meaning

Logic: Well-understood operators enable reasoning:

Logical constants: not, and, or, all, some

Not (All men are taller than all women).

All men are taller than 12”.

Some women are taller than 12”.

Not (All A are F than all B).

All A are F than x.

Some B are F than x.

Page 25: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Syntax: Terms (aka Constants)

• A sampling of some constants:– Dog, SnowSkiing, PhysicalAttribute

– BillClinton,Rover, DisneyLand-TouristAttraction

– likesAsFriend, bordersOn, objectHasColor, and, not, implies, forAll

– RedColor, Soil-Sandy

Terms denote specific individuals or collections (relations, people, computer programs, types of cars . . . )

Each Terms is a character string prefixed by

These denote collections

These denote individuals :

•Partially Tangible Individuals

•Relations

•Attribute Values

Page 26: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Syntax: Propositions

Propositions: a relation applied to some arguments, enclosed in parentheses– Also called formulas, sentences…

• Examples:– (isa GeorgeWBush Person)– (likesAsFriend GeorgeWBush AlGore)– (BirthFn JacquelineKennedyOnassis)

Page 27: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Syntax: Non-Atomic Terms• New terms can be made by applying functions to other

things – In the Cyc system, functions typically end in “Fn”

• Examples of functions:– BirthFn, GovernmentFn, BorderBetweenFn

• Examples of Non-Atomic Terms:– (GovernmentFn France)– (BorderBetweenFn France Switzerland)– (BirthFn JacquelineKennedyOnassis)

Non-atomic Terms can be used in statements like any other term• (residenceOfOrganization (GovernmentFn France)

CityOfParisFrance)

Page 28: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Why Use NATs?• Uniformity

– All kinds of fruits, nuts, etc., are represented in the same, compositional way:

(FruitFn PLANT) *

• Inferential Efficiency– Forward rules can automatically conclude many useful

assertions about NATs as soon as they are created, based on the function and arguments used to create the NAT.

• what kind of thing that NAT represents• how to refer to the NAT in English• …

Page 29: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Well-formedness: Arity

• Arity constraints are represented in CycL with the predicate arity:

• (arity performedBy 2)Represents the fact that performedBy takes two arguments, e.g.:

(performedBy AssassinationOfPresidentLincoln JohnWilkesBooth)

• (arity BirthFn 1)Represents the fact that BirthFn takes one arguments, e.g.:

(BirthFn JacquelineKennedyOnassis)

Page 30: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Well-Formedness: Argument Type

Argument type constraints are represented in CycL with the following 2 predicates:

1 argIsa

(argIsa performedBy 1 Action) means that the first argument of performedBy must be an individual Action, such as the assassination of Lincoln in:

(performedBy AssassinationOfPresidentLincoln JohnWilkesBooth)

2 argGenl

(argGenl penaltyForInfraction 2 Event) means that the second argument of penaltyForInfraction must be a type of Event, such as the collection of illegal equipment use events in:

(penaltyForInfraction SportsEvent IllegalEquipmentUse Disqualification)

Page 31: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Why constraints are important

• They guide reasoning– (performedBy PaintingTheHouse Brick2)

– (performedBy MarthaStewart CookingAPie)

• They constrain learning

Page 32: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Compound propositions

• Connectives from propositional logic can be used to make more complex statements

(and (performedBy GettysburgAddress Lincoln)(objectHasColor Rover TanColor))

(or (objectHasColor Rover TanColor)(objectHasColor Rover BlackColor))

(implies (mainColorOfObject Rover TanColor)(not (mainColorOfObject Rover RedColor)))

(not (performedBy GettysburgAddress BillClinton))

Page 33: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Variables and Quantifiers

• General statements can be made by using variables and quantifiers– Variables in logic are like variables in algebra

• Sentences involving concepts like “everybody,” “something,” and “nothing” require variables and quantifiers:

Everybody loves somebody.

Nobody likes spinach.

Some people like spinach and some people like broccoli, but no one likes them both.

Page 34: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Quantifiers• Adding variables and quantifiers, we can represent more

general knowledge.• Two main quantifiers:

1. Universal Quantifer -- forAll

Used to represent very general facts, like:All dogs are mammalsEveryone loves dogs

2. Existential Quantifier -- thereExists

Used to assert that something exists, to state facts like: Someone is bored

Some people like dogs

Page 35: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Quantifiers

• Universal Quantifier(forAll ?THING

(isa ?THING Thing))• Existential Quantifier:

(thereExists ?JOE(isa ?JOE Poodle))

• Others defined in CycL:(thereExistsExactly 12 ?ZOS (isa ?

ZOS ZodiacSign))

(thereExistsAtLeast 9 ?PLNT (isa ?PLNT Planet))

Everything is a thing.

Something is a poodle.

There are exactly 12 zodiac signs

There are at least 9 planets

Page 36: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Implicit Universal Quantification

All variables occurring “free” in a formula are understood by Cyc to be implicitly universally quantified.

So, to CYC, the following two formulas represent the same fact:

(forAll ?X(implies

(isa ?X Dog)(isa ?X Animal))

(implies(isa ?X Dog)(isa ?X Animal))

Page 37: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Pop Quiz #1

• What does this formula mean?

(thereExists ?PLANET (and (isa ?PLANET Planet) (orbits ?PLANET Sun)))

Page 38: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Pop Quiz #1

• What does this formula mean?

(thereExists ?PLANET (and (isa ?PLANET Planet) (orbits ?PLANET Sun)))

“There is at least one planet orbiting the Sun.”

Page 39: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Pop Quiz #2

• What does this formula mean?

(forAll ?PERSON1(implies

(isa ?PERSON1 Person) (thereExists ?PERSON2 (and

(isa ?PERSON2 Person) (loves ?PERSON1 ?PERSON2)))

Page 40: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Pop Quiz #2

• What does this formula mean?

(forAll ?PERSON1(implies

(isa ?PERSON1 Person) (thereExists ?PERSON2 (and

(isa ?PERSON2 Person) (loves ?PERSON1 ?PERSON2)))

“Everybody loves somebody.”

Page 41: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Pop Quiz #3

• How about this one?

(implies (isa ?PERSON1 Person) (thereExists ?PERSON2 (and (isa ?PERSON2 Person) (loves ?PERSON2 ?PERSON1))))

Page 42: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Pop Quiz #3

• How about this one?

(implies (isa ?PERSON1 Person) (thereExists ?PERSON2 (and (isa ?PERSON2 Person) (loves ?PERSON2 ?PERSON1))))

“Everyone is loved by someone.”

Page 43: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Pop Quiz #4

And this?

(implies

(isa ?PRSN Person)(loves ?PRSN ?PRSN))

Page 44: Knowledge Representation Praveen Paritosh CogSci 207: Fall 2003: Week 1 Thu, Sep 30, 2004

Pop Quiz #4

And this?

(implies

(isa ?PRSN Person)(loves ?PRSN ?PRSN))

“Everyone loves his (or her) self.”