knowledge representation, reasoning, and planning · 3. knowledge representation, reasoning, and...

67
Chapter Chapter 3 3 Knowledge Representation Knowledge Representation , , Reasoning Reasoning , , and Planning and Planning —————————————— —————————————— Christian Jacob Christian Jacob [email protected] Department of Computer Science University of Calgary

Upload: others

Post on 22-Oct-2020

9 views

Category:

Documents


2 download

TRANSCRIPT

  • ChapterChapter 3 3

    Knowledge RepresentationKnowledge Representation,,ReasoningReasoning,, and Planning and Planning————————————————————————————

    Christian JacobChristian [email protected]

    Department of Computer ScienceUniversity of Calgary

  • Knowledge Engineering ApproachesKnowledge Engineering Approaches

    [Kasabov, 1996]

  • Knowledge Engineering ApproachesKnowledge Engineering Approaches

    [Kasabov, 1996]

  • KnowledgeKnowledgeEngineeringEngineeringPathwaysPathways

    [Kasabov, 1996]

  • 3.3. Knowledge Representation,Knowledge Representation,Reasoning, and PlanningReasoning, and Planning

    3.13.1 Common Sense KnowledgeCommon Sense Knowledge

    3.23.2 Knowledge Representation NetworksKnowledge Representation Networks

    3.33.3 ReasoningReasoning–– PropositionalPropositional Logic Logic

    –– Predicate Logic: PROLOGPredicate Logic: PROLOG

    3.43.4 PlanningPlanning

  • What isWhat is Commonsense Commonsense Knowledge Knowledge(CSK)?(CSK)?

    –– „„It is perhaps paradoxical thatIt is perhaps paradoxical that AI AI scientists scientists find findthe very subjects that are easy for tenthe very subjects that are easy for ten--yearyear--oldoldhumans more refractoryhumans more refractory to AI to AI methods than are methods than aresubjects that experts must study for yearssubjects that experts must study for years.“.“

    [[NilssonNilsson, 1998, p. 301], 1998, p. 301]

  • CommonsenseCommonsense Examples Examples

    –– A liquidA liquid fills the shape of fills the shape of a a cup cup..

    –– TheThe liquid will fall liquid will fall out if the cup is turned upside out if the cup is turned upsidedown.down.

    –– If you dropIf you drop an an object object,, it it will fall. will fall.

    –– People donPeople don‘t‘t exist before they are born exist before they are born..

    –– FishFish live in live in water and water and will die will die if taken out if taken out..

    –– People buy bread and milkPeople buy bread and milk in a in a grocery store grocery store..

    –– People typically sleep at nightPeople typically sleep at night..

  • MoreMore Commonsense Commonsense Examples Examples

    –– Get under shelter when itGet under shelter when it‘s‘s raining raining..((no need for knowledge about lowno need for knowledge about low--pressurepressuresystemssystems))

    –– Don‘tDon‘t spill the coffee out of your cup when spill the coffee out of your cup whenstopping and moving abruptlystopping and moving abruptly..((no need for advanced hydrodynamicsno need for advanced hydrodynamics))

    –– Plug yourselfPlug yourself in in when the battery charge gets low when the battery charge gets low..((no need for electrochemical theoryno need for electrochemical theory))

  • CSKCSK vs vs.. Scientific Knowledge Scientific Knowledge

    –– CSKCSK is adequate for many of the things that is adequate for many of the things thathumans wanthumans want to to do do..

    –– Scientific knowledge gradually separated itselfScientific knowledge gradually separated itselffromfrom CSK, CSK, seking more precise descriptions of seking more precise descriptions ofour worldour world..

    –– For many tasks theFor many tasks the simple simple knowledge possessed knowledge possessedby tenby ten--yearyear--olds is requiredolds is required..

    –– Once we figure out howOnce we figure out how to to represent that represent thatknowldegeknowldege,, it ought it ought to to be more tractable than be more tractable thanusing overly detailed scientific knowledgeusing overly detailed scientific knowledge..

  • DifficultiesDifficulties in in Representing Representing CSK CSK

    –– Its sheer bulkIts sheer bulk

    –– Expert knowledge can be compartmentalizedExpert knowledge can be compartmentalized..

    –– AA few hundred or few hundred or a a few thousand facts are are few thousand facts are aresufficientsufficient to to build useful expert systems build useful expert systems..

    –– How many rulesHow many rules will will be needed by be needed by a a system systemcapable of generalcapable of general human- human-level intelligencelevel intelligence??

  • DifficultiesDifficulties in in Representing Representing CSK (2) CSK (2)

    –– „…„… there is probably no there is probably no elegant, elegant, effortless way effortless way to toobtain thisobtain this immense immense knowledge base knowledge base.. Rather Rather,, the thebulk of the effort mustbulk of the effort must ( (atat least least initially initially)) be bemanual entry of assertion after assertionmanual entry of assertion after assertion.“.“[[Doug LenatDoug Lenat, CYC], CYC]

  • DifficultiesDifficulties in in Representing Representing CSK (3) CSK (3)

    –– Interdependent knowldegeInterdependent knowldege: CSK: CSK seems seems not to not tohavehave well- well-defined frontiersdefined frontiers..

    –– DifficultDifficult to to get get a a grip on parts independent of the grip on parts independent of theother partsother parts..

    –– DifficultDifficult to to conceptualize conceptualize..

    –– Knowledge about some topics doesnKnowledge about some topics doesn‘t‘t seem seem to to be beeasily captured by declarative sentenceseasily captured by declarative sentences..

  • DifficultiesDifficulties in in Representing Representing CSK (4) CSK (4)

    –– CanCan a human face a human face be sescribed be sescribed in in words words so so that it that itcan be recognized by another personcan be recognized by another person??

    –– …… who hasn who hasn‘t‘t seen it before seen it before??

    –– How do we use wordsHow do we use words to to capture capture•• aa tree tree,,

    •• aa mountain view mountain view

    •• aa tropical sunset tropical sunset

    •• ......

  • Importance ofImportance of CSK CSK

    Machines with common sense wouldMachines with common sense would find findmany commercially valuable applicationsmany commercially valuable applications..–– „„household robothousehold robot““

    CommonsenseCommonsense knowledge is what is needed knowledge is what is needed to tomake expert systems more usefulmake expert systems more useful..–– Recognize when the user wants informationRecognize when the user wants information

    outside of its specialized areaoutside of its specialized area..

    –– Predict more accurately when its knowledge isPredict more accurately when its knowledge isrelevant torelevant to the task at hand the task at hand

  • Importance ofImportance of CSK (2) CSK (2)

    –– Structure ofStructure of CSK CSK important important in in expanding the expanding theknowledge of expert systemsknowledge of expert systems

    –– Analogies and metaphors are part of our ownAnalogies and metaphors are part of our ownreasoningreasoning; in; in particular particular,, spacial metaphors spacial metaphors::

    •• QuantumQuantum electrodynamics is electrodynamics is beyondbeyond our our limitlimit of ofknowledgeknowledge..

    •• Cleanliness is Cleanliness is nextnext to to godliness godliness..

    •• MaryMary‘s‘s salary is salary is aboveabove John John‘s.‘s.

  • Importance ofImportance of CSK (3) CSK (3)

    –– „An„An expert system possessing expert system possessing a a basic basiccommonsense conceptualization of the worldcommonsense conceptualization of the worldmight already bemight already be well well equipped equipped to to expand its expand itsknowledge base with little augmentation orknowledge base with little augmentation orrevisionrevision.“ [.“ [NilssonNilsson, 1998, p. 305], 1998, p. 305]

    –– CSKCSK is required is required to to understand understand natural natural language language..

  • EffortsEfforts to to Represent Represent CSK CSK

    –– Objects and materialsObjects and materials::The world consists of objectsThe world consists of objects..

    •• discretediscrete (e.g., solid (e.g., solid blocks blocks))

    •• hierarchicalhierarchical,, consisting of parts consisting of parts,, put together put together in a in a certain certainfashionfashion

    •• fluids and gasesfluids and gases

    •• collectionscollections (e.g., (e.g., piles of sand piles of sand,, bags of flour bags of flour,, galaxies galaxies))

  • EffortsEfforts to to Represent Represent CSK (2) CSK (2)

    –– SpaceSpace::The physical world has spatial extentThe physical world has spatial extent..

    •• LocationLocation:: inside inside,, above above,, and next and next to to other things other things

    •• Size and shapeSize and shape

    •• Spatial reasoningSpatial reasoning

    –– Physical propertiesPhysical properties::•• MassMass,, temperature temperature,, volume volume,, pressure pressure,, radiation level radiation level,,

    wavelengthwavelength,, and any relations among them and any relations among them

  • EffortsEfforts to to Represent Represent CSK (3) CSK (3)

    –– Physical processes and eventsPhysical processes and events

    •• ObjectsObjects fall, fall, balls are thrown balls are thrown,, grass grows grass grows,, glasses are glasses arefilled and emptiedfilled and emptied,, candles burn candles burn,, hot objects hot objects cool, … cool, …

    •• DifferentialDifferential equations might be used equations might be used,, but solutions might but solutions mightbe too exact forbe too exact for AI AI context context

    •• QualitativeQualitative physics physics:: general trends can be inferred general trends can be inferredwithout the need for exact calculationwithout the need for exact calculation..

  • EffortsEfforts to to Represent Represent CSK (4) CSK (4)

    –– Time:Time:ProcessesProcesses ( (including computationincluding computation)) occur occur in time. in time.

    •• TemporalTemporal logics logics

    •• SituationsSituations as snapshots of the world at unspecified times as snapshots of the world at unspecified times

    •• Situations are linked by actions that transform oneSituations are linked by actions that transform onesituation into anothersituation into another

    •• TimeTime and and time time intervals included among the entities that intervals included among the entities thatare explicitly reasoned aboutare explicitly reasoned about..

  • ExampleExample:: Representing Representing Time Time

    –– Time (Time (contcont.):.):Relations between intervalsRelations between intervals

    •• TimeTime is something that events and processes occur is something that events and processes occur in. in.

    •• IntervalsIntervals are used as containers for events and processes are used as containers for events and processes..

    •• ExampleExample:: denote denote time time intervals by predicate intervals by predicate--calculuscalculusobject constantsobject constants::

    OccursOccurs(E, I):(E, I): event event E E fully occupies the intervalfully occupies the interval I. I.

  • ExampleExample:: Representing Representing Time (2) Time (2)

    –– TimeTime intervals have beginning and ending intervals have beginning and ending timetimepointspoints,, denoted by functions denoted by functions startstart and and endend..

    –– BasicBasic fact fact::

    –– RelationsRelations:: ( )[ ( ) ( )]∀ ≤x start x end x( )[ eets( ) ( ( )=start(y))]∀ ≡x y M x y end x, ,

    ( )[ ( ) (Meets( ) Meets(z,y))]∀ ≡ ∃ ∧x y Before x y z x z, , ( ) ,

    ( )[ ( ) [end(x) < start(y)]]∀ ≡x y Before x y, ,

  • ExampleExample:: Representing Representing Time (3) Time (3)

    –– RelationsRelationsbetweenbetweentimetimeintervalsintervals

    [Nilsson, 1998]

  • ExampleExample:: Representing Representing Time (4) Time (4)

    –– Bath tubBath tub::Water flowing out ofWater flowing out of a a faucet is preceded by faucet is preceded byturningturning a a valve counterclockwise valve counterclockwise,, and followed and followedby turningby turning a a valve clockwise valve clockwise..

    ( ){ ( , ) ( , )[( ( _ , ) ( _ , ) ( , ) ( , )]}

    ∀⊃ ∃ ∧

    ∧ ∧

    y Occurs Flow yx z Occurs Turn ccw x Occurs Turn cw z

    Overlaps x y Overlaps y z

  • 3.3. Knowledge Representation,Knowledge Representation,Reasoning, and PlanningReasoning, and Planning

    3.13.1 Common Sense KnowledgeCommon Sense Knowledge

    3.23.2 Knowledge Representation NetworksKnowledge Representation Networks

    3.33.3 ReasoningReasoning–– PropositionalPropositional Logic Logic

    –– Predicate Logic: PROLOGPredicate Logic: PROLOG

    3.43.4 PlanningPlanning

  • Networks for Knowledge RepresentationNetworks for Knowledge Representation

    –– Taxonomic KnowledgeTaxonomic Knowledge

    –– Semantic NetworksSemantic Networks

    –– Nonmonotonic ReasoningNonmonotonic Reasoning in in Semantic Networks Semantic Networks

    –– FramesFrames

  • Taxonomic KnowledgeTaxonomic Knowledge

    –– Entities of both commonsense and expertEntities of both commonsense and expertknowledge domains can be arrangedknowledge domains can be arranged in inhierarchical structureshierarchical structures::

    •• toto organize and organize and

    •• simplify reasoningsimplify reasoning..

    –– Networks or Networks or frameframe data structures can be used data structures can be usedfor representationfor representation..

  • Taxonomic KnowledgeTaxonomic Knowledge (2) (2)

    –– ExampleExample: CYC (: CYC (GuhaGuha & & Lenat Lenat))In CYCIn CYC there are several kinds of there are several kinds of thingsthings::

    •• ObjectsObjects in in the world the world

    •• Mathematical objectsMathematical objects

    •• Events and processesEvents and processes

    •• ……

    –– Hierarchy implicitly encodes facts of the formHierarchy implicitly encodes facts of the form::•• „X„X is is a P.“ a P.“

    •• All P‘sAll P‘s are are Q‘s.“ Q‘s.“

    •• All Q‘sAll Q‘s are are R‘s.“ R‘s.“

  • Taxonomic Knowledge (3)Taxonomic Knowledge (3)

    –– Snoopy is a laser printer. All laser printers areSnoopy is a laser printer. All laser printers areprinters. All printers are machines. (… and someprinters. All printers are machines. (… and somerelated information)related information)

    –– Predicate calculus:Predicate calculus:

    Laser pr er Snoopy_ int ( )

    ( )[Laser_printer( ) ( )]∀ ⊃x x er x Print

    ( )[Printer( ) ( )]∀ ⊃x x Office machine x _

  • Taxonomic Knowledge (3)Taxonomic Knowledge (3)

    –– Snoopy is a laser printer. All laser printers areSnoopy is a laser printer. All laser printers areprinters. All printers are machines. (… and someprinters. All printers are machines. (… and somerelated information)related information)

    –– Predicate calculus:Predicate calculus:

    Laser pr er Snoopy_ int ( )

    ( )[Laser_printer( ) ( )]∀ ⊃x x er x Print

    ( )[Printer( ) ( )]∀ ⊃x x Office machine x _

    Categories

  • Taxonomic Knowledge (3)Taxonomic Knowledge (3)

    –– Snoopy is a laser printer. All laser printers areSnoopy is a laser printer. All laser printers areprinters. All printers are machines. (… and someprinters. All printers are machines. (… and somerelated information)related information)

    –– Predicate calculus:Predicate calculus:

    –– Transitivity:Transitivity:

    Laser pr er Snoopy_ int ( )

    ( )[Laser_printer( ) ( )]∀ ⊃x x er x Print

    ( )[Printer( ) ( )]∀ ⊃x x Office machine x _

    ( )[Laser_printer( ) ( )]∀ ⊃x x Office machine x _Office machine Snoopy_ ( )

  • Semantic NetworksSemantic Networks

    –– Nodes labeled by relation constants correspondNodes labeled by relation constants correspondto either taxonomic categories or properties.to either taxonomic categories or properties.

    –– Nodes labeled by object constants correspond toNodes labeled by object constants correspond toobjects in the domain.objects in the domain.

    –– Three kinds of arcs:Three kinds of arcs:•• Subset arcs (Subset arcs (isaisa links)links)

    •• Set membership arcs (Set membership arcs (instanceinstance links) links)

    •• Function arcsFunction arcs

  • Semantic Networks (2)Semantic Networks (2)

    [Nilsson, 1998]

  • Semantic Networks (3)Semantic Networks (3)

    –– Example: R2D2 is an office machine.Example: R2D2 is an office machine.

    [Nilsson, 1998]

  • Semantic Networks (4)Semantic Networks (4)

    –– Example: Snoopy is connected to the wall outlet.Example: Snoopy is connected to the wall outlet.

    [Nilsson, 1998]

  • FramesFrames

    PrintersPrinterssubset_of: Office_machinessubset_of: Office_machinessuperset_of:superset_of:

    { Laser_printers, Ink_jet_printers }{ Laser_printers, Ink_jet_printers }

    energy_source: Wall_outletenergy_source: Wall_outlet

    creator: John_Jonescreator: John_Jonesdate: 16_Aug_91date: 16_Aug_91

    Frame nameSlot name

    slots

    Slot fillers

    Meta information

  • 3.3. Knowledge Representation,Knowledge Representation,Reasoning, and PlanningReasoning, and Planning

    3.13.1 Common Sense KnowledgeCommon Sense Knowledge

    3.23.2 Knowledge Representation NetworksKnowledge Representation Networks

    3.33.3 ReasoningReasoning–– PropositionalPropositional Logic Logic

    –– Predicate Logic: PROLOGPredicate Logic: PROLOG

    3.43.4 PlanningPlanning

  • PropositionalPropositional Logic Logic

    A A logic systemlogic system consists of four parts: consists of four parts:–– AlphabetAlphabet: a set of basic symbols from which: a set of basic symbols from which

    more complex sentences (constructions) aremore complex sentences (constructions) aremademade

    –– SyntaxSyntax: a set of rules or operators for: a set of rules or operators forconstructing sentences (expressions)constructing sentences (expressions)

    –– SemanticsSemantics: for defining the meaning of the: for defining the meaning of thesentences in the logic systemsentences in the logic system

    –– Inference rulesInference rules: for constructing semantically: for constructing semanticallyequivalent but syntactically different sentencesequivalent but syntactically different sentences

  • PropositionalPropositional Symbols Symbols

    A A propositionalpropositional symbol represents a symbol represents a statementstatementabout the world, for example,about the world, for example,“The temperature is over 120.”“The temperature is over 120.”

    The semantic The semantic meaningmeaning of a of a propositionalpropositionalsymbol is expressed by two symbol is expressed by two semanticalsemanticalsymbols: symbols: truetrue or or falsefalse..

  • Syntactic ConnectivesSyntactic Connectives

    For constructing more complexFor constructing more complexpropositions:propositions:

    •• ∧∧ AND, conjunctionAND, conjunction•• ∨∨ OR, disjunctionOR, disjunction•• ¬¬ NOT, negationNOT, negation•• →→ implicationimplication•• = = equalityequality

  • Syntactic Connectives: SemanticsSyntactic Connectives: Semantics

    Truth Table:Truth Table:

    P P Q Q PP∧∧QQ PP∨∨QQ PP→→QQ P=QP=Q ¬¬PP ¬¬QQTT TT T T T T T T T T F F F F

    TT FF F F T T F F F F F F T T

    FF TT F F T T T T F F T T F F

    FF FF F F F F T T T T T T T T

    All laws of inference can be proved for correctnessAll laws of inference can be proved for correctnessusing the truth table, that is, by comparing theusing the truth table, that is, by comparing theresulting truth values.resulting truth values.

  • Prop. Logic: Laws of InferenceProp. Logic: Laws of Inference

    Modus Modus ponensponens:: P P →→ Q, and P Q, and P ∴∴ Q QModus Modus tollenstollens:: P P →→ Q, and Q, and ¬¬Q Q ∴∴ ¬¬PP

    Laws of De Morgan:Laws of De Morgan: ¬¬(P (P ∧∧ Q) Q) ∴∴ ¬¬P P ∨∨ ¬¬QQ ¬¬(P (P ∨∨ Q) Q) ∴∴ ¬¬P P ∧∧ ¬¬QQ

    Law of syllogism:Law of syllogism: P P →→ Q, and Q Q, and Q →→ R R ∴∴ P P →→ R R

    Law of Law of contrapositivecontrapositive:: P P →→ Q Q ∴∴ ¬¬Q Q →→ ¬¬PP

  • Syntactic Connectives: SemanticsSyntactic Connectives: Semantics

    Truth Table:Truth Table:Modus Modus ponensponens

    P P Q Q PP∧∧QQ PP∨∨QQ PP→→QQ P=QP=Q ¬¬PP ¬¬QQTT TT T T T T TT T T F F F F

    TT FF F F T T F F F F F F T T

    FF TT F F T T T T F F T T F F

    FF FF F F F F T T T T T T T T

    All laws of inference can be proved for correctnessAll laws of inference can be proved for correctnessusing the truth table, that is, by comparing theusing the truth table, that is, by comparing theresulting truth values.resulting truth values.

    P → Q, and P ∴ Q

  • Syntactic Connectives: SemanticsSyntactic Connectives: Semantics

    Truth Table:Truth Table:Modus Modus tollenstollens

    P P Q Q PP∧∧QQ PP∨∨QQ PP→→QQ P=QP=Q ¬¬PP ¬¬QQTT TT T T T T T T T T F F F F

    TT FF F F T T F F F F F F T T

    FF TT F F T T T T F F T T F F

    FF FF F F F F TT T T TT TT

    All laws of inference can be proved for correctnessAll laws of inference can be proved for correctnessusing the truth table, that is, by comparing theusing the truth table, that is, by comparing theresulting truth values.resulting truth values.

    P → Q, and ¬Q ∴ ¬P

  • Prop. Logic: Simple Knowledge BaseProp. Logic: Simple Knowledge Base

    PL is a useful way to represent a simplePL is a useful way to represent a simpleknowledge base:knowledge base:

    –– IF (temperature is above 120) THEN (there isIF (temperature is above 120) THEN (there isoverheating)overheating)

    –– (there is overheating) (there is overheating) ∨∨ (the brakes react slowly) (the brakes react slowly)→→ (stop the car) (stop the car)

    –– (the cooling temperature is over 120) (the cooling temperature is over 120) ∧∧ (the gauge (the gaugeworks properly) works properly) →→ (there is overheating) (there is overheating)

  • Problems with Prop. LogicProblems with Prop. Logic

    Major problem: PL can only deal withMajor problem: PL can only deal withcomplete statements.complete statements.

    PL cannot examine the internal structure of aPL cannot examine the internal structure of astatement.statement.

  • Prop. Logic: Inference not possibleProp. Logic: Inference not possible

    The following inference is not possible inThe following inference is not possible inpropositionalpropositional logic: logic:

    –– All humans are mortal.All humans are mortal.

    –– Socrates is a human.Socrates is a human.

    –– Therefore, Socrates is mortal.Therefore, Socrates is mortal.

    PL cannot even prove the validity of a simplePL cannot even prove the validity of a simplesyllogism like this.syllogism like this.

  • 3.3. Knowledge Representation,Knowledge Representation,Reasoning, and PlanningReasoning, and Planning

    3.13.1 Common Sense KnowledgeCommon Sense Knowledge

    3.23.2 Knowledge Representation NetworksKnowledge Representation Networks

    3.33.3 ReasoningReasoning–– PropositionalPropositional Logic Logic

    –– Predicate Logic: PROLOGPredicate Logic: PROLOG

    3.43.4 PlanningPlanning

  • Predicate LogicPredicate Logic

    The following types of symbols are allowed inThe following types of symbols are allowed inPredPred. Logic:. Logic:

    –– TermsTerms::

    •• Constant symbolsConstant symbols: symbols, expressions, or entities: symbols, expressions, or entitieswhich do not change during execution (e.g., true / false)which do not change during execution (e.g., true / false)

    •• Variable symbolsVariable symbols: represent entities that can change: represent entities that can changeduring executionduring execution

    •• Function symbolsFunction symbols: represent functions which process: represent functions which processinput values on a predefined list of parameters, andinput values on a predefined list of parameters, andobtain resulting valuesobtain resulting values

  • Predicate LogicPredicate Logic

    –– PredicatesPredicates::

    •• Predicate symbolsPredicate symbols: represent true/false-type relations: represent true/false-type relationsbetween objects. Objects are represented by constantbetween objects. Objects are represented by constantsymbols.symbols.

    Example: Example: father(person, person)father(person, person) and andfather(John, William)father(John, William) are predicates. are predicates.

  • Predicate LogicPredicate Logic

    –– Connective symbols:Connective symbols:are the same as those valid for are the same as those valid for propositional propositional calculuscalculus

    •• ConjunctionConjunction

    •• DisjunctionDisjunction

    •• NegationNegation

    •• ImplicationImplication

    •• equivalenceequivalence

  • Predicate LogicPredicate Logic

    –– Quantifiers:Quantifiers:are valid for variable symbolsare valid for variable symbols

    •• ∃∃xx — — existential quantifierexistential quantifier: “there exists at least one value for: “there exists at least one value forx from its domain”x from its domain”

    •• ∀∀xx — — universal quantifieruniversal quantifier: “for all x in its domain”: “for all x in its domain”

    Socrates syllogism:Socrates syllogism:

    ∀∀x, Human(x) x, Human(x) →→ Mortal(x). Mortal(x).Human(Socrates).Human(Socrates).

  • First-Order LogicFirst-Order Logic

    First-Order Logic allows quantified variables toFirst-Order Logic allows quantified variables torefer to objects, but not to predicates orrefer to objects, but not to predicates orfunctions.functions.

    For applying an For applying an inferenceinference to a set of predicate to a set of predicateexpressions, the system has to process matchesexpressions, the system has to process matchesof expressions.of expressions.

    The process of matching is called The process of matching is called unificationunification..

    father(X,Y)father(X,Y) matches matches father(David,Peter).father(David,Peter).

  • SkolemizationSkolemization

    In order to not restrict the variable domains,In order to not restrict the variable domains,the existential quantifier can be replaced by athe existential quantifier can be replaced by aso-called so-called skolem skolem function:function:

    ∀∀ X, human(X) X, human(X) →→ ∃∃ Y, mother(Y,X) Y, mother(Y,X)

    can be can be skolemized skolemized with with skolemskolem function function ff to: to:

    ∀∀ X, human(X) X, human(X) →→ mother( mother(ff(X),X).(X),X).

  • Programming in Logic: PROLOGProgramming in Logic: PROLOG

    In PROLOG, a quantifier-free, so-called Horn-In PROLOG, a quantifier-free, so-called Horn-clausal clausal notation is adopted.notation is adopted.

    First-order predicate logic systems can beFirst-order predicate logic systems can beadequately represented.adequately represented.

    Socrates syllogism in PROLOG:Socrates syllogism in PROLOG:

    mortal(X) :– human(X).mortal(X) :– human(X).human(Socrates).human(Socrates).

  • PROLOG: Horn ClausesPROLOG: Horn Clauses

    A ruleA rule(A(A11, A, A22, …, A, …, Ann) ) →→ B B

    as a Horn-clause has the following form:as a Horn-clause has the following form:

    B :– AB :– A11, A, A22, …, A, …, Ann

    which means that the goal B is true if all thewhich means that the goal B is true if all thesubgoalssubgoals A A11, A, A22, …, A, …, Ann are also true. are also true.

    AA11, A, A22, …, A, …, Ann are predicate expressions. are predicate expressions.

  • PROLOG: FactsPROLOG: Facts

    A fact is represented as a literal clause with theA fact is represented as a literal clause with theright side being the constant “true”.right side being the constant “true”.

    Therefore, a clause representing a fact isTherefore, a clause representing a fact isalways true.always true.

    human(Socrates) :– true.human(Socrates) :– true.or shortlyor shortly

    human(Socrates).human(Socrates).

  • PROLOG: Knowledge RepresentationPROLOG: Knowledge Representation

    Knowledge is represented as a set of clausesKnowledge is represented as a set of clauseswhich havewhich have–– premises (right side of the clause) andpremises (right side of the clause) and

    –– one conclusion (left side).one conclusion (left side).

    –– AND is denoted by the character “,”AND is denoted by the character “,”

    –– OR is denoted by “;”OR is denoted by “;”

    –– NOT is denoted by “NOT is denoted by “¬¬””

  • PROLOG ProgramsPROLOG Programs

    A (declarative-type) program in PROLOGA (declarative-type) program in PROLOGconsists of clauses and facts.consists of clauses and facts.

    A backward chaining inference engine isA backward chaining inference engine isimplicitly built in.implicitly built in.

    The inference engine starts when a goal isThe inference engine starts when a goal isgiven.given.

    A goal can only be a predicate used in theA goal can only be a predicate used in theprogram.program.

  • PROLOG Structure and ProgramPROLOG Structure and Program

    [Kasabov, 1996]

  • Family Relationship ExampleFamily Relationship Example

    (* facts — defining the existing initial facts *)(* facts — defining the existing initial facts *)father(John, Mary).father(John, Mary).

    father(Jack, Andy).father(Jack, Andy).

    father(Jack, Tom).father(Jack, Tom).

    mother(Helen, Jack).mother(Helen, Jack).

    mother(Mary, mother(Mary, JillyJilly).).

    grandfather(Barry, Jim).grandfather(Barry, Jim).

  • Family Relationship ExampleFamily Relationship Example

    (* rules — defining the knowledge base of rules *)(* rules — defining the knowledge base of rules *)

    grandfather(X,Y)grandfather(X,Y):– father(X,Z), parent(Z,Y).:– father(X,Z), parent(Z,Y).

    grandmother(X,Y)grandmother(X,Y):– mother(X,Z), parent(Z,Y).:– mother(X,Z), parent(Z,Y).

    parent(X,Y) :– mother(X,Y).parent(X,Y) :– mother(X,Y).

    parent(X,Y) :– father(X,Y).parent(X,Y) :– father(X,Y).

  • PROLOG Sample DialoguePROLOG Sample Dialogue

    Goal?– grandfather(John, Goal?– grandfather(John, JillyJilly).).

    yesyes

    Goal?– grandmother(Helen, X).Goal?– grandmother(Helen, X).

    2 solutions2 solutions

    X = AndyX = Andy X = TomX = Tom

    Goal?– grandmother(X,Y), X = Y.Goal?– grandmother(X,Y), X = Y.

    failfail

  • Goal?– grandfather(John, Jilly).

    grandfather(John, Jilly)

    father(John, Z) parent(Z, Jilly)

    mother(Z, Jilly) father(Z, Jilly)

    AND

    ORMary

    Mary

    yes

    father(John, Mary).father(Jack, Andy).father(Jack, Tom).

    mother(Helen, Jack).mother(Mary, Jilly).

    grandfather(Barry, Jim).

  • Goal?– grandmother(Helen, X).

    grandmother(Helen, X)

    mother(Helen, Z) parent(Z, X)

    mother(Z, X) father(Z, X)

    AND

    ORJack

    Jack

    2 solutions: X= Andy or X= Tom

    AndyTom

    father(John, Mary).father(Jack, Andy).father(Jack, Tom).

    mother(Helen, Jack).mother(Mary, Jilly).

    grandfather(Barry, Jim).

  • 3.3. Knowledge Representation,Knowledge Representation,Reasoning, and PlanningReasoning, and Planning

    3.13.1 Common Sense KnowledgeCommon Sense Knowledge

    3.23.2 Knowledge Representation NetworksKnowledge Representation Networks

    3.33.3 ReasoningReasoning–– PropositionalPropositional Logic Logic

    –– Predicate Logic: PROLOGPredicate Logic: PROLOG

    3.43.4 PlanningPlanning

  • ReferencesReferences

    • Nilsson, N. (1998). Artificial Intelligence — A New Synthesis.San Francisco, CA, Morgan Kaufmann.

    • Kasabov, N. (1996). Foundations of Neural Networks, FuzzySystems, and Knowledge Engineering. Cambridge, MA, MITPress.