Introduction to Knowledge Representation and Logic Motivation All our search programs seem quite special purpose. The search algorithm may be general, but we have to code up the problem representation and heuristic functions ourselves. Wouldn’t it be nice if we could build a more “general purpose” program. E.g., suppose we could just – tell our program about the rules of chess or checkers, and it would be able to play – give it some ideas about how to play well, and it would use them. Knowledge Representation Such a general program would have to be capable of “knowing” lots of things: – E.g., the rules of chess – Good strategies – Lots of things needed to make sense out of these rules, etc. (“Background knowledge”) We would need to be able to express an open-ended variety of things, in some form that they can be properly manipulated. The means of expressing general “facts”, or beliefs, etc., is called a knowledge representation language. KR: The Basic Idea The World Mental Representations “A man is on the girder.” “The girder is on the mountain.” mental processes “The man is above the mountain.” Some Things to Do with Representations Given some beliefs, – determine what else we should believe. – agree that some other things are true (likely?). – predict that something is going to happen. – predict what happens conditionally. Note that the last two complicate the idea of correspondence with “the world”. Knowledge Representation Languages A KRL is a sme way of writing down beliefs/facts/etc. Not really a language, any more than a programming language is. Needs to be – Very expressive: In it, we need to be able to express anything we want. – What might some possibilities be? KRL Candidates: LISP? I.e., suppose everything we know is a program. – After all, we only care about knowledge that we can use. – E.g., knowing someone’s telephone number might be the program you run to dial that number. Pretty expressive. Good for certain kinds of things. – Certainly, some of the things we know (how to play tennis) might best we thought of this way. But: – We miss certain generalizations if everything is a program. – E.g.: If our knowledge of a phone number were the procedure that dials the number, then that procedure doesn’t work » when we move from a rotary to a touch-tone phone » for any other number The Procedural/Declarative Distinction “Know-how” versus “know-that”. In general, procedural knowledge is – Hard to use generally, reason with, introspect on, articulate. – Enable fast behavior Declarative knowledge is – More flexible (multi-use), amenable to introspection, articulation – This is the focus of most KR work. – (Note, though, that there must always be some sort of (procedural) mechanism around that is interprets declarative knowledge.) KRL Candidates: English? I.e., suppose the KRL is some natural language. Expressive! Suitably declarative. But: – Ambiguous » “I saw her duck.” – Context-dependent meanings » Pronouns, deixis – Non-compositional » Idioms, collocations, etc. In other words, a KR language should represent facts in form that expresses what they mean after they have been understood. KRL Desiderata Expressive Unambiguous (wrt relevant distinctions) Context-independent Compositional Artificial Languages We’ll have to make up an artificial “language” that has all these nice properties. If we are being psychological, we might hope to uncover the language of thought. There is at least some evidence that people think in something other than language per se – Consider “false-alarming”; multi-lingual recall. – We are hard-pressed to know exactly what this language is. Actual KRLs There have been various candidates proposed for KRLs over the years. One set of proposals is that formal logic be used as a basic framework for such languages. Logic consists of – A language » which tells us how to build up sentences in the language (i.e., syntax) » and what those sentences mean (i.e, semantics) – An inference procedure » Which tells us which sentences are valid inferences from other sentences Logic as a KRL There are really many logics. – differing mostly in terms of how much they can express, – but also, in a lot of details. Using logic seems reasonable in that the language was designed not to have the “flaws” of natural languages. – I.e., we can engineer our way around ambiguity, etc. Using logic seems questionable, in that: – The inference procedure is designed for “valid reasoning”, i.e, it is a proof theory. Human reason seems rife with useful nonvalid processed, e.g., assumption, likelihood, etc. – Designing a complete valid inference procedure is not possible for all but the simplest logics. – The semantics is “model theory”, which some find problematic for real domains. Alternatives? There have been various representational alternatives to logic proposed over the years: – Frames, semantic networks, Conceptual Dependency, Conceptual Graphs However, all the other formalisms people have proposed over the years seem to have not worked out very well. – Most could be viewed as special cases of logical frameworks, or organizations layered on top of them, etc. – The shortcomings of logic don’t disappear no matter what we do. It was also claimed by some that neural networks, etc., would eliminate the need for representations, somehow. – But, in fact, the fundamental problems don’t go away. – And things are are very easy with logical representations can be very hard to do with neural network formalisms. There’s Lots of Room to Maneuver Bear in mind, if we agree on a logic, that is just the beginning. We still have to figure out what the vocabulary is. – This is at least as much of a problem. In addition, there is no reason why one has to buy into both the language and the inference procedure. – We might find that the general inference procedure isn’t what we want, but still use the language, etc. Knowledge Bases and Beliefs, etc. We'll assume that we can describe the world in terms of sentences in our KRL. A knowledge base is a set of sentences. – I.e., it is partial description of the world (we hope). – (“Knowledge” is a bad word for this….) Sentences can be completely disembodied, but they are most interesting when used to describe mental states of agents. For example, sentences in a knowledge based can be said to represent an agent’s beliefs. – Actually, there are lots of relations an agent can have toward sentences: belief, doubt, thinking about. The philosophers call these propositional attitudes. What Does a Sentence Mean? We said that sentences are supposed to correspond to “the world”. Exactly how a sentence corresponds to the world is its interpretation. – We'll have to specify this explicitly. – More on this latter. The “world” as we will talk about it will generally be fairly small part of the whole world. – We call this the universe (or domain) of discourse. Truth and All That A sentence is true if its interpretation corresponds to what’s actually out there. – E.g., “Bush likes baseball.” is true given the normal interpretation of things. – (Obviously, we’re using English here, but we really mean “the content of this sentence, represented in our formal language”, which we haven’t seen yet.) Some sentences are true no matter how we interpret them. These are said to be valid. – E.g., “Everyone who likes baseball likes baseball.” – What about “Everyone who hates baseball doesn't like it.”? More often, sentences will be true or not depending on how we interpret them. – Such sentences are said to be satisfiable. But some are never true, and hence are unsatisfiable. – E.g.. “Bush likes baseball and Bush doesn't like baseball.” (Assertions Aren’t Everything!) Note that all our sentences are just assertions, i.e., declarative sentences. In natural language, we can “do” lots more. – E.g., we can » ask questions » give commands » express incredulity We don't (yet) have anything that corresponds to these notions, a big limitation. Note in particular that “truth” per se doesn't apply to questions or commands. Our First Logic: Propositional Calculus The syntax: – Vocabulary: » A set of propositional symbols ◆ e.g., P, Q, … » A set of logical connectives or operators ◆ usually ∨ (or), ∧ (and), ¬ (not), → (implication), maybe ≡ (equivalence) » Parenthesis (for grouping) » The special symbols True, False (logical constants) Propositional Calculus (con’t) Syntax (con’t) – Rules for forming sentences: » Each symbol (i.e., a constant or a propositional symbol) is a sentence (an atomic sentence). » A sentence in parentheses is a sentence. » If α and β are sentences, then so are ◆ ◆ ◆ ◆ ◆ ◆ α ∨ β (conjunction) α ∧ β (disjunction) ¬α (negation) α → β (implication) and similarly for whatever other connectives we allow These are complex sentences. » (Actually, we should insist on parentheses, or specify a precedence order of operators, but we drop these when they are not needed.) Sample Sentences P True P∨Q ¬P (P ∨ Q) ¬(P ∨ Q) ¬P ∨ Q (P ∨ Q) → R P ∧ ¬P But What Do the Sentences Mean? We specify semantics by stating: – The interpretation of each propositional symbol. – The interpretation of each complex sentences as a function of its parts. We interpret each propositional symbol as referring to some proposition (whichever one you like). – E.g., P might be “It is raining in Oakland”, and Q, “Paris is the capital of Germany.” We interpret logical connectives in the obvious way. – E.g., ¬P means that P is not the case; P ∨ Q means that at least one of P or Q is true. Truth For sentences, we also get to say whether they are true or false. – True is always true; False always false. – P, Q, etc., are true or false depending on their interpretation. » So these are satisfiable, but not valid. – Complex sentences are true or false as a function of their connective. » Usually specified as a truth table. Truth Tables Conjunction (∧) α β Disjunction (∨) α∧β α β α∨β false false false false false false false true false false true true true false false true false true true true true true true true Implication (→) α β Negation (¬) α→β false false true false true true true false false true true true α ¬α false true true false Comments Note that connectives are truth conditional, i.e., their truth is completely determined by the truth of their subparts. This doesn’t seem true even for the corresponding named terms of ordinary language. – “Touch that and you die!” – “Bush having used heroin implies that he will legalize drugs.” A Proof Theory for Propositional Logic It is easy to devise a procedure to determine the truth of an arbitrary sentence in propositional logic. Just write down a big truth table, and see if the sentence is always true. E.g., suppose we want to know if ¬(P∧Q)→ ¬P∨¬Q. Here is a truth table: P Q ¬(P∧Q) ¬P∨¬Q ¬(P∧Q)→ ¬P∨¬Q false false true true true false true true true true true false true true true true true false false true So we have proved this sentence. Reasoning in Propositional Logic Similarly, if we assume a few things, we can determine if something follows. E.g., if we assume P, then P∨Q, say, degenerates into True∨Q, which a truth table will tell us is always true. So, we can always draw valid conclusions from premises, regardless of that any of this means. More Convenient Reasoning While it is not strictly necessary—we can always use truth-tables—it is convenient to capture common patterns of inference, using inference rules. We often write these as α, β, … γ or, sometimes, as α, β, …|− γ meaning, if we know α, β, …, it is okay to conclude γ. Common Inference Rules Modus Ponens: α→β, α |− β And-Elimination: α1∧α2 |− αi And-Introduction: α1, α2 |− α1∧α2 Or-Introduction: α |− α∨β Double-Negation Elimination: ¬¬α |− α Resolution: α∨β, ¬β∨γ |− α∨γ The Complexity of Propositional Inference While propositional logic inference procedures are complete, the problem of finding a proof is generally regarded to be exponential. – In general, determining whether a set of sentences is satisfiable is NP-complete. Of course, any particular proof might be easy. And there are useful special cases which are better. E.g., if we can express all our knowledge in form P1 ∧ P2 ∧ P3 … ∧ Pn → Q then there is a polynomial-time inference procedure. – These are called Horn clauses. – Not all knowledge bases can be expressed this way. But! Propositional calculus is not expressive enough to much interesting reasoning. For example, if P = “It is raining” Q = “Jan is outside” R = “Jan is wet” we can say P ∧ Q → R. Then, by MP, if P ∧ Q, we could deduce R. But we would need an entirely different rule for Pat. What we would like instead is to be able to say that this is true in general for things of people. Example: Using Propositional Logic for a Blocks World Problem Suppose we have tiny world, and try to solve problems in it with propositional logic. E.g.: Suppose our world is this: A B C Table with rules like – If you move a block x from y to z, it is now on z. – To move a block, nothing can be on top of it. Our goal might be building a tower with A on top of B on top of C. A B C Table With Propositional Logic All we have to work with is propositions, so suppose we have a set of propositions like CA, OAB , OA, meaning things like “Nothing is on A”, “A is on B”, and “A is on table”, resp. Then initial state of world might be: CA: Nothing is on A. CC: Nothing is on C. OAB: A is on B. OB: B is on the table. OC: C is on the table. And our goal: OAB ∧ OBC And some facts We might add that OAB ∨ OCB → ¬CB OAB → ¬OAC ∧ ¬OA etc. Note that we can indeed use logic for something: – We can ask if our goal state is true. But how do we encode actions, like “moving A to the table?” Several subproblems: – How do we say “A must be clear to move it”? – How do we say “After moving A to the table, it is on the table”? I.e., we want to say things like CA → MA (“If A is clear, then you can move it to the table.”) MA → OA (“If you move A to the table, it is on the table.”) but MA is used inconsistently here. Representing Actions One trick helps somewhat: Can say (CA ∧ MA) → OA i.e., if A is clear and you move it to the table, then it is on the table. Of course, we will need a lot of sentences like this one. Then we might try different moves by assuming MA, say, and seeing if we can find a sequence of such assumptions that will let us achieve our goal. But this isn’t quite right. – If we assume MA, then since, CA is true, we could prove OA, which isn’t true. – I.e., we have no notion of time at all. A Quick Fix: Introduce States of the World Instead of (CA ∧ MA) → OA we will say (CA0 ∧ MA0) → OA1 i.e., CA0 means A is clear in state 0, etc. We will also need (CA1 ∧ MA1) → OA2 up to some finite number. And we will have to upgrade all our formulas as well, so, e.g., instead of OAB ∨ OCB → ¬CB we would have OAB0 ∨ OCB0 → ¬CB0 Our New Goal Instead of OAB ∧ OBC something like this: OAB0 ∧ OBC0 ∨ OAB1 ∧ OBC1 ∨ OAB2 ∧ OBC2 ∨ … to some finite number of steps. Now we could try to prove this goal. (Actually, if we try, we’ll find there are quite a few more rules we have to add to make this work. We’ll explore the difficulties later.) Then we could use the formulas in the proof that have MXYs in them to as the sequence of steps to take. Bottom Line The big problem with propositional logic is – – – – we would lots and lots of symbols, and lots and lots of formulas, even for simple problems, and even then, we couldn’t really express what we want (i.e., find a solution in any number of steps). Let’s see if another representation language will help us.
© Copyright 2026 Paperzz