1 FOL CS 331 Dr M M Awais Formal Logic The most widely used formal logic method is FIRST-ORDER PREDICATE LOGIC Reference: Chapter Two The predicate Calculus.

Slides:



Advertisements
Similar presentations
Knowledge Representation using First-Order Logic
Advertisements

First-Order Logic Chapter 8.
Knowledge Representation using First-Order Logic CS 271: Fall 2007 Instructor: Padhraic Smyth.
March 2, 2006AI: Chapter 8: First-Order Logic1 Artificial Intelligence Chapter 8: First-Order Logic Michael Scherger Department of Computer Science Kent.
First-Order Logic Chapter 8.
Knowledge Representation using First-Order Logic
First-Order Logic. Limitations of propositional logic Suppose you want to say “All humans are mortal” –In propositional logic, you would need ~6.7 billion.
Logic. Propositional Logic Logic as a Knowledge Representation Language A Logic is a formal language, with precisely defined syntax and semantics, which.
9/28/98 Prof. Richard Fikes First-Order Logic Knowledge Interchange Format (KIF) Computer Science Department Stanford University CS222 Fall 1998.
Lahore University of Management Sciences, Lahore, Pakistan Dr. M.M. Awais- Computer Science Department Lecture 5 Knowledge Representation Formal Method.
First-Order Logic Chapter 8. Problem of Propositional Logic  Propositional logic has very limited expressive power –E.g., cannot say "pits cause breezes.
Knowledge Representation using First-Order Logic (Part III) This lecture: R&N Chapters 8, 9 Next lecture: Chapter 13; Chapter (Please read lecture.
First-Order Logic Chapter 8. Outline Why FOL? Syntax and semantics of FOL Using FOL Wumpus world in FOL Knowledge engineering in FOL.
Predicate Calculus.
CE An introduction to Artificial Intelligence CE Chapter 8: First Order Logic Ramin Halavati In which we notice that.
Propositional Logic Agenda: Other forms of inference in propositional logic Basics of First Order Logic (FOL) Vision Final Homework now posted on web site.
First-Order Logic Knowledge Representation Reading: Chapter 8, , FOL Syntax and Semantics read: FOL Knowledge Engineering read:
FIRST ORDER LOGIC Levent Tolga EREN.
Knowledge representation methods جلسه سوم. KR is AI bottleneck The most important ingredient in any expert system is knowledge. The power of expert systems.
Artificial Intelligence Building Knowledge Base Chapter 8.
AIC1 Logic Propositional Logic (Calculus) First Order Logic Based on Russell and Norvig slides.
First-Order Logic Chapter 8.
First-Order Logic Chapter 8. Outline Why FOL? Syntax and semantics of FOL Using FOL Wumpus world in FOL Knowledge engineering in FOL.
1 First-Order Logic Chapter 8. 2 Why FOL? –How do you say “All students are smart?” –Some students work hard –Hardworking students have good marks –If.
ARTIFICIAL INTELLIGENCE Lecture 3 Predicate Calculus.
© Copyright 2008 STI INNSBRUCK Intelligent Systems Predicate Logic.
First-Order Logic Chapter 8. Outline Why FOL? Syntax and semantics of FOL Using FOL Wumpus world in FOL Knowledge engineering in FOL.
Knowledge Representation using First-Order Logic 부산대학교 전자전기컴퓨터공학과 인공지능연구실 김민호
Limitation of propositional logic  Propositional logic has very limited expressive power –(unlike natural language) –E.g., cannot say "pits cause breezes.
First-Order Logic Chapter 8. Outline Why FOL? Syntax and semantics of FOL Using FOL Wumpus world in FOL Knowledge engineering in FOL.
CS 666 AI P. T. Chung First-Order Logic First-Order Logic Chapter 8.
First-Order Logic Chapter 8. Outline Why FOL? Syntax and semantics of FOL Using FOL Wumpus world in FOL Knowledge engineering in FOL.
1 FOL CS 531 Dr M M Awais Formal Logic The most widely used formal logic method is FIRST-ORDER PREDICATE LOGIC Reference: Chapter Two The predicate Calculus.
Artificial Intelligence First-Order Logic (FOL). Outline of this Chapter The need for FOL? What is a FOL? Syntax and semantics of FOL Using FOL.
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Lecture 11 Jim Martin.
First-Order Logic Chapter 8 (not 8.1). Outline Why FOL? Why FOL? Syntax and semantics of FOL Syntax and semantics of FOL Using FOL Using FOL Wumpus world.
First-Order Logic. Outline Why FOL? Syntax and semantics of FOL Using FOL Knowledge engineering in FOL.
LOGIC. Logic in general  Logics are formal languages for representing information such that conclusions can be drawn  Syntax defines the sentences in.
First-Order Logic Chapter 8. Outline Why FOL? Syntax and semantics of FOL Using FOL Wumpus world in FOL Knowledge engineering in FOL.
5/16/2005EE562 EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS Lecture 12, 5/16/2005 University of Washington, Department of Electrical Engineering Spring.
First-Order Logic Reading: C. 8 and C. 9 Pente specifications handed back at end of class.
1 CS 4700: Foundations of Artificial Intelligence Carla P. Gomes Module: FOL (Reading R&N: Chapter 8)
First-Order Logic Semantics Reading: Chapter 8, , FOL Syntax and Semantics read: FOL Knowledge Engineering read: FOL.
1 First Order Logic CS 171/271 (Chapter 8) Some text and images in these slides were drawn from Russel & Norvig’s published material.
LOGIC Heng Ji Feb 19, Logic Knowledge-based agents Knowledge base (KB) = set of sentences in a formal language Declarative approach.
First-Order Logic Chapter 8. Problem of Propositional Logic  Propositional logic has very limited expressive power –E.g., cannot say "pits cause breezes.
B.Ombuki COSC 3P711 LOGIC: Knowledge representation Propositional Logic: ch.7 First-Order-Logic: ch.8.
Knowledge Representation using First-Order Logic (Part II) Reading: R&N Chapters 8, 9.
CPSC 420 – Artificial Intelligence Texas A & M University Lecture 7 Lecturer: Laurie webster II, M.S.S.E., M.S.E.e., M.S.BME, Ph.D., P.E.
© Copyright 2008 STI INNSBRUCK Intelligent Systems – Predicate Logic Florian Fischer Partially based on CS188,
First-Order Logic Knowledge Representation
First-Order Logic Chapter 8.
First-Order Logic.
First-Order Logic Chapter 8.
Artificial Intelligence First Order Logic
Notes 8: Predicate logic and inference
First-Order Logic Knowledge Representation
Artificial Intelligence 1: First-Order Logic
CS 188: Artificial Intelligence Spring 2007
First-Order Logic Knowledge Representation
First-Order Logic Knowledge Representation
First-Order Logic Chapter 8.
First-Order Logic Chapter 8.
Artificial Intelligence: Agents and First-Order Logic
Introduction to Artificial Intelligence
First-Order Logic Chapter 8.
Knowledge Representation using First-Order Logic (Part III)
First-Order Logic Knowledge Representation
First-Order Logic Chapter 8.
First-Order Logic Chapter 8.
Presentation transcript:

1 FOL CS 331 Dr M M Awais Formal Logic The most widely used formal logic method is FIRST-ORDER PREDICATE LOGIC Reference: Chapter Two The predicate Calculus Luger’s Book Examples included from Norvig and Russel.

2 FOL CS 331 Dr M M Awais First-order logic Whereas propositional logic assumes the world contains facts, first-order logic (like natural language) assumes the world contains –Objects: people, houses, numbers, colors, baseball games, wars, … –Relations: red, round, prime, brother of, bigger than, part of, comes between, … –Functions: father of, best friend, one more than, plus, …

3 FOL CS 331 Dr M M Awais Syntax of FOL: Basic elements Constantsjohn, 2, lums,... Predicatesbrother, >,... Functionssqrt, leftsideOf,... VariablesX,Y,A,B... Connectives , , , ,  Equality= Quantifiers , 

4 FOL CS 331 Dr M M Awais Truth in first-order logic Sentences are true with respect to a model and an interpretation Model contains objects (domain elements) and relations among them Interpretation specifies referents for constant symbols → objects predicate symbols → relations function symbols →functional relations An atomic sentence predicate(term 1,...,term n ) is true iff the objects referred to by term,,..., term, are in the relation referred to by predicate

5 FOL CS 331 Dr M M Awais Alphabets-I Predicates, variables, functions,constants, connectives, quantifiers, and delimiters Constants: (first letter small) bLUEa color sanTROa car crowa bird Variables: (first letter capital) Dog: an element that is a dog, but unspecified Color:an unspecified color

6 FOL CS 331 Dr M M AwaisAlphabets-II Function: Maps Sentences to Objects Ali is father of Babarfather(babar) = ali father_of(baber) = ali Interpretation has to be very clear. If you write father(baber), the answer should be ali For the above functions the arity is 1 (number of arguments to the function)

7 FOL CS 331 Dr M M AwaisAlphabets-II Functions: 1) shahid likes zahidlikes(shahid) = zahid 2) atif likes abidlikes(atif) = abid 3)Constants to Variableslikes(X) = Y BINDINGS {X,Y} have two possible BINDINGS {X, Y} could be {shahid, zahid} Or {X,Y} could be {atif, abid} likes(X) =Y Substitutions: For 1 to be true: {shahid/X, zahid/Y} For 2 to be true: {atif/X, abid/Y}

8 FOL CS 331 Dr M M AwaisAlphabets-II Predicate Maps Sentences to Truth Values (True/False) 1) Shahid is studentstudent(shahid) 2) Sana is a girlgirl(sana) 3) Father of baber is elder than Hamza elder(father(babar), hamza) For 1 and 2 arity is 1 and for 3 the arity is 2

9 FOL CS 331 Dr M M AwaisAlphabets-II Predicate 1)Shahid is a good student student(shahid,good) or good_student(shahid) 2) Sana is a friend of Saima, Sana and Saima both are girls friend_of(sana,saima)^girl(sana)^girl(saima) 3) Bill helps Fred helps(bill,fred)

10 FOL CS 331 Dr M M Awais Atomic sentences Atomic sentence =predicate (term 1,...,term n ) or term 1 = term 2 term = function (term 1,...,term n ) or constant or variable brother(john,richard) greater(length(leftsideOf(squareA)), length(leftsideOf(squareB))) >(length(leftsideOf(squareA)), length(leftsideOf(squareB))) Functions cannot be atomic sentences

11 FOL CS 331 Dr M M Awais Alphabets-III Connectives: ^and vor ~not Implication Quantification All persons can see There is a person who cannot see Universal quantifiers  (ALL) Existential quantifiers  (There exists)

12 FOL CS 331 Dr M M Awais Complex sentences Complex sentences are made from atomic sentences using connectives  S, S 1  S 2, S 1  S 2, S 1  S 2, S 1  S 2, sibling(ali,hamza)  sibling(hamza,ali) >(1,2)  ≤ (1,2) (1 is greater than 2 or less than equal to 2) >(1,2)   >(1,2) (1 is greater than 2 and is not greater than equal to 2)

13 FOL CS 331 Dr M M Awais Examples My house is a blue, two-story, with red shutters, and is a corner house blue(my-house)^two-story(my-house)^red-shutters(my- house)^corner(my-house) Ali bought a scooter or a car bought(ali, car) v bought(ali, scooter) IF fuel, air and spark are present the fuel will combust present(spark)^present(fuel)^present(air) combustion(fuel)

14 FOL CS 331 Dr M M Awais Universal quantification  Everyone at LUMS is smart:  X at(X, lums)  smart(X)  X P is true in a model m iff P is true with X being each possible object in the model Roughly speaking, equivalent to the conjunction of instantiations of P at(rabia,lums)  smart(rabia)  at(shahid,lums)  smart(shahid)  at(lums,lums)  smart(lums) ...

15 FOL CS 331 Dr M M AwaisExamples All people need air  X[person(X) need_AIR(X)] The owner of the car also owns the boat [owner(X, car) ^ car(X, boat)] Formulate the following expression in the PC: “Ali is a computer science student but not a pilot or a football player” cs_STUDENT(ali)  (  pilot(ali)   ft_PLAYER(ali) )

16 FOL CS 331 Dr M M Awais Examples Restate the sentence in the following way: 1.Ali is a computer science (CS) student 2.Ali is not a pilot 3.Ali is not a football player cs_student(ali)^ ~pilot(ali)^ ~football_player(ali)

17 FOL CS 331 Dr M M AwaisExamples Studying fuzzy systems is exciting and applying logic is great fun if you are not going to spend all of your time slaving over the terminal  X(~slave_terminal(X) [fs_eciting(X)^logic_fun(X)]) Every voter either favors the amendment or despises it  X[voter(X) [favor(X, amendment) v despise(X,amendment)] ^ ~[favor(X, amendment) v despise(X, amendment)] (this part simply endorses the statement, may not be required)

18 FOL CS 331 Dr M M Awais Undecidable Predicate For which exhaustive testing is required Example:  X likes(zahra, X) This sentence is computationally impossible to calculate Scope of problem domain is to be limited to remove this problem, –i.e., X is a variable representing final year female student in the AI class, compared to an X representing all the people in the city of Lahore

19 FOL CS 331 Dr M M Awais Robotic Arm Example Represent the initial details of the system Generate sentences of descriptive and or implicative nature Modify the facts using new sentences a b c d

20 FOL CS 331 Dr M M Awais Example: Robotic Arm Represent the initial details of the systems a b c d on(a,b) on( c,d) ontable(b) ontable(d) clear(a) clear(c) hand_empty

21 FOL CS 331 Dr M M Awais Goal: To pick a block and place it over another block Define predicate: stack_on(X,Y) General sentence: Conditions Conclusions What could the conditions? hand_empty clear (X) clear (Y) pick (X) put_on (X,Y) a b c d hand_empty ^ clear (X) ^ clear (Y) ^ pick (X) ^ put_on (X,Y) stack_on (X,Y)

22 FOL CS 331 Dr M M Awais Goal: To pick a block and place it over another block hand_empty ^ clear (X) ^ clear (Y) ^ pick (X) ^ put_on (X,Y)  stack_on (X,Y) hand_empty ^ clear (X)  pick (X) clear(Y) ^ pick (X)  put_on (X,Y) put_on (X,Y)  stack_on (X,Y) Semantically more correct hand_empty could be written as empty(hand), if hand_empty is in the knowledge base, then hand is empty otherwise false. put_on (X,Y)  stack_on (X,Y) is in fact equivalence

23 FOL CS 331 Dr M M Awais Example: Robotic Arm Modify details of the systems a b c d on(b,a) on( c,d) ontable(b) ontable(d) clear(a) clear(c) hand_empty a b c d on(b,a) on( c,d) on(e,a) ontable(b) ontable(d) clear(c) clear(e) hand_empty e

24 FOL CS 331 Dr M M Awais Models for FOL: Example

25 FOL CS 331 Dr M M Awais A common mistake to avoid Represent: Everyone at LUMS is smart  X at(X,lums)  smart(X)  X at(X, lums)  smart(X) Common mistake: using  as the main connective with  : means “Everyone is at LUMS and everyone is smart” “Everyone at LUMS is smart” Typically,  is the main connective with 

26 FOL CS 331 Dr M M Awais Existential quantification  Someone at LUMS is smart:  X at(X,lums)  smart(X)  X P is true in a model m iff P is true with X being some possible object in the model Roughly speaking, equivalent to the disjunction of instantiations of P at(sana,lums)  smart(sana)  at(bashir,lums)  smart(bashir)  at(lums,lums)  smart(lums) ...

27 FOL CS 331 Dr M M Awais Another common mistake to avoid Typically,  is the main connective with  Common mistake: using  as the main connective with  :  X at(X,lums)  smart(X) is true if there is anyone who is not at LUMS! Even if the antecedent is false the sentence can still be true (see the truth table of implication).

28 FOL CS 331 Dr M M Awais Properties of quantifiers  X  Y is the same as  Y  X  X  Y is the same as  Y  X  X  Y is not the same as  Y  X  X  Y loves(X,Y) “There is a person who loves everyone in the world”  Y  X Loves(X,Y) “Everyone in the world is loved by at least one person” Quantifier duality: each can be expressed using the other  X likes(X,car)  X  likes(X,car)  X likes(X,bread)  X  likes(X,bread)

29 FOL CS 331 Dr M M Awais Equality term 1 = term 2 is true under a given interpretation if and only if term 1 and term 2 refer to the same object Sibling in terms of Parent:  X,Y sibling(X,Y)  [  (X = Y)   M,F  (M = F)  parent(M,X)  parent(F,X)  parent(M,Y)  parent(F,Y)]

30 FOL CS 331 Dr M M Awais Using FOL The kinship domain: Brothers are siblings  X,Y brother(X,Y)  sibling(X,Y) One's mother is one's female parent  M,C mother(C) = M  (female(M)  parent(M,C)) “Sibling” is symmetric  X,Y sibling(X,Y)  sibling(Y,X)

31 FOL CS 331 Dr M M Awais Rules: Wumpus world Perception –  T,S,B percept([S,B,glitter],T)  glitter(T) Reflex –  T glitter(T)  bestAction(grab,T)

32 FOL CS 331 Dr M M Awais Deducing Squares/Properties What are Adjacent Squares  X,Y,A,B adjacent([X,Y],[A,B])  [A,B]  {[X+1,Y], [X-1,Y],[X,Y+1],[X,Y-1]} Properties of squares:  S,T at(agent,S,T)  breeze(T)  breezy(S) Squares are breezy near a pit: Diagnostic rule---infer cause from effect  S breezy(S)  adjacent(R,S)  pit(R) Causal rule---infer effect from cause  R pit(R)  [  S adjacent(R,S)  breezy(S)]

33 FOL CS 331 Dr M M Awais Knowledge engineering in FOL 1.Identify the task 2.Assemble the relevant knowledge 3.Decide on a vocabulary of predicates, functions, and constants 4.Encode general knowledge about the domain 5.Encode a description of the specific problem instance 6.Pose queries to the inference procedure and get answers 7.Debug the knowledge base

34 FOL CS 331 Dr M M Awais The electronic circuits domain One-bit full adder

35 FOL CS 331 Dr M M Awais The electronic circuits domain 1.Identify the task –Does the circuit actually add properly? (circuit verification) 2.Assemble the relevant knowledge –Composed of wires and gates; Types of gates (AND, OR, XOR, NOT) –Irrelevant: size, shape, color, cost of gates 3.Decide on a vocabulary –Alternatives: type(x 1 ) = xor type(x 1, xor) xor(x 1 )

36 FOL CS 331 Dr M M Awais The electronic circuits domain 4.Encode general knowledge of the domain –  T 1,T 2 connected(T 1, T 2 )  signal(T 1 ) = signal(T 2 ) –  T signal(T) = 1  signal(T) = 0 –1 ≠ 0 –  T 1,T 2 connected(T 1, T 2 )  connected(T 2, T 1 ) –  G type(G) = OR  signal(out(1,G)) = 1   N signal(in(N,G)) = 1 –  G type(G) = AND  signal(out(1,G)) = 0   N signal(in(N,G)) = 0 –  G type(G) = XOR  signal(out(1,G)) = 1  signal(in(1,G)) ≠ signal(in(2,G)) –  G type(G) = NOT  signal(out(1,G)) ≠ signal(in(1,G))

37 FOL CS 331 Dr M M Awais The electronic circuits domain 5.Encode the specific problem instance type(x 1 ) = xortype(x 2 ) = xor type(a 1 ) = and type(a 2 ) = and type(o 1 ) = or connected(out(1,x 1 ),in(1,x 2 ))connected(in(1,c 1 ),in(1,x 1 )) connected(out(1,x 1 ),in(2,a 2 ))connected(in(1,c 1 ),in(1,a 1 )) connected(out(1,o 2 ),in(1,o 1 )) connected(in(2,c 1 ),in(2,x 1 )) connected(out(1,a 1 ),in(2,o 1 )) connected(in(2,c 1 ),in(2,a 1 )) connected(out(1,x 2 ),out(1,c 1 )) connected(in(3,c 1 ),in(2,x 2 )) connected(out(1,o 1 ),out(2,c 1 )) connected(in(3,c 1 ),in(1,a 2 ))

38 FOL CS 331 Dr M M Awais The electronic circuits domain 6.Pose queries to the inference procedure What are the possible sets of values of all the terminals for the adder circuit?  I 1,I 2,I 3,O 1,O 2 signal(in(1,c_1)) = I 1  signal(in(2,c 1 )) = I 2  signal(in(3,c 1 )) = I 3  signal(out(1,c 1 )) = O 1  signal(out(2,o 1 )) = O 2 7.Debug the knowledge base May have omitted assertions like 1 ≠ 0

39 FOL CS 331 Dr M M Awais Summary First-order logic: –objects and relations are semantic primitives –syntax: constants, functions, predicates, equality, quantifiers Increased expressive power: sufficient to define wumpus world

40 FOL CS 331 Dr M M Awais Operations Unification: Algorithm for determining the subitutions needed to make two predicate calculus expressions match Skolemization: A method of removing or replacing existential quantifiers Composition: If S and S` are two substitutions sets, then the composition of S and S` (SS`) is obtained by applying the elements of S to the elements of S` and finally adding the results