Presentation is loading. Please wait.

Presentation is loading. Please wait.

6/11/2016 Linear Resolution and Introduction to First Order Logic Michael Leuschel Softwaretechnik und Programmiersprachen Lecture 5.

Similar presentations


Presentation on theme: "6/11/2016 Linear Resolution and Introduction to First Order Logic Michael Leuschel Softwaretechnik und Programmiersprachen Lecture 5."— Presentation transcript:

1

2 6/11/2016 Linear Resolution and Introduction to First Order Logic Michael Leuschel Softwaretechnik und Programmiersprachen Lecture 5

3 6/11/2016 Recap: CNF & Resolution Conjunctive Normal Form: set of clauses clause = disjunction of literals literal = p or  p Example: {  p  q, wet   rains   outside } Resolution From p   and  p   derive a new logical consequence    Proof by refutation for S  {L}: Show that S  {  L} is inconsistent by obtaining the contradiction  by resolution

4 6/11/2016 Linear Resolution 1.Take a theory T in CNF with Horn clauses, but no denials 2. Take a denial D 3. Resolve the denial with one clause from T you obtain a new denial D’ 4. Set D := D’ (forget old denial) and restart at step 2 until you reach a contradiction Observations: Negative literals: always from D, Positive literals always from T, T remains unchanged T: p  q q D:  p D’:  q

5 6/11/2016 Linear Resolution and Prolog umbrella :- rain, outside. rain. outside. ?- umbrella. yes umbrella   rain   outside rain outside  umbrella   rain   outside   outside   umbrella  rain  outside Linear = One can forget the past

6 6/11/2016 SLD-Trees: Definition SLD-Tree for P  {  Q}: Root (Wurzel) Initial query:  Q Leaves (Blätter): Success  or If no head of clause from P unifies with selected atom Ever non-success node: Selected atom is underlined Children are all resolvents (obtained by resolving literal with a clause from P)

7 6/11/2016 SLD-Trees  p  q   r  s   r  r   t   r  Prolog: explores this tree Depth-First, always selects leftmost literal p :- q,r. q :- t. q :- s. r. s.

8 Types of SLD Trees Failed vs Successful Successful: contains a leaf marked  Failed: otherwise Finite vs Infinite 6/11/2016 Theorem: P  {  Q} is inconsistent iff the SLD-tree for P  {  Q} is successful

9 Exercise: Find P  {  Q} for: A finitely-failed SLD- tree An infinitely-failed SLD-tree A infinite successful SLD-tree An infinite successful SLD-tree where Prolog does not find an answer 6/11/2016

10 Non Linear Resolution 1) cut   say 2) cut  say Non-linear resolution required to show that “cut” is a logical consequence! Observe: 2) not a Horn clause Linear = One can forget the past One day Tokusan told his student Gantõ, “I have two monks who have been here for many years. Go and examine them.” Gantõ picked up an ax, saying, “If you say a word I will cut off your heads; and if you do not say a word, I will also cut off your heads.”

11 6/11/2016 First-Order Logic

12 6/11/2016 Why a more expressive logic? Example: John loves all girls Janet is a girl Therefore, John loves Janet Propositional Logic: {j_loves_all_girls, janet_is_girl}  {j_loves_janet} But: argument above still valid  We have to be able to talk about objects/individuals 

13 6/11/2016 Addition 1: Constants Constants: a,b,c, john, janet Start with lowercase letter Do not stand for a truth-value (true/false) Represent a particular object from the “real world” john janet a b c (mathematically: interpretations will map each constant to an element from a domain)

14 6/11/2016 Addition 2: Predicates Predicates: girl(_), loves(_,_), … Start with lowercase letter Represent relations between objects Have an arity loves(_,_): 2 girl(_): 1 rains: 0 (propositions are just a special case) loves(john,janet) binary relation

15 6/11/2016 Addition 3: Variables Variables: X,Y,Z,… Start with uppercase letter Do not have a truth-value either Can stand for “any” object from the “real world” X

16 6/11/2016 Addition 4: Quantifiers Universal quantifier  (for all) Example:  X loves(X,X) Intuitively: “Everybody loves himself” (  X F): means that for all possible values of X the formula F has to be true Existential quantifier  (there exists) Example:  X girl(X) Intuitively: “There exists a girl” (  X F): means that we can find one value (at least) for X such that the formula F is true

17 6/11/2016 Exercise: Dylan Translate into logic: You can fool some of the people all of the time. You can fool all of the people some of the time. But you cannot fool all of the people all of the time. Use predicate: fool(X,T): you can fool X at time T

18 6/11/2016 Exercise: Solution Translate into logic: You can fool some of the people all of the time. You can fool all of the people some of the time. But you cannot fool all of the people all of the time. A Solution:  X  T fool(X, T)  T  X fool(X, T) (maybe also acceptable:  X  T fool(X, T))  (  X  T fool(X, T) )

19 Exercise 2 Graph Colouring Predicates: colour(node,col) link(node1,node2) =/2 adjacent nodes have different colour 6/11/2016

20 Exercise 3 N-Queens Predicates: queen(i,j) 6/11/2016

21 Exercise 4 “Shoes must be worn” “Dogs must be carried” Predicates: OnEscalator(x),... 6/11/2016 Source: Michael Jackson, Wikimedia Commons

22 6/11/2016 Addition 5: Function Symbols Function symbols: succ(_), cons(_,_), … Start with lowercase letter Represent total functions between objects Have an arity cons(_,_): 2 succ(_): 1 john: 0 (constants are just a special case) unary function

23 6/11/2016 Natural Numbers Constant 0 Function symbol succ(_) Describing natural numbers: nat(0)  X ( nat(succ(X))  nat(X) ) Describing addition:  X plus(0, X, X)  X Y Z ( plus(succ(X),Y,succ(Z))  plus(X, Y, Z) ) 0 1 2 3 4 5 6 7 8 9 10... succ (but there are Prolog built-in’s)

24 Exercise Define (in terms of plus/3) Subtraction Multiplication Run it in Prolog 6/11/2016

25 Representing Lists Constant nil: empty list Function symbol.(_,_).(H,T): list with first element H and tail T [a,b] denoted by.(a,.(b,nil)) nil [] [a][a] [a,b] [a,a] [b][b] [b,a] ab [b,b].  X app([],X,X)

26 6/11/2016 Summary 0. Propositional Logic - propositions (basic units: either true or false) - logical connectives (     ) 1. First-Order Logic - constants, functions, variables (tom mother(tom) X) - relations ( human(.) married(.,.) ) - quantifiers (   ) p  p rains  rains rains  carry_umbrella  X. human(X)  mortal(X) human(sokrates) rains no variables variables over objects

27 6/11/2016 What definitely to know for the exam Linear Resolution Ingredients of First Order Logic (FOL) Constants, predicates, quantifiers, function symbols Translating natural language into FOL Tutorial How to represent data-structures in FOL Natural numbers, lists Trees (later in the course)


Download ppt "6/11/2016 Linear Resolution and Introduction to First Order Logic Michael Leuschel Softwaretechnik und Programmiersprachen Lecture 5."

Similar presentations


Ads by Google