630 likes | 795 Views
Knowledge Representation. École Supérieure Polytechnique Dakar, Senegal Winter 2011 by Fabian M. Suchanek. This document is available under a Creative Commons Attribution Non-Commercial License. Organisation. 1h class on Knowledge Representation Slides are available at the Web-site
E N D
Knowledge Representation ÉcoleSupérieurePolytechnique Dakar, Senegal Winter 2011 by Fabian M. Suchanek This document is available under a Creative Commons Attribution Non-Commercial License
Organisation • 1h class on Knowledge Representation • Slides are available at the Web-site http://suchanek.name/work/teaching • Language of the Slides is English, lecturer will do his best to talk in French, questions are welcome throughout the session in French or English
Check To help assess your background knowledge, please answer the following questions on a sheet of paper: • say “All men are mortal” in first order logic. • reduce ~ x: y: (loves(x,y) & married(x,y)) • write a rule in PROLOG. • what is the minimum of f(x)=x2 ? Do not worry if you cannot answer. Hand in your answers anonymously. This check just serves to adjust the level of the lecture. You will not be graded. E A
Definition of KR Knowledge representation (KR) is a research field of artificial intelligence that aims to formalize information so that it can be used for automated reasoning.
Motivation KR is required to find formal answers to questions: Is Elvis Presley still alive? alive(Elvis) ? sings(Elvis) bornIn(Elvis, Tupelo) locatedIn(Tupelo, USA) sings(X) => alive(X) … formalization reasoning Elvis is alive / not alive
Big Picture Knowledge Base (KB) query Is Elvis Presley still alive? facts / assertions sings(Elvis) bornIn(Elvis, Tupelo) locatedIn(Tupelo, USA) sings(X) => alive(X) … rules / formulas inference implied / deduced facts / statements alive(Elvis)
Query Answering Knowledge Base (KB) query Is Elvis Presley still alive? sings(Elvis) bornIn(Elvis, Tupelo) locatedIn(Tupelo, USA) sings(X) => alive(X) … Answering a query: Finding out whether the query or its contrary can be deduced from the KB alive(Elvis)
KR Formalism Knowledge Base (KB) KR formalism: The language of the KB sings(Elvis) bornIn(Elvis, Tupelo) locatedIn(Tupelo, USA) sings(X) => alive(X) …
KR Formalisms, 1/2 • There are different ways to represent knowledge: • PROLOG-like: • alive(Elvis), is(Elvis, alive) • graphically is alive • in natural language “Elvis is alive” • in propositional logic • elvis_alive .
KR Formalisms, 2/2 • in first order logic • x: rocksinger(x) => alive(x) A • in a mathematical notation • elvis Alive • in a programming language • elvis.alive=true • in completely different formalism • фelvis→☺☺☺
Canonicity A KR formalism is canonic if one piece of knowledge can be represented in only one way alive(Elvis) is(Elvis, alive) alive(Elvis, true) vivant(Elvis) not very canonic
Canonicity is Desirable Canonicity is in general desirable because it facilitates co-operation by different people is(Elvis, alive) ! alive(Elvis) ? is(Elvis, alive) no
Achieving Canonicity • A formalism can be made more canonic by • restricting it e.g., by allowing only unary predicates: alive(Elvis) is(Elvis, alive) • providing best practice guidelines e.g., by prescribing certain conventions: alive(Elvis) Alive(elvis) • providing standard vocabularies e.g., by listing predicates that should be used in a certain domain: {alive, dead, young, old, happy, sad}
Expressiveness A KR formalism is more expressive than another one if we can say things in the first formalism that we cannot say in the second. First order logic x: rocksinger(x) => alive(x) Propositional logic ? A
Expressiveness is Desirable In general, a higher expressiveness is desirable from a modeling point of view x: alive(x) A … but it comes at a cost…
Decidability A KR formalism is decidable, if there is an algorithm (computer program) that can answer any query on a knowledge base in that formalism. (Technically: A logical system is decidable iff there is an effective method for determining whether arbitrary formulas are theorems of the logical system.) Some formalisms are so expressive that they are undecidable: • Natural language is undecidable Is sentence (*) true? (*) This sentence is false.
Decidability of FOL • First order logic is also undecidable First order logic is so powerful that it can express sentences of which it is impossible to determine whether they are true or not. This means that there are some first-order-logic sentences, which we can never prove or disprove. Worse, we cannot even determine whether a given sentence is of this type.
Achieving Decidability In general, decidability is desirable. But the more expressive a formalism is, the more likely it is to be undecidable. • Some formalisms can be made decidable by restricting them • Propositional logic is decidable • First order logic is decidable • if all formulae are of the following form: E x, y,…. z, q,… : p(x,y) … => … A existential universal arbitrary formula quantifiers quantifiers without quantifiers and function symbols
Closed World Assumption A KR formalism follows the closed world assumption (CWA), if any statement that cannot be proven is assumed to be false. PROLOG, e.g., follows the CWA: ?- assert(bornIn(Elvis, Tupelo)). yes ?- alive(Elvis). no
Open World Assumption • In many contexts, the open world assumption (OWA) is more appropriate. • Under the OWA, a statement can be • provably false • provable true • unknown ?- alive(Elvis). I have no clue
Reification A KR formalism allows reification, if it can treat statements like entities. reification, a statement appears as argument thinks(Fabian, alive(Elvis)). => alive(Elvis)
Modal Logic Modal logic allows talking about necessity and possibility “It is possible that Elvis is alive” alive(Elvis) Thus, modal logic implements a (restricted) type of reification.
Unique Name Assumption A KR formalism follows the unique name assumption (UNA), if different names always refer to different objects. The King The King Elvis
Unique Name Assumption The UNA is not useful if different people want to use different identifiers: The King Elvis alive(TheKing) TheKing=Elvis => alive(Elvis)
Schema A KR formalism is schema-bound, if one has to decide upfront which entities can have which properties. In schema-bound formalisms, one has to decide a priori for classes of things and their properties: • person: • alive/dead • birthday • profession • camera: • resolution • shutter speed • weight • gender
Advantages of Schemas A schema-bound formalism puts more modeling constraints, but can exclude non-sensible statements. PROLOG is schema-free, any entity can have any property: ?- assert(alive(Elvis)). yes ?- assert(hasResolution(Elvis,five_megapixel)) yes
Databases Databases are a particular schema-bound KR formalism. A database can be seen as a set of tables. each table corresponds to one class of things each column is one property Person each row is one thing
SQL A database can be queried in the Structured Query Language (SQL). SELECT name, birth FROM person WHERE profession=‘Singer’ AND birth>1930 Elvis, 1935 JohnLennon, 1940 …
Uses of Databases • Databases are used in practically every major enterprise, with the main database systems being • Oracle • Microsoft SQL Server • IMB’s DB2 • Postgres • MySQL Headquarters of Oracle in Redwood Shores, CA, USA
Inheritance A KR formalism supports inheritance, if properties specified for one class of things can be automatically transferred to a more specific class. • person: • name • birthday • gender • singer: • name • birthday • gender • instrument
Inheritance more general class, fewer properties more specific class, more properties • person: • name • birthday • gender • singer: • inherits from person • instrument additional properties
Restrictions The more specific class can restrict properties inherited from the more general class. • person: • name • birthday • gender • profession • singer: • inherits from person • profession=singer • instrument restriction
Object Oriented Languages Object-oriented programming languages (such as e.g., Java) support inheritance. super-class * declares two properties public class Person { String name; String profession; } public class Singer extends Person { String profession=“Singer”; String instrument; } sub-class * overwrites a property * adds a property Singer elvis=new Singer(); elvis.name=“Elvis”; elvis.instrument=“guitar”; System.out.println(elvis.profession) Singer Elvis is a singer * but he inherited properties * and has predefined values
Object Oriented Languages • Most programming languages support object-orientation • today, with the most important ones being • Java • C++ • C# • Visual Basic • Python • Ruby
Monotonicity A KR formalism is monotonous, if adding new knowledge does not undo deduced facts. First order logic and propositional logic are monotonous: elvis_is_person elvis_alive elvis_dead=> ~elvis_alive elvis_is_dead elvis_is_person elvis_alive elvis_dead => ~elvis_alive + =>elvis_alive =>elvis_alive =>elvis_is_dead =>m_jackson_alive Monotonicity can be very counter-intuitive. It requires everything to be known upfront.
Default Logic Default logic is not monotonous: elvis_is_person prerequisite conclusion elvis_is_dead ~elvis_is_alive if Elvis is dead then he is not alive justification elvis_is_person: elvis_is_alive elvis_is_alive if Elvis is a person and nothing says he’s not alive then he is alive elvis_is_dead + =>elvis_is_alive
Fuzziness A KR formalism is fuzzy, if certain statements can hold to a certain degree. fantastic(Bush) 0.1 fantastic(Madonna) 0.8 fantastic(Elvis) 1.0 The opposite of fuzzy is crisp. First order logic, PROLOG and propositional logic are all crisp.
Fuzzy Logic Fuzzy logic is a fuzzy KR formalism. rainy (0.8) rainy => bad_weather bad_weather (0.8)
Fuzzy Logic Operators rainy (0.8) windy(1.0) rainy \/ windy => bad_weather bad_weather (??) 1.0 • Fuzzy logic defines how to compute fuzzy values • for complex combinations of fuzzy predicates, e.g. • OR is computed as maximum • AND is computed as minimum • NOT is computed as 1-x
Contradictions A KR formalism is tolerant to contradictions if it allows contradictions in the knowledge base. Madonna is alive Elvis is alive Elvis is a person Elvis is not alive Knowledge base
FOL & Contradictions First order logic and propositional logic are not tolerant to contradictions: alive(Elvis). ~alive(Elvis). ex falso quod libet… =>life_is_beautiful Some domains require handling of contradictions (e.g. information extraction from the Web) Elvisfans.com: Elvis is alive Wikipedia: Elvis is dead.
Possible Worlds Given propositional predicates, a possible world is an assignment of truth values to the predicates. Given the predicates elvis_alive, elvis_dead there are 4 possible worlds: w3: elvis_alive elvis_dead w1: elvis_alive elvis_dead w2: elvis_alive elvis_dead w4: elvis_alive elvis_dead
Markov Logic A Markov Logic Network is a set of propositional logic formulas with weights: f1: elvis_alive [0.8] f2: elvis_dead => ~elvis_alive [0.5] f3: elvis_dead [0.6] A Markov Logic Network assigns a probability to each possible world: P(w) ~ Πeweight(f) satisfied formula f w1: elvis_alive elvis_dead f1 satisfied, f2 satisfied, f3 not satisfied P(w1) ~ e0.8. e0.5 = 3.6
Markov Logic Example Markov Logic Network: f1: elvis_alive [0.8] f2: elvis_dead => ~elvis_alive [0.5] f3: elvis_dead [0.6] Possible worlds: w1: elvis_alive elvis_dead w2: elvis_alive elvis_dead w4: elvis_alive elvis_dead w3: elvis_alive elvis_dead Satisfied formulas: f1,f3 f2 f1,f2 f2,f3 1.6 3.0 3.6 4.1
Markov Logic Summary • A Markov Logic Network is a KR formalism that allows • contradictions. • It assigns a probability to all possible worlds: • larger probabilities for worlds that satisfy more constraints • smaller values for worlds that violate more constraints
Explicitness A KR formalism is explicit, if it can explain why a certain statement was deduced. Logic-based formalisms are usually explicit: rich(BillGates) rich(X) => happy(X) rich(BillGates) => happy(BillGates) happy(BillGates) Modus Ponens Instantiation
Explicitness Explicitness may not always be useful, consider pattern recognition: a aaaa hard to describe explicitly a ... or image recognition: hard to describe explicitly Elvis Presley
Neural Networks A neural network is a a non-explicit KR formalism. It tries to model the human brain. neuron (nerve cell) connections
Perceptrons A perceptron is a simplified model of a nerve cell (neuron). It is defined by a vector of n real-valued weights, w1,...,wn. It can be visualized as follows: input values x1x2 ... xn weights w1 w2... wn perceptron nerve cell y real-valued output value
Perceptron Function A perceptron computes a function Rn {0,1} from the n input values to the set {0,1} as follows: x1x2 ... xn w1 w2... wn if wi · xi > 0 0 else y =