Artificial Intelligence Logic Course 7 Knowledge Representation As the degree of “connectedness” and “understanding” increase, we progress from data through information and knowledge to wisdom Degree of Connectedness Wisdom Knowledge Information Understanding patterns Understanding relations Data Understanding principles Degree of understanding Models of Representation ١. Symbolic representation ١. Expert systems ١. Semantics networks ١. Conceptual dependency ١. Frame representation ١. Script representation Logic and Natural Language A language with concrete rules Many ways to translate between languages A statement can be represented in different logics And perhaps differently in same logic Expressiveness of a logic No ambiguity in representation (may be other errors!) Allows unambiguous communication and processing Very unlike natural languages e.g. English How much can we say in this language? Not to be confused with logical reasoning Logics are languages, reasoning is a process (may use logic) Syntax and Semantics Syntax Semantics Rules for constructing legal sentences in the logic Which symbols we can use (English: letters, punctuation) How we are allowed to combine symbols How we interpret (read) sentences in the logic Assigns a meaning to each sentence Example: “All lecturers are seven foot tall” A valid sentence (syntax) And we can understand the meaning (semantics) This sentence happens to be false (there is a counterexample) Example In a restaurant, your Father has ordered Fish, your Mother ordered Vegetarian, and you ordered Meat. Out of the kitchen comes some new person carrying the three plates. What will happen? Questions “Who has the meat?” “Who has the meat?” Logic Propositional Logic Predicate Logic The study of statements and their connectivity structure The study of individuals and their properties Propositional logic more abstract and hence less detailed than predicate logic Proposition Logic Also known as sentential logic Is a formal system in which knowledge is represented as propositions These propositions can be joined in various ways using logical operators These expressions can then be interpreted as truth-preserving inference rules that can be used to derive new knowledge from the old, or test the existing knowledge. Propositional Logic The logic formalism allows the derivation of new knowledge from already known knowledge, using logic-mathematic deduction Applicability Automate demonstration of theorems Artificial intelligence Propositional Logic A proposition is a statement that is either true or false (but not both) In propositional logic, we assume a collection of atomic propositions are given: p, q, r, s, t, …. Then we form compound propositions by using logical connectives (logical operators) Propositional Logic Syntax Propositions, e.g. “it is wet” Connectives: and, or, not, implies, iff (equivalent) Brackets, T (true) and F (false) Semantics Define how connectives affect truth “P and Q” is true if and only if P is true and Q is true Use truth tables to work out the truth of statements Propositional Logic A formula is valid if it holds under every assignment. |= F to denote this. A valid formula is called a tautology A sentence is contingent if and only if some interpretation satisfies it and some interpretation falsifies it. P: ‘2+2 = 4 ‘ P: ‘It will rain tomorrow ‘ A formula is unsatisfiable if it holds under no assignment. An unsatisafiable formula is called a contradiction P: ‘1=0’ Inference rules P P→ Q Q Modus Ponens Chain rule AND introduction Transposition P→ Q Q→ R P→ R P Q P∧ Q P→ Q ~Q→ ~ P Example p = “AI covers logic programming.” q = “AI only covers fun topics.” r = “Logic programming is a fun topic.” ¬p = “AI does not cover logic programming.” pΛq = “AI covers logic programming and AI only covers fun topics.” pVq →r = “If AI covers logic programming and AI only covers fun topics, then logic programming is a fun topic.” Predicate Logic Propositional logic combines atoms Predicates allow us to talk about objects. It is a property or description of subjects in the universe of discourse An atom contains no propositional connectives Have no structure (today_is_wet, john_likes_apples) Properties: is_wet(today) Relations: likes(john, apples) True or false In predicate logic each atom is a predicate e.g. first order logic, higher-order logic Predicate Logic More expressive logic than propositional) Constants are objects: john, apples Predicates are properties and relations: Functions transform objects: likes(john, apples) likes(john, fruit_of(apple_tree)) Variables represent any object: likes(X, apples) Quantifiers qualify values of variables True for all objects (Universal): apples) Exists at least one object (Existential): apples) ∀X. likes(X, ∃X. likes(X, Example “Every rose has a thorn” For all X if (X is a rose) then there exists Y (X has Y) and (Y is a thorn) Example “On Mondays and Wednesdays I go to John’s house for dinner” Note the change from “and” to “or” Translating is problematic Forward Chaining A Horn clause is a clause with at most one positive literal Categories A rule: 1 positive literal, at least 1 negative literal. A rule has the form "~P1 V ~P2 V ... V ~Pk V Q". This is logically equivalent to "[P1^P2^ ... ^Pk] => Q"; thus, an if-then implication with any number of conditions but one conclusion. Examples: "~man(X) V mortal(X)" (All men are mortal); "~parent(X,Y) V ~ancestor(Y,Z) V ancestor(X,Z)" (If X is a parent of Y and Y is an ancestor of Z then X is an ancestor of Z.) Forward Chaining Categories A fact or unit: 1 positive literal, 0 negative literals. Examples: "man(socrates)", "parent(elizabeth,charles)", "ancestor(X,X)" (Everyone is an ancestor of themselves (in the trivial sense).) A negated goal : 0 positive literals, at least 1 negative literal. In virtually all implementations of Horn clause logic, the negated goal is the negation of the statement to be proved; the knowledge base consists entirely of facts and goals. The statement to be proven, therefore, called the goal, is therefore a single unit or the conjuction of units; an existentially quantified variable in the goal turns into a free variable in the negated goal. Example: If the goal to be proven is "exists (X) male(X) ^ ancestor(elizabeth,X)" (show that there exists a male descendent of Elizabeth) the negated goal will be "~male(X) V ~ancestor(elizabeth,X)". The null clause: 0 positive and 0 negative literals. Appears only as the end of a resolution proof. Forward Chaining Starts with the atomic sentences in the knowledge base and apply Modus Pones in the forwarded direction, adding new atomic sentences, until no future inference can be done Forward chaining Idea: fire any rule whose premises are satisfied in the KB, add its conclusion to the KB, until query is found Forward chaining example Forward chaining example Forward chaining example Forward chaining example Forward chaining example Forward chaining example Forward chaining example Forward chaining example Backward Chaining Starts from the goal, chaining through rules to find knows facts that support the rule Depth-First Search Idea: work backwards from the query q: to prove q by BC, check if q is known already, or prove by BC all premises of some rule concluding q Avoid loops: check if new subgoal is already on the goal stack Avoid repeated work: check if new subgoal 1. has already been proved true, or 2. has already failed Backward chaining example Backward chaining example Backward chaining example Backward chaining example Backward chaining example Backward chaining example Backward chaining example Backward chaining example Backward chaining example Backward chaining example Beyond True and False Multi-valued logics More than two truth values e.g., true, false & unknown Fuzzy logic uses probabilities, truth value in [0,1] Modal logics Modal operators define mode for propositions Epistemic logics (belief) e.g. p (necessarily p), p (possibly p), … Temporal logics (time) e.g. p (always p), p (eventually p), … Next Course Probabilistic Reasoning Laboratory Verification of A* project and evolutionary algorithms project
© Copyright 2026 Paperzz