This action might not be possible to undo. Are you sure you want to continue?

BooksAudiobooksComicsSheet Music### Categories

### Categories

### Categories

### Publishers

Scribd Selects Books

Hand-picked favorites from

our editors

our editors

Scribd Selects Audiobooks

Hand-picked favorites from

our editors

our editors

Scribd Selects Comics

Hand-picked favorites from

our editors

our editors

Scribd Selects Sheet Music

Hand-picked favorites from

our editors

our editors

Top Books

What's trending, bestsellers,

award-winners & more

award-winners & more

Top Audiobooks

What's trending, bestsellers,

award-winners & more

award-winners & more

Top Comics

What's trending, bestsellers,

award-winners & more

award-winners & more

Top Sheet Music

What's trending, bestsellers,

award-winners & more

award-winners & more

P. 1

Ai Knowledge Representation|Views: 56|Likes: 1

Published by Mandeep Singh Dhaliwal

See more

See less

https://www.scribd.com/doc/71564177/Ai-Knowledge-Representation

11/27/2012

text

original

,

2007, Lecture 15 to 22 (8 hrs) Slides 1 to 79 (Revised – Feb. 02, 2008)

myreaders , http://myreaders.wordpress.com/ , rcchak@gmail.com

**Artificial Intelligence Knowledge Representation
**

Issues, Predicate Logic, Rules

(Lectures 15, 16, 17, 18, 19, 20, 21, 22

Topics

8 hours)

Slides 03-26

1. Knowledge Representation Introduction – KR model, typology, relationship, framework, mapping, forward KR & backward schemes representation, relational, system requirements; inheritable,

inferential, declarative, procedural; relationship, granularity. 2. KR Using Predicate Logic Logic representation, tautologies, argument;

**KR issues - attributes,
**

27-47

Propositional logic antecedent,

statements, consequent, quantifiers,

variables, symbols, connective, truth value, contingencies, contradictions, Predicate logic - expressions,

formula; Representing “IsA” and “Instance” relationships, computable functions and predicates; Resolution. 3. KR Using Rules Types of Rules declarative, procedural, meta rules; Procedural verses declarative knowledge & language; Logic programming – characteristics, Statement, language, syntax & terminology, simple & structured data objects, Program predicate, sentence, subject; Components - clause,

48-77

**Programming paradigms - models of computation, imperative model, functional model, logic model; 4. References
**

02

Forward & backward

78-79

reasoning - chaining, conflict resolution; Control knowledge.

Knowledge Representation

Issues, Predicate Logic, Rules

How do we represent what we know ?

**• Knowledge is a general term.
**

An answer to the question, "how to represent knowledge", requires an analysis to distinguish between knowledge “how” ■ knowing "how to do something". e.g. "how to drive a car" is Procedural knowledge. ■ knowing "that something is true or false". e.g. "that is the speed limit for a car on a motorway" is Declarative knowledge. and knowledge “that”.

**• knowledge and Representation are distinct entities that play a central
**

but distinguishable roles in intelligent system. ■ Knowledge is a description of the world. It determines a system's competence by what it knows. ■ Representation is the way knowledge is encoded. It defines the performance of a system in doing something.

**• Different types of knowledge require different kinds of representation.
**

The Knowledge Representation models/mechanisms are often based on: ◊ Logic ◊ Frames ◊ Rules ◊ Semantic Net

**• Different types of knowledge require different kinds of reasoning.
**

03

■ Wisdom is the pinnacle of the : Example : Encompasses understanding of all the interactions raining. disconnected facts. • Knowledge Progression Organizing Interpretation Data Analyzing Information Evaluation Understanding Knowledge Principles Wisdom Fig 1 Knowledge Progression ■ Data is viewed as collection of : Example : It is raining. and "when". and raining. understanding. changes. ■ Knowledge relationships emerges among : Example : If the humidity is very high and the temperature drops substantially. temperature that happen air between currents. describe patterns. we understand what the data means. to "who". so it rains. ■ Information established Provides emerges and when : Example : The temperature dropped 15 degrees and then it started raining. "where". By organizing or analyzing the data. relationships among facts are understood. Introduction Knowledge is a general term. then atmospheres is unlikely to hold the moisture.KR -Introduction 1. and this becomes information. Knowledge is a progression that starts with data which is of limited utility. 04 gradients. . Provides answers as "how" . are identified and understood. The interpretation or evaluation of information yield knowledge. uncovers principles of relationships that Provides answers as "why" . An understanding of the principles embodied within the knowledge is wisdom. evaporation. when patterns answers "what".

they are based on the gathering of facts and adding context. rather than for what is or was. the transitions are from data. that as the degree of “connectedness” and “understanding” increase. information. and finally to wisdom. to information. data and information deal with the past. knowledge. acquire vision for what will be. Knowledge Model Data Degree of Understanding The model represents transitions and understanding. They are white (Shedroff. wisdom deals with the future. the understanding support the transitions from one stage to the next stage. 05 more like shades of gray. rather than black and .• Knowledge Model (Bellinger 1980) KR -Introduction The model tells. The distinctions between data. knowledge deals with the present that enable us to perform. Degree of Connectedness Wisdom Understanding principles Knowledge Understanding patterns Information Understanding relations Fig. and wisdom are not very discrete. we progress from data through information and knowledge to wisdom. 2001). to knowledge.

procedure. process. concepts. ◊ Can be articulated formally. ◊ Drawn from experience. action. term “Tacit” corresponds to informal or implicit type of knowledge. ◊ Exists outside a human being. processed and stored. ◊ Hard to steal or copy. subjective insight. ◊ Can be shared. ◊ Difficult to articulate formally. ◊ Difficult to share/communicate. it is embedded. it is embodied. copied.KR -Introduction • Knowledge Type Knowledge is categorized into two major types: Tacit and term “Explicit” corresponds to formal type of knowledge. ◊ Drawn from artifact of some type as [The next slide explains more about tacit and explicit knowledge.] 06 . Tacit knowledge Explicit knowledge Explicit. ◊ Easy to steal or copy principle. ◊ Exists within a human being.

These artifacts are used in the knowledge creation process to create two types of knowledge: declarative and procedural explained below. action. principles allow to make predictions and draw implications. Doing (action) and Explicit knowledge comes from principle. ◊ Procedures : are series of step-by-step actions and decisions that result in the achievement of a task. principles are the basic building blocks of theoretical models (theories). process.KR -Introduction ■ Knowledge typology map The map shows that. rules. ◊ Principles : are guidelines. and parameters that govern. Knowledge Typology Map ◊ Facts : are data or instance that are specific and unique. procedure. 07 . Tacit knowledge comes from experience. or ideas that are known by a common name and share common features. ◊ Concepts : are class of items. subjective insight type. via transcribed content or artifact of some Experience Principles Procedure Tacit Knowledge Explicit Knowledge Process Subjective Insight Knowledge Concept Context Information Data Facts Fig. ◊ Processes : are flow of events or activities that describe how things work rather than how to do things. words. concepts.

first find Note : About procedural knowledge. agendas. The strategic knowledge is thought as a subset of declarative knowledge. Procedural knowledge ◊ examples : procedures. it is knowledge that can be and has been articulated. four tyres. that it is close to Tacit knowledge. about do ◊ Knowledge about "that something e. objects. it manifests itself in the doing of some-thing yet cannot be expressed in words. semantic rules. e. logic and descriptive models.KR -Introduction • Knowledge Type Cognitive psychologists sort knowledge into Declarative and Procedural category and some researchers added Strategic as a third category. A car has older than Peter or Robert is older.. ◊ focuses on tasks to that a "how must be ◊ refers to representations of objects and events.g. the difference is that a task or method is described instead of facts or things. strategies. models.g. there is some disparity in views. nets. Declarative knowledge propositions. knowledge about facts and relationships.. to determine if is true or false". e. we read faces and moods. − Another view is. assertions. 08 . that it is close to declarative knowledge.g.. performed reach particular to objective or goal. All declarative knowledge are explicit knowledge. facts. − One view is. ◊ example : concepts. Peter is Robert. their ages. ◊ Knowledge something".

indicate the strong relationships exist among them. Knowledge Start Has been articulated No Can not be articulated Yes Implicit Yes Explicit Facts and things No Tacit Motor Skill (Manual) Describing Tasks and methods Declarative Procedural Doing Mental Skill Fig. − all procedural knowledge as tacit. we may view. we often "know about" before we "know how". i. tacit. declarative knowledge is tied to "describing" and procedural knowledge is tied to "doing." − The arrows connecting explicit with declarative and tacit with procedural. 09 . Therefore. and − all declarative knowledge as explicit.. Relationship among types of knowledge The Figure shows. − The arrow connecting declarative and procedural indicates that we often develop procedural knowledge as a result of starting with declarative knowledge. implicit.KR -Introduction • Relationship among knowledge type The relationship among explicit. declarative and procedural knowledge are illustrated below.e.

− This output can then be represented in a informally described solution that user understands or checks for consistency.1 Framework of Knowledge Representation (Poole 1998) Computer requires a well-defined problem description to process and also provide well-defined acceptable solution. 10 . The computer can then use an algorithm to compute an answer. and − conversion of informal (implicit) knowledge to formal (explicit) knowledge. Problem Represent Solve Solution Interpret Informal Formal Compute Representation Output Fig. This process is illustrated below. Note : The Problem solving requires − formal knowledge representation. − It is then represented formally and the computer produces an output. Knowledge Representation Framework The steps are − The informal formalism of the problem takes place first. To collect fragments of knowledge we need : first to formulate description in our spoken language and then represent it in formal language so that computer can understand.KR -framework 1.

framework • Knowledge and Representation Problem solving requires large amount of knowledge and some mechanism for manipulating that knowledge. The Knowledge and the Representation are distinct entities. . we : − need to know about things we want to represent . it defines the system's performance in doing something. and − need some means by which things we can manipulate.KR . Thus. . play a central but distinguishable roles in intelligent system.facts about objects in the domain.to what we represent . knowledge representation can be considered at two levels : (a) knowledge level at which facts are described.knowledge about how to do things ‡ Meta-knowledge . 11 . can be manipulated in the programs. − Representation is the way knowledge is encoded. defined in terms of symbols. − Knowledge is a description of the world.knowledge about what we know ◊ need means to manipulate ‡ Requires some formalism . and (b) symbol level at which the representations of the objects. it determines a system's competence by what it knows. ◊ know things to represent ‡ Objects ‡ Events ‡ Performance .actions that occur in the domain. Note : A good representation enables fast and accurate access to knowledge and understanding of the content. In simple words.

We need a representation of facts that can be manipulated by a program. Example : Consider an English sentence Reasoning programs Facts Internal Representation English understanding English generation English Representation Facts Representations A fact represented in English sentence Using forward mapping function the above fact is represented in logic A logical representation of the fact that "all dogs have tails" ◊ Spot is a dog ◊ dog (Spot) ◊ ∀ x : dog(x) → hastail (x) Now using deductive mechanism we can generate a new representation of object : ◊ hastail (Spot) ◊ Spot has a tail [it is new knowledge] 12 A new object representation Using backward mapping function to generate English sentence . we must be able to map "facts to symbols" and "symbols to facts" using forward and backward representation mapping.KR . Thus some symbolic representation is necessary. too hard currently for a computer program to draw inferences in natural languages. Therefore. Normal English is insufficient.framework • Mapping between Facts and Representation Knowledge is a collection of “facts” from some domain.

■ Forward and Backward representation KR . 13 . ‡ The solid lines on bottom indicates the concrete reasoning process that the program performs.framework The forward and backward representations are elaborated below : Desired real reasoning Initial Facts Forward representation mapping Final Facts Backward representation mapping Internal Representation Operated by program English Representation ‡ The doted line on top indicates the abstract reasoning process that a program is intended to model.

◊ Inferential Efficiency The ability to incorporate additional information into the knowledge structure that can be used to focus the attention of the inference mechanisms in the most promising direction. ◊ Acquisitional Efficiency The ability to acquire new knowledge using automatic methods wherever possible rather than reliance on human intervention. ◊ Inferential Adequacy The ability to manipulate the representational structures to derive new structure corresponding to new knowledge inferred from old .framework • KR System Requirements A good knowledge representation enables fast and accurate access to knowledge and understanding of the content.KR . ◊ Representational Adequacy The ability to represent all kinds of knowledge that are needed in that domain. A knowledge representation system should have following properties. 14 . Note : To date no single system can optimizes all of the above properties.

− e. These KR schemes are detailed below in next few slides 15 . ◊ Inferential Knowledge − is inferred from objects through relations among objects. but the use to which that knowledge is to be put is not given. Inheritable. and recipes.2 knowledge Representation schemes There are four types of Knowledge representation .g. − e. computer programs. − it prescribes a structure in which new objects are created which may inherit all or a subset of attributes from existing objects. directions.g. − e.Relational. and Declarative/Procedural. these indicate specific use or implementation. laws.schemes 1. ◊ Declarative Knowledge − a statement in which knowledge is specified. Inferential. but with the help of other words in phrase the reader may infer more from a word.KR . Procedural Knowledge − a representation in which the control information. a word alone is a simple syntax. to use the knowledge. is embedded in the knowledge itself. ◊ Relational Knowledge : − provides a framework to compare two objects based on equivalent attributes. − any instance in which two different objects are compared is a relational type of knowledge.g. these are facts which can stand alone. this inference within linguistic is called semantics. ◊ Inheritable Knowledge − is obtained from associated objects.. not dependent on other knowledge. people's name.

KR . Table . then these facts will enable that procedure to compute an answer.Right Right . − This representation provides little opportunity for inference. − Relational knowledge is made up of objects consisting of attributes and their corresponding associated values.Simple Relational Knowledge Player Aaron Mays Ruth Williams Height 6-0 5-10 6-2 6-3 Weight 180 170 215 205 Bats . ‡ But if a procedure for finding heaviest player is provided.Right Left .Left Left .Throws Right .Right ‡ Given the facts it is not possible to answer simple question such as : " Who is the heaviest player ? ".schemes • Relational knowledge : associates elements of one domain with another. 16 . − The facts about a set of objects are put systematically in columns. Used to associate elements of one domain with the elements of another domain or set of design constrains. The table below shows a simple way to store facts. − The results of this knowledge type is a mapping of elements among different domains.

• Inheritable knowledge : elements inherit attributes from their parents. physical and process domains.106 Pitcher isa Fielder 0.262 instance Chicago Cubs instance Pee-WeeReese team Three Finger Brown team BrooklynDodger Fig. elements inherit attributes from their parents. Baseball knowledge − isa : show class inclusion Person handed height Right − instance : show class membership isa Adult Male 5. − Property inheritance : Objects/elements of specific classes inherit attributes and values from more general classes. not all attributes of the parent elements be prescribed to the child elements. It shows property inheritance and way for insertion of additional knowledge. − Classes are organized in a generalized hierarchy. and The KR in hierarchical structure. is called “semantic network” or a collection of “frames” or “slot-and-filler structure".10 6. KR . but in many cases. ‡ the box nodes represents objects and values of the attributes. Inheritable knowledge representation (KR) ‡ the directed arrows represent attributes (isa. shown below. Within the hierarchy.schemes The knowledge is embodied in the design hierarchies found in the functional. instance. but not adequate. [Continuing in the next slide] 17 .1 isa EQUAL handed bats Baseball Player height batting-average 0. − The basic KR needs to be augmented with inference mechanism. − Inheritance is a powerful form of inference. and team) originating at the object being described and terminating at the object or its value.252 batting-average isa batting-average 0.

then fail. If not.1 − bats(Three Finger Brown) = right [For explanation . ‡ It does describe the basic mechanism of inheritance. move to the node corresponding to that value and look for a value for the attribute A. This algorithm is simple. Find object O in the knowledge base. (a) Get the value of the “isa” attribute and move to that node. If yes. report it. (b) See if there is a value for the attribute A. 5. ‡ It does not say what to do if there is more than one value of the instance or “isa” attribute.refer book on AI by Elaine Rich & Kevin Knight. Else. see if there is a value for the attribute instance. 3.106 − height (Pee-Wee-Reese) = 6. If one is found.252 ◊ Algorithm : Property Inheritance Retrieve a value V Steps to follow: 1. do until there is no value for the “isa” attribute until an answer is found : or for an attribute A of an instance object O.1 0. Else.KR . 4 Else.schemes [Continuing from previous slide – example] ◊ Viewing a node as a frame Baseball-player isa : Bates : Height : Batting-average : Adult-Male EQUAL handed 6. 2. page 112] 18 . This can be applied to the example of knowledge base illustrated to derive answers to the following queries : − team (Pee-Wee-Reese) = Brooklyn–Dodger − batting–average(Three-Finger-Brown) = 0. If there is a value for the attribute A then report that value. report it.

" Λ " (and). − In addition to algebraic relations. 19 . land) V live (x. − Inference through predicate logic uses a set of logical operations to relate individual data.schemes • Inferential knowledge : generates new information . a predicate logic (mathematical deduction) is used to infer from a set of attributes. " ∃ " (there exists). " ∀ " (for all). " V " (or). Generates new information from the given information. Wonder is a name of a dog : 2. one may infer other values or relations. " ¬ " (not). − Given a set of relations and values. more knowledge can be inferred. All dogs belong to the class of animals : dog (wonder) ∀ x : dog (x) → animal(x) 3. water) We can infer from these three statements that : " Wonder lives either on land or on water. All animals either live on land or in water : ∀ x : animal(x) → live (x. The symbols used for the logic operations are : " → " (implication). Examples of predicate logic statements : 1.KR . This new information does not require further data gathering form source." As more information is made available about these objects and their relations. but does require analysis of the given information to generate new knowledge.

schemes • Declarative/Procedural knowledge The difference between Declarative/Procedural knowledge is not very clear. adjectives and nouns. 20 . − domains represent the physical world and the perceived functionality. the knowledge is based on declarative facts about axioms and domains. − axiom and domains thus simply exists and serve as declarative statements that can stand alone. The procedural knowledge : − may have inferential efficiency.KR . − are represented as small programs that know how to do specific things. but no inferential adequacy and acquisitional efficiency. adjectives and nouns. Procedural knowledge: Here the knowledge is a mapping process between domains that specifies “what to do when” and the representation is of “how to make it” rather than “what it is”. Declarative knowledge : Here. − axioms are assumed to be true unless a counter example is found to invalidate them. how to proceed. Example : a parser in a natural language has the knowledge that a noun phrase may contain articles. It thus accordingly call routines that know how to process articles.

Some of these are explained below. The issues that arise while using KR techniques are many.issues 1.3 Issues in Knowledge Representation The fundamental goal of Knowledge Representation is to facilitate inferencing (conclusions) from knowledge.KR . Inheritable KR. 21 . ◊ Important Attributes : Any attribute of objects so basic that they occur in almost every problem domain ? ◊ Relationship among attributes: Any important relationship that exists among object attributes ? ◊ Choosing Granularity : At what level of detail should the knowledge be represented ? ◊ Set of objects : How sets of objects be represented ? ◊ Finding Right structure : Given a large amount of knowledge stored. referring previous example. Fig. how can relevant parts be accessed ? Note : These issues are briefly explained. For detail readers may refer book on AI by Elaine Rich & Kevin Knight.page 115 – 126.

accompanied by a knowledge acquisition tool that guarantees the consistency of inverse slot by checking. that are of general significance. Inheritable KR There are two attributes "instance" and "isa". for e. and team). . The entities are related to each other in many different ways. while a value is added to one attribute. Inheritable KR The attributes we use to describe objects are themselves entities that we between the attributes of an object. and the other.KR . team = Pee-Wee-Reese. one the inverse of the other. These attributes are important because they support property inheritance. one. may hold properties like: Inverses . This second approach is followed in semantic net and frame-based systems. team(Pee-Wee-Reese. existence in an isa hierarchy . . Brooklyn–Dodgers). ◊ Inverses : This is about consistency check. originating at the object being described and terminating either at the object or its value. ‡ second. . use attributes that focus on a single entity but use them in pairs. There are two ways of realizing this: ‡ first.issues • Important Attributes : Ref. each with a directed arrow. 22 team = Brooklyn–Dodgers . . independent of specific knowledge they encode. Example.. techniques for reasoning about values and single valued attributes. that can be interpreted as a statement about Pee-Wee-Reese or Brooklyn–Dodger.g.Fig. a logical representation. The relationship : Ref.g. represent both relationships in a single representation. • Relationship among attributes represent. e. each time a value is added to one attribute then the corresponding value is added to the inverse. instance. The figure shows attributes (isa.Fig. . Example..

The values are often specified when a knowledge base is created.issues ◊ Existence in an isa hierarchy : This is about generalization-specialization. in turn. of attributes. the attribute there are attributes and specialization height is a specialization of general attribute physical-size which is. height : must be in a unit of length. 23 . like. a baseball player can at time have only a single height and be a member of only one team. These generalization-specialization relationships are important for attributes because they support inheritance. classes of objects and specialized subsets of those classes. ◊ Techniques for reasoning about values : This is about reasoning values of attributes not given explicitly. KR systems take different approaches to provide support for single valued attributes. Several kinds of information are used in reasoning. Example. ◊ Single valued attributes : This is about a specific attribute that is guaranteed to take a unique value.KR . age : of person can not be greater than the age of person's parents. Example. like. a specialization of physical-attribute.

issues • Choosing Granularity Regardless of the KR formalism. y) → saw (x . High-level facts may not be adequate for inference while Low-level primitives may require a lot of storage. such as Spotted (x . − − − − − − 24 . it is necessary to know : − At what level should the knowledge be represented and what are the primitives ?. We can add other facts.KR . This could be represented as Spotted (agent(John)." Should there be a small number or should there be a large number of low-level primitives or High-level facts. − − Example of Granularity : − Suppose we are interested in following facts: John spotted Sue. we cannot discover that answer. object (Sue)) Such a representation would make it easy to answer questions such are : Who spotted Sue ? Suppose we want to know : Did John see Sue ? Given only one fact. y) We can now infer the answer to the question.

123] 25 and (c) Intensional definition is to provide a rule. the node . means.issues • Set of objects There are certain properties of objects that are true as member of a set but not as individual. Example : Consider the assertion made in the sentences : "there are more sheep than people in Australia". on whether the object is in the set or not. Inheritable KR. then it is more efficient to associate it once with the set rather than to associate it explicitly with every elements of the set . that returns true or false depending . [Readers may refer book on AI by Elaine Rich & Kevin Knight. as in the example – Fig. sheep. However in doing so. − − in logical representation through the use of universal quantifier. any thing that is an elephant is large.Baseball-Player and the predicates as Ball and Batter in logical representation.KR . means. − whether we are asserting some property of the set itself. (b) Extensional definition is to list the numbers. and "English speakers can be found all over the world. − There are three ways in which sets may be represented by. the set of elephants is large. The reason to represent sets of objects is : If a property is true for all or most elements of a set. for example: assert large (elephant). This is done. remember to make clear distinction between. the only way is to attach assertion to the sets representing people.page 122 . and in hierarchical structure where node represent sets and inheritance propagate set level assertion down to individual. and English. (a) Name. or asserting some property that holds for individual elements of the set ." To describe these facts.

Some knowledge representation techniques solve some of them.page 124 . general purpose method for solving all these problems. it is necessary to solve following problems : − − − how to perform an initial selection of the most appropriate structure. what to do if none of the available structures is appropriate.KR . This requires.issues • Finding Right structure This is about access to right structure for describing a particular situation. when to create and remember a new structure. how to fill in appropriate details from the current situations. While doing so. selecting an initial structure and then revising the choice. how to find a better structure if the one chosen initially turns out not to be appropriate. − − There is no good. [Readers may refer book on AI by Elaine Rich & Kevin Knight.126] 26 .

Intelligent Behavior can be achieved by manipulation of symbol structures. facts. concepts. illustrates how knowledge may be represented as “symbol structures” that characterize bits of knowledge about objects. red1 car1. we need formal notation that allow automated inference and problem solving..g. KR languages are designed to facilitate operations over symbol structures. To satisfy these assumptions about KR. examples : “red” “car1” "red(car1)" Assumptions about KR : − − represents represents represents colour red. Semantic e. and tells what an expression means ? e. strategies. property “dark red” applies to my car.KR – using logic 2. KR Using Predicate Logic In the previous section much has been illustrated about knowledge and KR related issues. red1(car1). One popular choice is use of logic. draw new conclusions from existing facts. rules.g. my car . car1(red1). fact that my car is red. 27 . have precise syntax and semantics.. This section. Syntax tells which expression is legal ?. red1(car1 & car2) ?. − Make Inferences.

Logic includes : Syntax . It Specifies what facts a sentence refers to. The facts about the world are represented as sentences in logic. 28 . stands for the objects and relations. ◊ Semantic : Specifies how to assign a truth value to a sentence based on its meaning in the world. ◊ Inference Procedure : Specifies methods for computing new sentences from an existing sentences. Semantics and Inference Procedure.KR – using Logic • Logic Logic is concerned with the truth of statements about the world. Generally each statement is either TRUE or FALSE. Sentences can be encoded in a computer program. Representation is an expression (sentence). and it may be TRUE or FALSE. Note : Facts are claims about the world that are True or False. A fact is a claim about the world. ◊ Syntax : Specifies the symbols in the language about how they can be combined to form sentences.

Logic is studied as KR languages in artificial intelligence. Predicate Logic is the study of individuals and their properties. 29 . Description logic etc. They represent things and allow more or less efficient inference. ◊ Logics are of different types : Propositional logic. Temporal logic. Modal logic. ◊ The problem of designing a KR language is a tradeoff between that which is : (a) Expressive enough to represent important objects and relations in a problem domain. a collection of rules used while doing logical reasoning. Propositional Logic is the study of statements and their connectivity. (b) Efficient enough in reasoning and answering questions about implicit information in a reasonable amount of time. Predicate logic. ◊ Logic is a formal system in which the formulas or sentences have true or false values. ◊ Propositional logic and Predicate logic are fundamental to all logic.KR – using Logic • Logic as a KR Language Logic is a language for reasoning.

either TRUE or false but not both are called propositions. In this section. "snow is white" expresses that snow is white is TRUE. example: the declarative "snow is white" expresses that snow is white. ◊ Logic defines ways of putting symbols together so that user can define legal sentences in the language that represent TRUE facts. To build a Logic-based representation : ◊ User defines a set of primitive symbols and the associated semantics. ◊ Sentences . ◊ A declarative sentence expresses a statement with a proposition as content.1 Logic Representation The Facts are claims about the world that are True or False.KR – Logic 2. ◊ Logic defines ways of inferring new sentences from existing ones. first Propositional Logic (PL) is briefly explained and then the Predicate logic is illustrated in detail. further. Logic can be used to represent simple facts. 30 .

"3 = 3" or "air is equal to air" or "Water is equal to water" has no meaning) − − Propositional logic is fundamental to all logic. which in English would be a declarative sentence. ‡ if proposition is true. Every proposition is either TRUE or FALSE. . 31 . Sentential tells the ways of joining and/or modifying entire or sentences. is also called Propositional calculus. then truth value is "false" .KR . ‡ a sentence is smallest unit in propositional logic. − propositions. (c) 12 * 12=144 ‡ propositions are “sentences” . then truth value is "true" . statements or sentences to form more complicated statements relationships and properties that are derived from the methods of combining or altering statements. (b) Snow is cold.. if proposition is false. Examples: (a) The sky is blue. Propositional logic Propositional logic propositions. or Boolean algebra. No (since x is not defined) No (don't know what is "x" and "=". Example : Sentence "Grass is green" "2 + 5 = 5" "Close the door" "Is it hot out side ?" "x > 2" where is variable "x = x" Truth value "true" "false" Proposition (Y/N) Yes Yes No No either true or false but not both. as well as the logical calculus.Propositional Logic • Propositional Logic (PL) A proposition is a statement.

or q is true. five basic connectives and their symbols : − − listed in decreasing order of operation priority.Propositional Logic These and few more related terms. lower-case letters. Example of a formula : ((((a Λ ¬b) V c → d) ↔ ¬ (a V c )) Connectives and Symbols in decreasing order of operation priority Connective assertion negation conjunction disjunction implication equivalence P Symbols "p is true" Read as NOT AND OR if . contradictions. or both " · && & | P v q || p→q ⊃ ⇒ "if p is true. consequent and argument are explained below. Large. are basic propositions. and joins compounds into larger compounds. p. 32 . connective. operations with higher priority is solved first. are symbols for simple statements. compound or complex statement are constructed from basic propositions by combining them with connectives. variables and symbols KR . q. truth value. TRUE or FALSE.■ Statement. then q is true" " p implies q " ↔ ≡ ⇔ if and only if "p and q are either both true or both false" Note : The propositions and connectives are the basic elements of propositional logic. ◊ Connective or Operator The connectives join simple statements into compounds. Table below indicates. contingencies. tautologies.. ◊ Statement Simple statements (sentences). that does not contain any other statement as a part. antecedent.then ¬p p∧q ~ ! "p is false" "both p and q are true" "either p is true. such as. r.

use " F " or " 0 " to mean FALSE Truth table defining the basic connectives : p T T F F 33 q T F T F ¬p ¬q p ∧ q p v q p→q p ↔ q F F T T F T F T T F F F T T T F T F T T T F F T q→p T T F T . is either TRUE or FALSE. is either TRUE or FALSE.◊ Truth value The truth value of a statement is its Example : p ~p pvq is either TRUE or FALSE. KR .Propositional Logic TRUTH or FALSITY . use " T " or " 1 " to mean TRUE. and so on.

. 2nd statement or "then .. if that proposition is neither a tautology nor a contradiction e. the 1st statement or "if . ◊ Antecedent.g.KR . ◊ Contingencies A proposition is called a contingency. (P ∧ ¬P) is always false regardless of the truth value of the proposition P. (P v ¬P) is always true regardless of the truth value of the proposition P.. e.clause" (here p) is called antecedent .g. e. p → q .g.Propositional Logic ◊ Tautologies A proposition that is always true is called a tautology. 34 .clause" (here q) is called consequent. ◊ Contradictions A proposition that is always false is called a contradiction. Consequent In the conditional statements. (P v Q) is a contingency.

and equivalence. conjoin them. consistency. 35 . Note : The truth tables are adequate to test validity. Take all the premises. "if and only if" the statement of their equivalence using " ≡ " is a tautology. ‡ Two statements are logically equivalent "if and only if" their truth table columns are identical. contingency. ‡ An argument is valid "if and only if" its corresponding conditional is a tautology. ‡ Two statements are consistent "if and only if" their conjunction is not a contradiction. − Because the corresponding conditional of an argument is a statement. contradiction. or a contradiction. tautology. This implication statement is called the corresponding conditional of the argument. and every implication statement has a corresponding argument. it is therefore either a tautology. or a contingency.◊ Argument KR . and make that conjunction the antecedent of a conditional and make the conclusion the consequent. Note : − Every argument has a corresponding conditional.Propositional Logic Any argument can be expressed as a compound statement.

Then Socrates is mortal” .KR . or change it to something like "There is a number x for which x > 1 holds". Predicate logic satisfies the requirements of a language. x > 1 holds". These cannot be expressed in propositional logic as a finite and logically valid argument (formula). Predicate logic is built upon the ideas of propositional logic. Example : The assertion "x > 1". is not powerful enough for all types of assertions. − Consider example : “All men are mortal.Predicate Logic • Predicate logic The propositional logic. or "For every number x. or a relationship among objects represented by the variables . Socrates is a man. − − 36 Predicate logic is powerful enough for expression and reasoning. where x is a variable. . We need languages : that allow us to describe properties (predicates) of objects. − − either we substitute a specific number for x . is not a proposition because it is neither true nor false unless value of x is defined. For x > 1 to be a proposition .

read as “x” represents an arbitrary Object . or a relation among objects represented by the variables. Let ‘B’ is name for predicate "is_blue". 37 . describes property. Sentence is represented as "B(x)" . The subject is what (or whom) the sentence is about. "The sky is blue" . always includes verb. tells something about the subject.KR . "The cover of this book is blue" Predicate is “is blue" . Example: “The car Tom is driving is blue" . Predicate is a verb phrase template that describes a property of objects. is Judy and the predicate is runs . "x is blue". Predicate. tells something about the subject.Predicate Logic ■ Predicate : Every complete sentence contains two parts: a subject and a predicate. Predicates are given names. The subject The predicate Example : A sentence "Judy {runs}".

.. found Assignment for < are 3.. z and then true) . Applying truth table..) && ( !q(...) || r (...■ Predicate logic expressions : The propositional operators combine predicates. 1 for the value can be FALSE or TRUE 3 < 2 || ( 2 < 1 && 1 < 3) It is 38 False . 2.) ) ) KR . Consider the expression with the respective logic symbols || and && x < y || ( y < z && z < x) Which is true || ( true && True x. y. like If ( p(..Predicate Logic Examples of logic operators : disjunction (OR) and conjunction (AND).

denoted by symbol and existential quantifiers .. such as x > 1 or P(x). 39 . and it then becomes a true statement. Quantify the variable using a quantifier on formulas of predicate logic (called wff ). x need to be declared ‡ Declaration x : a * x:a * x:a ‡ Statement declares variable x read as “x is an element of set a” p is a statement about x is quantification of statement statement declaration of variable x as element of set a quantifier * Q x:a • p * Quantifiers are two types : universal quantifiers . Assign a value to the variable. x > 1. hence a ‡ Variable * x > 5 x is not a proposition. that for x > 1 Generally.g. by using Quantifiers on variables. its tru th depends upon the value of variable x * to reason such statements.Predicate Logic ■ Predicate Logic Quantifiers As said before. denoted by symbol Note : The next few slide tells more on these two Quantifiers. e. proposition. a predicate with variables (is called atomic formula) can be made a proposition by applying one of the following two operations to each of its variables : 1.KR . Apply Quantifiers on Variables if 3 is assigned to x becomes 3 > 1 . 2. x>1 is not proposition and why ? to be a proposition what is required ? Also said.

40 . This indicates : − − a set of entities that the quantifiers deal. y (x < y or x = y or x > y).Predicate Logic ■ Universe of Discourse The universe of discourse. set of all cars on a parking lot. universe is thus the domain of the (individual) variables. y in N. there is no need to be more precise and say forAll because N is implicit. it is necessary to qualify what the allowable values of x and y are. x. propositions in the predicate logic are statements on objects of a universe. set of integers. entities can be set of real numbers. also called domain of discourse or universe. being the universe of discourse. Examples: − About natural numbers forAll x. but it should be obvious from the context. − About a property that holds for natural numbers but not for real numbers. − − The universe is often left implicit in practice.KR . the set of all students in a classroom etc.

means all the objects P(x) is true for every object x in the universe ‡ Example : English language to Propositional form * "All cars have wheels" x : car • x has wheel * x P(x) where P (x) is predicate tells : ‘x has wheels’ x is variable for object ‘cars’ that populate universe of discourse 41 . x. P(x) holds ” P(x) holds ” P(x) holds ” x in the universe or x P(x) * where P(x) is predicate. * a is universe of discourse " For All " Universal Quantification allows us to make a statement about a x:a•p p holds ” * x is a member of the domain of discourse. ‡ Universal quantification: * read “ for all x in a .KR .Predicate Logic ■ Apply Universal quantifier collection of objects. * p is a statement about x ‡ In propositional form it is written as : * read “ for all “ for each “ for every x x. x.

* p is a statement about x ‡ In propositional form it is written as : * read * Where x P(x) “ there exists an x such that P(x) ” or “ there exists at least one x such that P(x) ” P(x) is predicate x P(x) means at least one object x in the universe is true for least one object x in the universe ‡ Example : English language to Propositional form * “ Someone loves you ” x : Someone • x loves you * x P(x) where P(x) is predicate tells : ‘ x loves you ’ x 42 is variable for object ‘ someone ’ that populate universe of discourse .KR . ‡ Existential quantification: x:a•p * read “ there exists an x such that p holds ” * a is universe of discourse * x is a member of the domain of discourse.Predicate Logic ■ Apply Existential quantifier " There Exists " Existential Quantification allows us to state that an object does exist without naming it.

KR . . and t1. where t1 and t2 are terms. . . − Well-formed formula ("wiff") is a symbol or string of symbols (a formula) generated by the formal grammar of a formal language. tn). a token of which is a symbol or string of symbols which may be interpreted as any meaningful unit in a formal language. . .e. where f is an n-ary function symbol. tn are terms. ‡ Terms : Defined recursively as variables. ‡ Atomic formulas : An atomic formula (or simply atom) is a formula with no deeper propositional structure.Predicate Logic ■ Formula : In mathematical logic. An atomic formula is one of the form: − t1 = t2. . . tn are terms.. . or constants. . and t1. . Applying predicates to terms produce atomic formulas. − Compound formulas are formed by combining the atomic formulas using the logical connectives. or functions like f(t1. a formula that contains no logical connectives or a formula that has no strict sub-formulas. ∧ b) and (a v b) are formula when a and b are formula − (a ‡ Compound formula : example ((((a ∧ b ) ∧ c) ∨ ((¬ a ∧ b) ∧ c)) ∨ ((a ∧ 43 ¬ b) ∧ c)) . or − R(t1. i. − Atoms are thus the simplest well-formed formulas of the logic. a formula is a type of abstract object. . . − ¬ a is a formula when a is a formula. where R is an n-ary relation symbol. . . . tn). .

while for a human there is no confusion. are logically expressed are : ■ Example : A simple sentence like "Joe is a musician" ◊ Here "is a" (called IsA) is a way of expressing what logically is called a class-instance relationship between the subjects represented by the terms "Joe" and "musician". containing subject.e. "musician" plays the role of class in that sentence. and object. attributes "instance" and "isa". Inheritable KR).2 Representing “ IsA ” and “ Instance ” Relationships KR – logic relation Logic statements. The ways. ◊ Note : In such a sentence. but for computers each relationship have to be defined explicitly.2. "Joe" plays the role of instance. predicate. 44 [Joe] [Instance] IsA IsA [Musician] [Class] . in a hierarchical structure (ref. were explained. Also stated. These two attributes support property inheritance and play important role in knowledge representation. ◊ "Joe" is an instance of the class of things called "musician". fig. This is specified as: i. two important attributes "instance" and "isa"..

p2.. . = 2x 1x 1 = 2 45 2! according to above definition. recursively are : n! = n x (n-1)! for n ≥ 1 5! = 1 x 2 x 3 x 4 x 5 = 120 0! = 1 The above definition incorporates an instance that the product of no numbers ie 0! = 1 . ◊ The expressions defining n! . 2 ≠ 0 → 2 . . . . else if pn then en” . n ≠ 0 → n . p2 → e2.. = 2 x 1 x 0! = 2 x 1 x ( 0 = 0 → 1. the e corresponding to the first p that has value T. ◊ Example: Evaluate 2! = 2 x 1! = 2 x ( 1 = 0 → 1. the recursive relation (n + 1)! = n! x (n+1) works for n = 0 . pn if p2 then e2 . This is expressed as C { F } is explained below using two examples : (1) "evaluate factorial n" and (2) "expression for triangular functions". ( 0 – 1 )! ) = ( 2 = 0 → 1. ◊ Now use conditional expressions n! = ( n = 0 → 1. (p1 → e1. . Here p1. n! ■ Example (1) : A conditional expression to define factorial n ie ◊ Expression “ if p1 then e1 else ie. pn → en ) are propositional expressions taking the .pn → en ) is the value of values T or F for true and false respectively. . . (n – 1 ) ! ) to define functions recursively. n= 5. . . . ( 2 – 1 )! ) 1 ≠ 0 → 1 .3 Computable Functions and Predicates The objective is to define class of functions C computable in terms of F. . . p2 → e2. . . ◊ The value of ( p1 → e1. .KR – functions & predicates 2. . ( 1 – 1 )! ) 0 ≠ 0 → 0 . then only.

0 X the conditional expressions for triangular functions are x = (x < 0 → -x .KR – functions & predicates ■ Example (2) : A conditional expression for triangular functions ◊ The graph of a well known triangular function is shown below Y 0. x ≤ 0 → -x. x ≤ 1 → x. x ≥ 0 → x) ◊ the triangular function of the above graph is represented by the conditional expression is tri (x) = (x ≤ -1 → 0.0 1.1 -1. x > 1 → 0) 46 .

4 Resolution Resolution is a procedure used in proving that arguments which are expressible in predicate logic are correct. − Resolution is a rule of inference. − Resolution is a computerized theorem prover.Predicate Logic – resolution 2. 47 . − Resolution is so far only defined for Propositional Logic. The strategy is that the Resolution techniques of Propositional logic be adopted in Predicate Logic. Resolution is a procedure that produces proofs by refutation or contradiction. Resolution lead to refute a theorem-proving technique for sentences in propositional logic and first-order logic.KR .

The production rules are simple but powerful forms of knowledge representation providing the flexibility of combining declarative and procedural representation for using them in a unified form. KR Using Rules Knowledge representations using predicate logic have been illustrated. 48 . The production rules as knowledge representation mechanism are used in the design of many "Rule-based systems" also called "Production systems" . The remaining two other types of KR are semantic net and frames. Examples of production rules : − IF condition THEN action − IF premise THEN conclusion − IF proposition p1 and proposition p2 are true THEN proposition p3 is true The advantages of production rules : − they are modular. sometimes called IF-THEN rules. − new rules may be added and old ones deleted − rules are usually independently of other rules. The other most popular approach to Knowledge representation is to use production rules. − each rule define a small and independent piece of knowledge.KR Using Rules 3.

49 .g. IF inflation rate declines THEN the price of gold goes down. AND there are rules which do mention the current goal in their premise. ■ Meta rules These are rules for making rules.g. These rules are part of the inference engine. e. − Meta-rules direct reasoning rather than actually performing reasoning. ■ Inference Procedural Rules These rules advise on how to solve a problem.KR Using Rules • Types of rules Three major types of rules used in the Rule-based production systems. IF the data needed is not in the system THEN request it from the user. ■ Knowledge Declarative Rules : These rules state all the facts and relationships about a problem. while certain facts are known. − Meta-rules specify which rules should be considered and in which order they should be invoked.g. Meta-rules reason about which rules should be considered for firing.. These rules are a part of the knowledge base. THEN the former rule should be used in preference to the latter. IF the rules which do not mention the current goal in their premise. e... e.

that − can be expressed in simple and clear statements. knowing 'that' It Looks similar to declarative knowledge.1 Procedural versus Declarative Knowledge These two types of knowledge were defined in earlier slides. It manifests itself in the doing of something. except that tasks or methods are Includes : Concepts. Peter is older than Robert. It is held by individuals in a way which does not allow it to be communicated directly to other individuals. e.. ■ Declarative Knowledge : knowing 'what'. procedures. Declarative knowledge is represented in a format that can be manipulated. e.. models. It is knowledge about facts and relationships. manual or mental skills cannot reduce to words. models. propositions. It is knowledge about how to do something. ■ Procedural Knowledge : knowing 'how to do' Includes : Rules.KR – procedural & declarative 3. agendas. strategies. objects.g.g. These explains what to do in order to reach a certain conclusion.g. Accepts a description of the steps of a task or procedure. decomposed and analyzed independent of its content. − can be added and modified without difficulty. 50 . A car has four tyres. facts. Rule: To determine if Peter or Robert is older. e. Declarative knowledge and explicit knowledge are articulated knowledge and may be treated as synonyms for most practical purposes.. first find their ages. being described instead of facts or things. assertions.

direct execution • Simple data type can be used sets of rules.oriented • Extension is easy • Slow (requires interpretation) • May require high level data type production system. • Representations in the form of • Representations in the form of routines and subroutines. organized into • Easy to validate • White box • Explicit • Data . 51 . the entire set of rules for executing the task.KR – procedural & declarative ■ Comparison : Comparison between Procedural and Declarative Knowledge : Procedural Knowledge Declarative Knowledge • Hard to debug • Black box • Obscure • Process oriented • Extension may effect stability • Fast .

C++. but now setting • Code of procedure tightly linked to • Same SQL statements will work front end with most front ends Code loosely linked to front end. DBMS handles structural issues positioning • Programmer works with a pointer • Programmer not concerned with or cursor • Knowledge of coding tricks applies • Knowledge of SQL tricks applies to only to one language any language using SQL 52 . Cobol. • Code tightly integrated structure of the data store with • Code loosely linked to structure of data. with the execution of the SQL statement • Programmer understands and has • Programmer has no interaction access to each step of the code • Data exposed to programmer • Programmer receives data at end during execution of the code as an entire set changes in the data structure changing data structure speed records • More susceptible to failure due to • More resistant to changes in the • Traditionally faster.KR – procedural & declarative ■ Comparison : Comparison between Procedural and Declarative Language : Procedural Language Declarative Language • Basic. etc. but that is • Originally slower. the languages • SQL within the DBMS • Most work is done by interpreter of • Most work done by Data Engine • For one task many lines of code translating the objective into lines of procedural code around the actual data • For one task one SQL statement clearly stating the objective as a SQL statement • Programmer must be skilled in • Programmer must be skilled in • Requires minimum of management • Relies on SQL-enabled DBMS to hold the data and execute the SQL statement .

does not specify the manner in which inference rules are applied. − the Rules of inference determine whether the axioms are sufficient to ensure the truth of the goal statement. z) 53 . Thus Logic + Control = Algorithms • Examples of Logic Statements − Statement A grand-parent is a parent of a parent.KR – Logic Programming 3. z : parent(x. − the Programmer specify basic logical relationships. − Statement expressed in first order logic as (for all) x: grand-parent(x) ← (there exist) y. − computation determines whether or not. − the program consists of a set of axioms and a goal statement.2 Logic Programming Logic programming offers a formalism for specifying a computation in terms of logical relations between entities. − programmer describes all relevant logical relationships between the various entities. − logic program is a collection of logic statements. a particular conclusion follows from those logical statements. y) & parent(y. − Statement expressed in more closely related logic terms as A person is a grand-parent if she/he has a child and that child is a parent. • characteristics of Logic program Logic program is characterized by set of relations and inferences. − the execution of a logic program corresponds to the construction of a proof of the goal statement from the axioms.

KR – Logic Programming • Logic programming Language A programming language includes : − the syntax − the semantics of programs and − the computational model. Prolog and logic data language (LDL) are examples of declarative languages. The program specifies a computation by giving the properties of a correct answer. PROLOG is the most popular Logic programming system. 54 . The program specifies a computation by saying "how" it is to be performed. and object-oriented languages fall under this general approach. emphasize the logical properties of a computation. C. Prolog and LDL are called logic programming languages. The most familiar paradigm is procedural. FORTRAN. Another paradigm is declarative. There are many ways of organizing computations.

general. hence no need for declaring them. a variable or a compound term. e. is guided by syntactic rules. the formation of components (expressions. Structured data object are made of several components. distinguishes the data objects. atoms. numbers. A term is a constant. etc. Constants Variables Atoms Numbers All these data components were mentioned now explained in detail below. The components are divided into two parts: (A) data components and (B) program components. Data object of any kind is also called Data Objects (terms) Simple Structured a term. data object The is not syntax decomposable.g.KR – Logic Programming • Syntax and terminology (relevant to Prolog programs) In any language. special structure. statements. e. (A) Data components : Data components are collection of data objects that follow hierarchy. are . 55 in the earlier slides. variables.g.). Simple constants.

. variables begin with an uppercase letter or an underscore. symbols for ► Functor : is characterized by its name. . atoms. 56 . ◊ Term : examples ‡ Constants: denote elements such as integers. . ‡ Compound terms: comprise a functor and sequence of one or more compound terms called arguments. which is an atom. floating point. ‡ Variables: denote a single but unspecified element. and its arity or number of arguments. t2. ‡ Ground and non-ground: Terms are ground if they contain no variables. and are generally non-ground. ƒ/n = ƒ( t1 . tn ) where ƒ ti 's ƒ/n is name of the functor and is of arity n are the arguments denotes functor ƒ of arity n Functors with the same name but different arities are distinct.KR – Logic Programming (a) Data objects : The data objects of any kind is called a term. otherwise they are non-ground. Goals are atoms or compound terms.

6.0e-3 calculations 33 -2. e.g. Variables ◊ Atoms ‡ a lower-case letter.g. ~ @ # $ & ‡ a string of any characters enclosed within single quotes. possibly followed by other letters (either case).KR – Logic Programming (b) Simple data objects : Atoms. [] two_B_or_not_2_b ::= 'a<>b' {} ‡ a string of special characters such as: + . digits.6e-2 are rarely written in Prolog.g. and underscore character. digits. a <> 'ABC' greaterThan ##&& '1234' ! .g.5 ◊ Variables ‡ begins by a capital letter.g. involving heavy e.* / \ = ^ < > : .23e+23 X25 List Noun_Phrase . 0 numerical -16 11. e. possibly followed by other letters (either case). e.1416 +100 ‡ real numbers 0. Numbers. ‡ following are also atoms ◊ Numbers ‡ applications ‡ integer e. 57 written in standard or scientific notation. representation: -3. and underscore character. e.g.

◊ Special Structures ‡ In Prolog an ordered collection of terms is called a list . Non-empty list carries element(s) between square brackets. greaterThan(9. h(d)) plus(2. g(b. 3.e. separating elements by comma. ‡ each argument is a term (i. ‡ Lists are structured terms and Prolog offers a convenient notation to represent them: * * Empty list is denoted by the atom [ ]. Special Structures ◊ General Structures ‡ a structured term is syntactically formed by a functor and a list of arguments. like integers 2. 5) Note : a structure in Prolog is a mechanism for combining terms together. any Prolog data object). ‡ list of arguments appears between parentheses.KR – Logic Programming (c) Structured data objects : General Structures .g. e. 58 [bach. 5 are combined with the functor plus. oranges.. 3. 6) f(a. bee] [apples. ‡ functor is an atom. ‡ e.g. grapes] [] . c). ‡ arguments are separated by a comma. ‡ the number of arguments of a structured term is called its arity.

‡ Example 1 : the predicate ‡ Example 2 : "cows eat grass". ‡ Predicate is composed of one or more clauses. The subject "cows eating grass" 59 the predicate "are visible from the highway" makes complete thought. "cows" and "eat grass." "cows eating grass are visible from highway" and It is a clause. . ‡ A Complete Sentence has two parts: subject and predicate. A predicate establishes a relationships between objects. o predicate tells something about the subject. Sentence. Subject ‡ Clause is a collection of grammatically-related words . every sentence contains one or more clauses.KR – Logic Programming (B) Program Components A Prolog program is a collection of predicates or rules. (a) Clause. Predicate. because it contains the subject This is a complete clause. ‡ Clauses are the building blocks of sentences. o subject is what (or whom) the sentence is about.

called "sub-goals" of the goal on left-hand side. parent(Z.<right-hand-side>.e. A predicate is true if at least one of its clauses is true. where LHS is a single goal called "goal" and RHS is composed of one or more goals.KR – Logic Programming (b) Predicates & Clause Syntactically a predicate is composed of one or more clauses.. Y) parent (X. (Z is parent of X) X (Y is grand parent of X) * An individual "Y" is a parent of "X" if "Y" is the mother of "X" (Y is parent of X) Y (Y is mother of X) * An individual "Y" is a parent of "X" (Y is parent of X) Y (Y is father of X) 60 X if "Y" is the father of "X". mother(X. Y) ::- :- parent(X. i. literal clause ‡ Example : grand_parent (X. Z). Y) parent (X. father(X. ‡ The structure of a clause in logic program head pred ( functor(var1. Y). var2)) :body pred(var2) literal pred(var1) . X . ‡ The general form of clauses is : <left-hand-side> :. ‡ Interpretation: * a clause specifies the conditional truth of the goal on the LHS. Y). goal on LHS is assumed to be true if the sub-goals on RHS are all true. separated by commas. Y). * An individual "Y" is the grand-parent of "X" "X" Y is "Z" and "Y" (Y is parent of Z) Z if a parent of that same is the parent of that "Z".

or simply stated as Y is father of X ‡ Goal true is built-in in Prolog and always holds.KR – Logic Programming (c) Unit Clause . ‡ In Prolog the clauses that are unconditionally true are called clause or fact ‡ Example : say Unconditionally relationships is unconditionally true. unit This relationship as a Prolog clause is : Interpreted as relationship of father between Y and X is always true. . one often encounters unconditional relationships that hold.true part is simply omitted. Y) ie 61 the :. ‡ Prolog offers a simpler syntax to express unit clause or fact father(X.a special Case Unlike the previous example of conditional truth. Y) :true. 'Y' is the father of 'X' father(X.

directives. By issuing queries. A special case of ‡ Syntactically. Who is a grandparent of X ? This query is interpreted as : relationships. 62 .KR – Logic Programming (d) Queries In Prolog the queries are statements called directive. Example : ? . Prolog tries to establish the validity of specific ‡ The result of executing a query is either success or failure Success. are called queries. Failure. means the goals specified in the query holds according to the facts and rules of the program.grandparent(X. means the goals specified in the query does not hold according to the facts and rules of the program. directives are clauses with an empty left-hand side. W).

and pragmatic considerations that shape the language. and (c) Logic. While. 63 . semantics. syntax.KR – Logic . there are two programming paradigms (concurrent and object-oriented programming). while computation is the application of a sequence of operations to a value to yield another value. they are not models of computation. Models of Computation : A computational model is a collection of values and operations. In addition to these. they rank in importance with computational models. There are three basic computational models : (a) Imperative.models of computation • Programming paradigms : Models of Computation A complete description of a programming language includes the computational model. (b) Functional.

which differs from the old state. .KR – Logic . Old State: X = 3. that makes it of execution time. Programs consist of sequences of commands. The value of Y in the new state is the value that 2 ∗ X + 3 had in the old state. Y := 2 ∗ X + 3 New State: X = 3. Example 1 : Linear function A linear function y = 2x + 3 can be written as Y := 2 ∗ X + 3 The implementation determines the value of X in the state and then create a new state. The computations are changes in the state. on which most efficient model in terms The imperative model is closest to the hardware model programs are executed.models of computation (a) Imperative Model : The Imperative model of computation. consists of a state and an operation of assignment which is used to modify the state. Y = 9. 64 Y = -2.

KR – Logic - models of computation

(b) Functional model : The Functional model of computation, consists of a set of values, functions, and the operation of functions. The functions may be named and may be composed with other functions. They can take other functions as arguments and return results. The programs consist of definitions of functions. The computations are application of functions to values. ‡ Example 1 : Linear function A linear function y = 2x + 3 can be defined as : f (x) = 2 ∗ x + 3 ‡ Example 2 : Determine a value for Circumference. Assigned a value to Radius, that determines a value for Circumference. Circumference = 2 × pi × radius where pi = 3.14 Generalize Circumference with the variable "radius" Circumference(radius) = 2 × pi × radius , ie where pi = 3.14

Functional models are developed over many years. The notations and methods form the base upon which problem solving methodologies rest.

65

KR – Logic - models of computation

(c) Logic model : The logic model of computation is based on relations and logical inference. Programs consist of definitions of relations. Computations are inferences (is a proof). ‡ Example 1 : Linear function A linear function y = 2x + 3 can be represented as : f (X , Y) ‡ Example 2: if Y is 2 ∗ X + 3. Determine a value for Circumference. Pi = 3.14 and C = 2 ∗ pi ∗ R.

The earlier circumference computation can be represented as: Circle (R , C) if circumference C. ‡ Example 3: Determine the mortality of Socrates. The program is to determine the mortality of Socrates. The fact given that Socrates is human. The rule is that all humans are mortal, for all X, that is if X is human then X is mortal. The function is represented as a relation between radious R and

To determine the mortality of Socrates, make the assumption that there are no mortals, that is ¬ mortal (Y)

[logic model

66

continued in the next

slide]

KR – Logic - models of computation

[logic model

continued in the previous slide]

**‡ The fact and rule are: human (Socrates) mortal (X) if human (X) ¬ mortal (Y)
**

Fact Rule assumption from 2 & 3 by unification and modus tollens from 1 and 4 by unification 5, 4b, and 1

**‡ To determine the mortality of Socrates, make the assumption that there are no mortals i.e.
**

1. 2. 3 4.(a) 4.(b) 5. 6. human(Socrates) mortal(X) if human(X) ¬mortal(Y) X=Y ¬human(Y) Y = Socrates Contradiction

‡ Computation (proof) that Socrates is mortal :

‡ Explanation :

* The 1st line is the statement "Socrates is a man." * The 2nd line is a phrase "all human are mortal"

into the equivalent "for all X, if X is a man then X is mortal".

* The 3rd line is added to the set to determine the mortality of Socrates. * The 4th line is the deduction from lines 2 and 3. It is justified by the

inference rule modus tollens which states that if the conclusion of a rule is known to be false, then so is the hypothesis.

* Variables X and Y are unified because they have same value. * By unification, Lines 5, 4b, and 1 produce contradictions and identify

Socrates as mortal.

* Note that, resolution is the an inference rule which looks for a

contradiction and it is facilitated by unification which determines if there is a substitution which makes two terms the same.

**Logic model formalizes the reasoning process. It is related to relational data bases and expert systems.
**

67

there are essentially two ways to generate new knowledge: one. The need is to find what new facts can be derived. 68 . and looks for rules that will help in answering it.3 Forward versus Backward Reasoning Rule-Based system architecture consists a set of rules. a set of facts. It starts with something to find out. forward chaining and the other. ■ Forward chaining : also called data driven. ■ Backward chaining : also called goal driven. backward chaining. Given a set of rules. and an inference engine. and sees what rules apply.KR – forward-backward reasoning 3. It starts with the facts.

KR – forward-backward reasoning ■ Example 1 : Rule R1 : Rule R2 : Rule R3 : Fact F1 : Fact F2 : IF IF IF hot hot AND smoky alarm_beeps fire [Given] [Given] THEN fire THEN smoky THEN switch_on_sprinklers alarm_beeps ■ Example 2 : Rule R1 : Rule R2 : Rule R3 : Fact F1 : Fact F2 : 69 IF IF IF hot hot AND smoky alarm_beeps fire [Given] [Given] THEN ADD fire THEN ADD smoky THEN ADD switch_on_sprinklers alarm_beeps .

F4 by R1] [from F4 by R3] THEN ADD smoky THEN ADD switch_on_sprinklers alarm_beeps ■ Example 4 : A typical Backward Chaining Rule R1 : Rule R2 : Rule R3 : Fact F1 : Fact F2 : Goal : 70 IF hot AND smoky IF alarm_beeps If _re hot alarm_beeps THEN fire THEN smoky THEN switch_on_sprinklers [Given] [Given] Should I switch sprinklers on? .KR – forward-backward reasoning ■ Example 3 : A typical Forward Chaining Rule R1 : Rule R2 : Rule R3 : Fact F1 : Fact F2 : Fact F4 : Fact F2 : Fact F6 : IF IF If hot smoky fire switch_on_sprinklers hot AND smoky THEN ADD fire alarm_beeps fire [Given] [Given] [from F1 by R2] [from F2.

‡ can be inefficient . algorithms. ■ Forward chaining system facts Working Memory facts facts Inference Engine rules User Rule Base ‡ facts are held in a working memory ‡ condition-action rules represent actions to be taken when specified facts occur in working memory. unfocused problem solving ‡ set of rules that can fire known as conflict set. actions involve adding or deleting facts from the working memory.KR – forward chaining • Forward chaining The Forward chaining system.lead to spurious rules firing. 71 . ‡ typically. ‡ decision about which rule to fire is conflict resolution. and conflict resolution strategy are illustrated. properties . ■ Properties of Forward Chaining ‡ all rules which can fire do fire.

I Repeat ‡ Collect the rule whose condition matches a fact in WM. ■ Forward chaining algorithm . ‡ If more than one rule matches ◊ Use conflict resolution strategy to eliminate all but one ‡ Do actions indicated by the rules (add facts to WM or delete facts from WM) Until problem is solved or no condition match 72 . ‡ R2 fires. IF IF If IF IF hot Dry hot AND smoky alarm_beeps fire dry sprinklers_on [Given] [Given] [Given] THEN ADD fire THEN ADD smoky THEN ADD switch_on_sprinklers THEN ADD switch_on_humidifier THEN DELETE dry alarm_beeps two rules can fire (R2 and R4) humidifier is on (then.II Repeat ‡ Collect the rules whose conditions match facts in WM. (add facts to WM or delete facts from WM) Until problem is solved or no condition match Apply on the Example 2 extended (adding 2 more rules and 1 fact) Rule R1 : Rule R2 : Rule R3 : Rule R4 : Rule R5 : Fact F1 : Fact F2 : Fact F2 : Now.KR – forward chaining ■ Forward chaining algorithm . as before) humidifier is off A conflict ! ‡ R4 fires. ‡ Do actions indicated by the rule.

Recency. ◊ Refractory ‡ a rule should not be allowed to fire more than once on the same data. ‡ prevents undesired loops. The popular conflict resolution mechanisms are Refractory. ‡ discard executed rules from the conflict set. Conflict resolution normally selects a single rule to fire. ‡ working memory elements are time-tagged indicating at what cycle each fact was added to working memory. ‡ more specific rules are ‘better’ because they take more of the data into account. ◊ Recency ‡ rank instantiations in terms of the recency of the elements in the premise of the rule.KR – forward chaining ■ Conflict Resolution Strategy Conflict set is the set of rules that have their conditions satisfied by working memory elements. 73 . are preferred to more general rules with fewer conditions. Specificity. ◊ Specificity ‡ rules which have a greater number of conditions and are therefore more difficult to satisfy. ‡ rules which use more recent data are preferred.

‡ Meta-knowledge. ‡ Example of meta-knowledge IF THEN conflict set contains any rule (c . They direct reasoning rather than actually performing reasoning. explicitly coded in the form of rules with "object level" knowledge. a) ‡ This example says meta-knowledge encodes knowledge about how to guide search for solution. sometimes we want to use knowledge in deciding which rules to fire. a) such that a = "animal is mammal'' fire (c .KR – forward chaining ■ Alternative to Conflict Resolution – Use Meta Knowledge Instead of conflict resolution strategies. ‡ Meta-knowledge : knowledge about knowledge to guide search. 74 . Meta-rules reason about which rules should be considered for firing.

it is proven. e. find a rule which can be used to conclude try to prove each of that rule's conditions. The idea is to focus on the search. ‡ Rules and facts are processed using backward chaining interpreter. G.g.KR – backward chaining • Backward chaining Backward chaining system and the algorithm are illustrated. alarm_beeps Smoky hot fire switch_on_sprinklers Encoding of rules Rule R1 : Rule R2 : Rule R3 : Fact F1 : Fact F2 : Goal : 75 IF hot AND smoky IF alarm_beeps If fire hot alarm_beeps THEN fire THEN smoky THEN switch_on_sprinklers [Given] [Given] Should I switch sprinklers on? . "should I switch the sprinklers on?" ■ Backward chaining algorithm ‡ Prove goal G : If G is in the initial facts . ■ Backward chaining system ‡ Backward chaining means reasoning from goals back to facts. and Otherwise. ‡ Checks hypothesis.

Medical expert systems ‡ Forward chaining may be better if there is less clear hypothesis and want to see what can be concluded from current situation. and on properties of rule set.. e.KR – backward chaining • Forward vs Backward Chaining ‡ Depends on problem.. . 76 e. then backward chaining is likely to be better. ‡ If there is clear hypotheses.g.g. Diagnostic problems or classification problems. Synthesis systems .design / configuration.

more easily improved. The other formulation. and when execution mechanisms provide more powerful problem-solving facilities of the kind provided by intelligent theorem-proving systems. that specifies the knowledge to be used in solving problems. The trend in databases is towards the separation of logic and control. The efficiency of an algorithm can often be improved by improving the control component without changing the logic of the algorithm and therefore without changing the meaning of the algorithm. may have a complicated logic component but employ a simple problem-solving strategy. Thus Algorithm = Logic + Control . 77 . and more readily adapted to new problems when programming languages separate logic and control. The programmer specifies both logic and control in a single language. producing same behavior. and control component.4 Control Knowledge An algorithm consists of : logic component. The logic component determines the meaning of the algorithm whereas the control component only affects its efficiency. that determines the problem-solving strategies by means of which that knowledge is used. An algorithm may be formulated in different ways. may have a clear statement in logic component but employ a sophisticated problem solving strategy in the control component. The programming languages today do not distinguish between them. Computer programs will be more often correct.KR – control knowledge 3. The execution mechanism exercises only the most rudimentary problem-solving capabilities. One formulation.

uk/~alison/ai3notes/all.cs. Steve Torrance. Milos Hauskrecht . http://atlas.no/grupper/su/publ/phd/aamodt-thesis.stanford.ac. Peter Szolovits. Knowledge Representation – chapter 4.edu/medg/ftp/psz/k-rep.itu.edu. David Young.html 13. http://www.csail. http://home.hw.berkeley.uk/books/computersand-thought/index.html Frans Coenen.mit.cs. A practical Introduction to Artificial Intelligence.tr/~sonmez/lisans/ai/KNOWLEDGE_REP. Howard Shrobe. 9.pdf .edu/~milos/courses/cs2740/ 14.csc.edu/~russell/intro.html 11. Elaine Rich and Kevin Knight. (2000).nwlink.att.ac.uk/~frans/OldLectures/2CS24/ai. References 1.edu/jmc/whatisai/whatisai. The knowledge in knowledge management.ac. 2006 Stuart Russell and Peter Norvig. “Artificial Intelligence. University of Liverpool.dit.com/~donclark/knowledge/knowledge. 2.ppt. Integrated Approach to Problem Solving and Sustained Learning.susx.html#intro Conversion of data to knowledge.vn/~tru/AI/ai. Chris Hutchison. 5.berkeley.html 12. Databases and Artificial Intelligence 3 Artificial Intelligence Segment. Carnegie Mellon University.vn/~tru/AI/chapter4. http://computing.liv. David Hogg. University of California.dit. http://www. Tru Hoang Cao . 3.cs. http://www.hcmut.pitt. Artificial Intelligence. Agnar Aamodt.macs. 4. CS2740 Knowledge Representation (ISSP 3712). what is artificial intelligence? http://www-formal. A Knowledge-Intensive.net/~nickols/Knowledge_in_KM. 6.html Randall Davis.unn. http://www.edu.informatics.org/kmgmt/kmgmt. 8. http://www. Mike Sharples.systems-thinking. Paul Brna.ntnu. W.cc. What is a Knowledge Representation? http://groups.hcmut. Prolog Programming A First Course.html Nickols. http://www. Stanford University. http://www. Alison Cawsey.idi.html 15. http://www.htm 10. 2CS24. F. http://aima.pdf Knowledge Management—Emerging Perspectives.edu/. http://www. 7.edu. http://www.uk/staff/cgpb4/prologbook/book. Artificial Intelligence: A Modern Approach.ac.html#definition" John McCarthy.htm Knowledge Management .4.

.scs.toronto.stanford. . Aljoscha Burchardt. C.buffalo.edu/~peters/courses/log/loghome. data.coli. J Lawry.edu/faculty/alphonce/.carleton. R.edu/~aabyan/PLBook/book/book.edu/jmc/basis1/basis1. figures or any other material which originally appeared in someone else’s work. Knowledge Representation and Reasoning.de/projects/milca/courses/comsem/html/index. Introduction to Programming Languages. Shunichi Toida. A Basis For A Mathematical Theory Of Computation. Shapiro.cse. tables. paraphrase or summaries. Knowledge Representation.edu/cse/levine/fall99/cse5324/z/ 25. Peter Suber.odu. Dyer.informatik.hmc.wwc. Predicate Logic http://www. http://cs. Ronald J. Logic .htm#top 20. Jim Woodcock and Jim Davies.edu/p/prop-log. http://www.de/~nestleri/main.html 26. .ac. http://faculty. Open To Europe project.html 32. http://www. http://www. 79 .utm. http://www. .uk/research/aigroup/enjl/logic/ 23. The quote.htm 27.buffalo.html 31.html 22.html 28.enm. 17.16. I sincerely acknowledge them.pdf. Symbolic Logic.iep.htw-dresden. Knowledge representation . http://moonbase. Leopoldo Bertossi. Aaby. Levesque. Robert M.ca/~bertossi/KR/ 30. An Elementary Introduction to Logic and Set Theory. Al Lehnen. Introduction to Programming Languages. . Propositional Logic Review.pdf 19.edu/alehnen/weblogic/logcont. Carl Alphonce. http://www.uni-saarland.uta. Aaby. CS381 Introduction to Discrete Structures. Stuart C.cs. CS 540 Lecture Notes. Computational Semantics http://www. FUNDAMENTALS OF PROPOSITIONAL LOGIC http://www. http://www.edu/~toida/index. http://pages.wisc.cs.earlham. information.matcmadison.html 29. Using Z. Anthony A. CSE 4/563 http://www.cs. Brachman and Hector J. Kevin C. Klement. http://www-formal.wwc.htm 24.edu/~keller/cs60book/10%20Predicate%20Logic.edu/~hector/PublicKRSlides.edu/~dyer/cs540/notes/logic. Anthony A.OldPages/CPSC312/CPSC312/Lecture/Lectur eHTML/CS312. ideas. Stephan Walter.edu/~aabyan/PLBook/HTML/ Note : This list is not exhaustive. text. http://www.html 21.bris.cse.cs. John Mccarthy. Keller. http://www. CS312 Functional and Logic Programming. Propositional Logic.edu/~shapiro/Courses/CSE563/ 18.

e Bankingykb Bilpa

Flowchart

Consumer Protection Act 1986

Land of Lisp

Discussion 07

Edutainment

TQM paper

- Read and print without ads
- Download to keep your version
- Edit, email or read offline

CommonLispFirstContact

CLisp

Land of Lisp

Lambda the Ultimate

Maxima Book 19 Sept 2004

Loving Lisp

Lisp Book

Common Lisp

The Evolution of Lisp

Macsyma Expert System

clojure

Visual Prolog

For Rubyists Http://Github.com/Stuarthalloway/Clojure-presentations

Patterns

Asynchronous concurrency in Clojure and a few other languages

rc122-010d-clojure

Http://Github.com/Stuarthalloway/Clojure Presentations

Clojure Cheat Sheet (1.2)

DSLsinAction

Land.of.Lisp

Let Over Lambda

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

CANCEL

OK

You've been reading!

NO, THANKS

OK

scribd

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->