SlideShare una empresa de Scribd logo
1 de 40
Knowledge Representation using First-Order Logic




                 CS 271: Fall 2007

             Instructor: Padhraic Smyth
Logistics

          • Midterm results
                 – Graded, solutions mailed out


          • Extra-credit projects
                 – Treated as 2 additional homeworks
                     • Lowest 2 scoring homeworks dropped, rest averaged
                 – no- extra-credit project
                     • Single lowest homework score dropped, rest averaged
                 – More information on the Web site (if not now, then soon)


          • Homework 3
                 – Should be graded by Thursday


          • Homework 4
                 – Up on the Web shortly




CS 271, Fall 2007: Professor Padhraic Smyth                            Topic 8: First-Order Logic 2
Outline

          •     What is First-Order Logic (FOL)?
                 – Syntax and semantics


          •     Using FOL

          •     Wumpus world in FOL

          •     Knowledge engineering in FOL




          •     Required Reading:
                 – All of Chapter 8




CS 271, Fall 2007: Professor Padhraic Smyth        Topic 8: First-Order Logic 3
Pros and cons of propositional logic

           Propositional logic is declarative
                 - Knowledge and inference are separate


           Propositional logic allows partial/disjunctive/negated information
                 – unlike most programming languages and databases

           Propositional logic is compositional:
                 – meaning of B1,1 ∧ P1,2 is derived from meaning of B1,1 and of P1,2


           Meaning in propositional logic is context-independent
                 – unlike natural language, where meaning depends on context


           Propositional logic has limited expressive power
                 – unlike natural language
                 – E.g., cannot say "pits cause breezes in adjacent squares“
                     • except by writing one sentence for each square


CS 271, Fall 2007: Professor Padhraic Smyth                                 Topic 8: First-Order Logic 4
First-Order Logic

          • 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, …




CS 271, Fall 2007: Professor Padhraic Smyth                                Topic 8: First-Order Logic 5
Logics in General

          • Ontological Commitment:
                 – What exists in the world — TRUTH
                 – PL : facts hold or do not hold.
                 – FOL : objects with relations between them that hold or do not hold


          • Epistemological Commitment:
                 – What an agent believes about facts — BELIEF




CS 271, Fall 2007: Professor Padhraic Smyth                              Topic 8: First-Order Logic 6
Syntax of FOL: Basic elements

          • Constant Symbols:
                 – Stand for objects
                 – e.g., KingJohn, 2, UCI,...

          • Predicate Symbols
                 – Stand for relations
                 – E.g., Brother(Richard, John), greater_than(3,2)...

          • Function Symbols
                 – Stand for functions
                 – E.g., Sqrt(3), LeftLegOf(John),...




CS 271, Fall 2007: Professor Padhraic Smyth                        Topic 8: First-Order Logic 7
Syntax of FOL: Basic elements

          • Constants KingJohn, 2, UCI,...

          • Predicates Brother, >,...

          • Functions                   Sqrt, LeftLegOf,...

          • Variables                          x, y, a, b,...

          • Connectives                        ¬, ⇒, ∧, ∨, ⇔

          • Equality                           =

          • Quantifiers                        ∀, ∃




CS 271, Fall 2007: Professor Padhraic Smyth                     Topic 8: First-Order Logic 8
Relations

          • Some relations are properties: they state
            some fact about a single object: Round(ball), Prime(7).

          • n-ary relations state facts about two or more objects:
            Married(John,Mary), LargerThan(3,2).

          • Some relations are functions: their value is another object:
            Plus(2,3), Father(Dan).




CS 271, Fall 2007: Professor Padhraic Smyth                     Topic 8: First-Order Logic 9
Models for FOL: Example




CS 271, Fall 2007: Professor Padhraic Smyth   Topic 8: First-Order Logic 10
Terms

          • Term = logical expression that refers to an object.

          • There are 2 kinds of terms:
                 – constant symbols: Table, Computer
                 – function symbols: LeftLeg(Pete), Sqrt(3), Plus(2,3) etc




CS 271, Fall 2007: Professor Padhraic Smyth                              Topic 8: First-Order Logic 11
Atomic Sentences


       •     Atomic sentences state facts using terms and predicate symbols
               – P(x,y) interpreted as “x is P of y”


       •     Examples:
                 LargerThan(2,3) is false.
                 Brother_of(Mary,Pete) is false.
                 Married(Father(Richard), Mother(John)) could be true or false

       •     Note: Functions do not state facts and form no sentence:
               – Brother(Pete) refers to John (his brother) and is neither true nor false.


       •     Brother_of(Pete,Brother(Pete)) is True.



        Binary relation                       Function




CS 271, Fall 2007: Professor Padhraic Smyth                                       Topic 8: First-Order Logic 12
Complex Sentences


       • We make complex sentences with connectives (just like in
         propositional logic).
                                                       property

           ¬Brother (LeftLeg (Richard ), John ) ∨ (Democrat (Bush ))

                binary             function
                relation

                                              objects




          connectives




CS 271, Fall 2007: Professor Padhraic Smyth                 Topic 8: First-Order Logic 13
More Examples


      •     Brother(Richard, John) ∧ Brother(John, Richard)


      •     King(Richard) ∨ King(John)


      •     King(John) => ¬ King(Richard)


      •     LessThan(Plus(1,2) ,4) ∧ GreaterThan(1,2)




      (Semantics are the same as in propositional logic)




CS 271, Fall 2007: Professor Padhraic Smyth                   Topic 8: First-Order Logic 14
Variables

          • Person(John) is true or false because we give it a single
            argument ‘John’

          • We can be much more flexible if we allow variables which can
            take on values in a domain. e.g., all persons x, all integers i,
            etc.
                 – E.g., can state rules like Person(x) => HasHead(x)
                            or Integer(i) => Integer(plus(i,1)




CS 271, Fall 2007: Professor Padhraic Smyth                             Topic 8: First-Order Logic 15
Universal Quantification ∀

          ∀ ∀ means “for all”

          •     Allows us to make statements about all objects that have certain
                properties

          •     Can now state general rules:

                 ∀ x King(x) => Person(x)

                 ∀ x Person(x) => HasHead(x)

                 ∀ i Integer(i) => Integer(plus(i,1))



                 Note that
                 ∀ x King(x) ∧ Person(x) is not correct!
                 This would imply that all objects x are Kings and are People

                 ∀ x King(x) => Person(x) is the correct way to say this




CS 271, Fall 2007: Professor Padhraic Smyth                                     Topic 8: First-Order Logic 16
Existential Quantification ∃

          ∀ ∃ x means “there exists an x such that….” (at least one object x)

          •     Allows us to make statements about some object without naming it

          •     Examples:

                 ∃ x King(x)

                 ∃ x Lives_in(John, Castle(x))

                 ∃i      Integer(i) ∧ GreaterThan(i,0)




                 Note that ∧ is the natural connective to use with ∃

                 (And => is the natural connective to use with ∀ )




CS 271, Fall 2007: Professor Padhraic Smyth                            Topic 8: First-Order Logic 17
More examples



                                              For all real x, x>2 implies x>3.

                      ∀x [(x > 2) ⇒ (x > 3)] x ∈ R (false )
                      ∃x [(x 2 = −1)]                 x ∈ R (false )

                                      There exists some real x whose square is minus 1.




CS 271, Fall 2007: Professor Padhraic Smyth                                       Topic 8: First-Order Logic 18
CS 271, Fall 2007: Professor Padhraic Smyth   Topic 8: First-Order Logic 19
CS 271, Fall 2007: Professor Padhraic Smyth   Topic 8: First-Order Logic 20
CS 271, Fall 2007: Professor Padhraic Smyth   Topic 8: First-Order Logic 21
CS 271, Fall 2007: Professor Padhraic Smyth   Topic 8: First-Order Logic 22
CS 271, Fall 2007: Professor Padhraic Smyth   Topic 8: First-Order Logic 23
Combining Quantifiers

          ∀ x ∃ y Loves(x,y)
                 – For everyone (“all x”) there is someone (“y”) who loves them



          ∃ y ∀ x Loves(x,y)
               - there is someone (“y”) who loves everyone

          Clearer with parentheses:           ∃y(∀x   Loves(x,y) )




CS 271, Fall 2007: Professor Padhraic Smyth                             Topic 8: First-Order Logic 24
Connections between Quantifiers

          • Asserting that all x have property P is the same as asserting
            that does not exist any x that don’t have the property P


               ∀ x Likes(x, 271 class)       ¬ ∃ x ¬ Likes(x, 271 class)


          In effect:
           - ∀ is a conjunction over the universe of objects
            - ∃ is a disjunction over the universe of objects
                  Thus, DeMorgan’s rules can be applied




CS 271, Fall 2007: Professor Padhraic Smyth                        Topic 8: First-Order Logic 25
De Morgan’s Law for Quantifiers


                    De Morgan’s Rule                  Generalized De Morgan’s Rule
              P ∧ Q ≡ ¬(¬P ∨ ¬Q )                       ∀x P ≡ ¬∃x (¬P )
              P ∨ Q ≡ ¬(¬P ∧ ¬Q )                       ∃x P ≡ ¬∀x (¬P )
              ¬(P ∧ Q ) ≡ ¬P ∨ ¬Q                       ¬∀x P ≡ ∃x (¬P )
              ¬(P ∨ Q ) ≡ ¬P ∧ ¬Q                       ¬∃x P ≡ ∀x (¬P )

          Rule is simple: if you bring a negation inside a disjunction or a conjunction,
          always switch between them (or and, and  or).




CS 271, Fall 2007: Professor Padhraic Smyth                                Topic 8: First-Order Logic 26
Using FOL

          • We want to TELL things to the KB, e.g.
            TELL(KB, ∀x , King (x ) ⇒ Person (x ) )
            TELL(KB, King(John) )

               These sentences are assertions



          • We also want to ASK things to the KB,
            ASK(KB, ∃x , Person (x )    )

                 these are queries or goals

                The KB should return the list of x’s for which Person(x) is true:
                {x/John,x/Richard,...}




CS 271, Fall 2007: Professor Padhraic Smyth                          Topic 8: First-Order Logic 27
FOL Version of Wumpus World

          • Typical percept sentence:
                Percept([Stench,Breeze,Glitter,None,None],5)


          • Actions:
                Turn(Right), Turn(Left), Forward, Shoot, Grab, Release, Climb


          • To determine best action, construct query:
             ∀ a BestAction(a,5)


          • ASK solves this and returns {a/Grab}
             – And TELL about the action.




CS 271, Fall 2007: Professor Padhraic Smyth                              Topic 8: First-Order Logic 28
Knowledge Base for Wumpus World

          • Perception
               ∀b,g,t Percept([Breeze,b,g],t) ⇒ Breeze(t)
               ∀s,b,t Percept([s,b,Glitter],t) ⇒ Glitter(t)

          • Reflex
               ∀t Glitter(t) ⇒ BestAction(Grab,t)

          • Reflex with internal state
               ∀t Glitter(t) ∧¬Holding(Gold,t) ⇒ BestAction(Grab,t)

                 Holding(Gold,t) can not be observed: keep track of change.




CS 271, Fall 2007: Professor Padhraic Smyth                       Topic 8: First-Order Logic 29
Deducing hidden properties

          Environment definition:
                 ∀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 locations:
                    ∀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) ⇔ ∃ r Adjacent(r,s) ∧ Pit(r)

                 – Causal rule---infer effect from cause (model based reasoning)
                    ∀r Pit(r) ⇒ [∀s Adjacent(r,s) ⇒ Breezy(s)]




CS 271, Fall 2007: Professor Padhraic Smyth                       Topic 8: First-Order Logic 30
Set Theory in First-Order Logic

         Can we define set theory using FOL?
             - individual sets, union, intersection, etc


         Answer is yes.

         Basics:
          - empty set = constant = { }

           - unary predicate Set( ), true for sets

           - binary predicates:
                x∈ s    (true if x is a member of the set x)
                s1 ⊆ s2 (true if s1 is a subset of s2)

          - binary functions:
               intersection s1 ∩ s2, union s1 ∪ s2 , adjoining {x|s}



CS 271, Fall 2007: Professor Padhraic Smyth                            Topic 8: First-Order Logic 31
A Possible Set of FOL Axioms for Set Theory

          The only sets are the empty set and sets made by adjoining an
             element to a set
            ∀s Set(s) ⇔ (s = {} ) ∨ (∃x,s2 Set(s2) ∧ s = {x|s2})

          The empty set has no elements adjoined to it
              ¬∃x,s {x|s} = {}

          Adjoining an element already in the set has no effect
                 ∀x,s x ∈ s ⇔ s = {x|s}

           The only elements of a set are those that were adjoined into it.
             Expressed recursively:
            ∀x,s x ∈ s ⇔ [ ∃y,s2 (s = {y|s2} ∧ (x = y ∨ x ∈ s2))]




CS 271, Fall 2007: Professor Padhraic Smyth                       Topic 8: First-Order Logic 32
A Possible Set of FOL Axioms for Set Theory

          A set is a subset of another set iff all the first set’s members are
             members of the 2nd set
             ∀s1,s2 s1 ⊆ s2 ⇔ (∀x x ∈ s1 ⇒ x ∈ s2)

          Two sets are equal iff each is a subset of the other
            ∀s1,s2 (s1 = s2) ⇔ (s1 ⊆ s2 ∧ s2 ⊆ s1)

          An object is in the intersection of 2 sets only if a member of both
             ∀x,s1,s2 x ∈ (s1 ∩ s2) ⇔ (x ∈ s1 ∧ x ∈ s2)

          An object is in the union of 2 sets only if a member of either
             ∀x,s1,s2 x ∈ (s1 ∪ s2) ⇔ (x ∈ s1 ∨ x ∈ s2)




CS 271, Fall 2007: Professor Padhraic Smyth                        Topic 8: First-Order Logic 33
Knowledge engineering in FOL

          1.       Identify the task

          3.       Assemble the relevant knowledge

          5.       Decide on a vocabulary of predicates, functions, and constants

          7.       Encode general knowledge about the domain

          9.       Encode a description of the specific problem instance

          11. Pose queries to the inference procedure and get answers

          13. Debug the knowledge base




          •
CS 271, Fall 2007: Professor Padhraic Smyth                                Topic 8: First-Order Logic 34
The electronic circuits domain

          One-bit full adder




          Possible queries:
             - does the circuit function properly?
            - what gates are connected to the first input terminal?
            - what would happen if one of the gates is broken?
            and so on



CS 271, Fall 2007: Professor Padhraic Smyth                     Topic 8: First-Order Logic 35
The electronic circuits domain

          1.       Identify the task
                 –       Does the circuit actually add properly?

          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(X1) = XOR (function)
                         Type(X1, XOR) (binary predicate)
                         XOR(X1)
                                (unary predicate)
                 –

                 –
                 –

          •



CS 271, Fall 2007: Professor Padhraic Smyth                                     Topic 8: First-Order Logic 36
The electronic circuits domain

   1.          Encode general knowledge of the domain
                  ∀t1,t2 Connected(t1, t2) ⇒ Signal(t1) = Signal(t2)

                    ∀t Signal(t) = 1 ∨ Signal(t) = 0

           –        1≠0

                    ∀t1,t2 Connected(t1, t2) ⇒ Connected(t2, t1)

                    ∀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))

           –



CS 271, Fall 2007: Professor Padhraic Smyth                             Topic 8: First-Order Logic 37
The electronic circuits domain

          1. Encode the specific problem instance
              Type(X1) = XOR                 Type(X2) = XOR
              Type(A1) = AND                 Type(A2) = AND
              Type(O1) = OR

                 Connected(Out(1,X1),In(1,X2))      Connected(In(1,C1),In(1,X1))
                 Connected(Out(1,X1),In(2,A2))      Connected(In(1,C1),In(1,A1))
                 Connected(Out(1,A2),In(1,O1))      Connected(In(2,C1),In(2,X1))
                 Connected(Out(1,A1),In(2,O1))      Connected(In(2,C1),In(2,A1))
                 Connected(Out(1,X2),Out(1,C1))     Connected(In(3,C1),In(2,X2))
                 Connected(Out(1,O1),Out(2,C1))     Connected(In(3,C1),In(1,A2))



          •




CS 271, Fall 2007: Professor Padhraic Smyth                         Topic 8: First-Order Logic 38
The electronic circuits domain

          1.         Pose queries to the inference procedure
                 What are the possible sets of values of all the terminals for the adder
                     circuit?
                     ∃i1,i2,i3,o1,o2 Signal(In(1,C_1)) = i1 ∧ Signal(In(2,C1)) = i2 ∧ Signal(In(3,C1)) =
                     i3 ∧ Signal(Out(1,C1)) = o1 ∧ Signal(Out(2,C1)) = o2




          •          Debug the knowledge base
                 May have omitted assertions like 1 ≠ 0
                 –



                 –
          •

CS 271, Fall 2007: Professor Padhraic Smyth                                             Topic 8: First-Order Logic 39
Summary

          • First-order logic:
                 –    Much more expressive than propositional logic
                 –    Allows objects and relations as semantic primitives
                 –    Universal and existential quantifiers
                 –    syntax: constants, functions, predicates, equality, quantifiers


          • Knowledge engineering using FOL
                 – Capturing domain knowledge in logical form


          • Inference and reasoning in FOL
                 – Next lecture


          • Required Reading:
                 – All of Chapter 8




                 –
CS 271, Fall 2007: Professor Padhraic Smyth                                   Topic 8: First-Order Logic 40

Más contenido relacionado

La actualidad más candente

Project ACRN: SR-IOV implementation
Project ACRN: SR-IOV implementationProject ACRN: SR-IOV implementation
Project ACRN: SR-IOV implementationGeoffroy Van Cutsem
 
Specializing the Data Path - Hooking into the Linux Network Stack
Specializing the Data Path - Hooking into the Linux Network StackSpecializing the Data Path - Hooking into the Linux Network Stack
Specializing the Data Path - Hooking into the Linux Network StackKernel TLV
 
BGP Dynamic Routing and Neutron
BGP Dynamic Routing and NeutronBGP Dynamic Routing and Neutron
BGP Dynamic Routing and Neutronrktidwell
 
Managing ESXi - Tools and Techniques
Managing ESXi - Tools and TechniquesManaging ESXi - Tools and Techniques
Managing ESXi - Tools and TechniquesChristopher Janoch
 
Introduction to the theory of computation
Introduction to the theory of computationIntroduction to the theory of computation
Introduction to the theory of computationprasadmvreddy
 
Profiling the ACPICA Namespace and Event Handing
Profiling the ACPICA Namespace and Event HandingProfiling the ACPICA Namespace and Event Handing
Profiling the ACPICA Namespace and Event HandingSUSE Labs Taipei
 
Ceph Object Storage at Spreadshirt (July 2015, Ceph Berlin Meetup)
Ceph Object Storage at Spreadshirt (July 2015, Ceph Berlin Meetup)Ceph Object Storage at Spreadshirt (July 2015, Ceph Berlin Meetup)
Ceph Object Storage at Spreadshirt (July 2015, Ceph Berlin Meetup)Jens Hadlich
 
Análise de Algoritmos - Solução de Recorrências
Análise de Algoritmos - Solução de RecorrênciasAnálise de Algoritmos - Solução de Recorrências
Análise de Algoritmos - Solução de RecorrênciasDelacyr Ferreira
 
Programando em python listas
Programando em python   listasProgramando em python   listas
Programando em python listassamuelthiago
 
Re-define network visibility for capacity planning & forecasting with Grafana
Re-define network visibility for capacity planning & forecasting with GrafanaRe-define network visibility for capacity planning & forecasting with Grafana
Re-define network visibility for capacity planning & forecasting with GrafanaBangladesh Network Operators Group
 
OpenStack Ironic - Bare Metal-as-a-Service
OpenStack Ironic - Bare Metal-as-a-ServiceOpenStack Ironic - Bare Metal-as-a-Service
OpenStack Ironic - Bare Metal-as-a-ServiceRamon Acedo Rodriguez
 
Analyse d'un kernel (crash, core) dump
Analyse d'un kernel (crash, core) dumpAnalyse d'un kernel (crash, core) dump
Analyse d'un kernel (crash, core) dumpGaëtan Trellu
 
MQTT avec Mosquitto et Paho - Laurent Guerin - JUG Nantes Nov 2018
MQTT avec Mosquitto et Paho - Laurent Guerin - JUG Nantes Nov 2018MQTT avec Mosquitto et Paho - Laurent Guerin - JUG Nantes Nov 2018
MQTT avec Mosquitto et Paho - Laurent Guerin - JUG Nantes Nov 2018Laurent Guérin
 
XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...
XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...
XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...The Linux Foundation
 
Sisteme de Operare: Fire de executie
Sisteme de Operare: Fire de executieSisteme de Operare: Fire de executie
Sisteme de Operare: Fire de executieAlexandru Radovici
 

La actualidad más candente (20)

Strongly Connected Components
Strongly Connected Components Strongly Connected Components
Strongly Connected Components
 
Project ACRN: SR-IOV implementation
Project ACRN: SR-IOV implementationProject ACRN: SR-IOV implementation
Project ACRN: SR-IOV implementation
 
Specializing the Data Path - Hooking into the Linux Network Stack
Specializing the Data Path - Hooking into the Linux Network StackSpecializing the Data Path - Hooking into the Linux Network Stack
Specializing the Data Path - Hooking into the Linux Network Stack
 
BGP Dynamic Routing and Neutron
BGP Dynamic Routing and NeutronBGP Dynamic Routing and Neutron
BGP Dynamic Routing and Neutron
 
TOC 7 | CFG in Chomsky Normal Form
TOC 7 | CFG in Chomsky Normal FormTOC 7 | CFG in Chomsky Normal Form
TOC 7 | CFG in Chomsky Normal Form
 
Xilkernel
XilkernelXilkernel
Xilkernel
 
Managing ESXi - Tools and Techniques
Managing ESXi - Tools and TechniquesManaging ESXi - Tools and Techniques
Managing ESXi - Tools and Techniques
 
Sisteme de Operare: Procese
Sisteme de Operare: ProceseSisteme de Operare: Procese
Sisteme de Operare: Procese
 
Primality
PrimalityPrimality
Primality
 
Introduction to the theory of computation
Introduction to the theory of computationIntroduction to the theory of computation
Introduction to the theory of computation
 
Profiling the ACPICA Namespace and Event Handing
Profiling the ACPICA Namespace and Event HandingProfiling the ACPICA Namespace and Event Handing
Profiling the ACPICA Namespace and Event Handing
 
Ceph Object Storage at Spreadshirt (July 2015, Ceph Berlin Meetup)
Ceph Object Storage at Spreadshirt (July 2015, Ceph Berlin Meetup)Ceph Object Storage at Spreadshirt (July 2015, Ceph Berlin Meetup)
Ceph Object Storage at Spreadshirt (July 2015, Ceph Berlin Meetup)
 
Análise de Algoritmos - Solução de Recorrências
Análise de Algoritmos - Solução de RecorrênciasAnálise de Algoritmos - Solução de Recorrências
Análise de Algoritmos - Solução de Recorrências
 
Programando em python listas
Programando em python   listasProgramando em python   listas
Programando em python listas
 
Re-define network visibility for capacity planning & forecasting with Grafana
Re-define network visibility for capacity planning & forecasting with GrafanaRe-define network visibility for capacity planning & forecasting with Grafana
Re-define network visibility for capacity planning & forecasting with Grafana
 
OpenStack Ironic - Bare Metal-as-a-Service
OpenStack Ironic - Bare Metal-as-a-ServiceOpenStack Ironic - Bare Metal-as-a-Service
OpenStack Ironic - Bare Metal-as-a-Service
 
Analyse d'un kernel (crash, core) dump
Analyse d'un kernel (crash, core) dumpAnalyse d'un kernel (crash, core) dump
Analyse d'un kernel (crash, core) dump
 
MQTT avec Mosquitto et Paho - Laurent Guerin - JUG Nantes Nov 2018
MQTT avec Mosquitto et Paho - Laurent Guerin - JUG Nantes Nov 2018MQTT avec Mosquitto et Paho - Laurent Guerin - JUG Nantes Nov 2018
MQTT avec Mosquitto et Paho - Laurent Guerin - JUG Nantes Nov 2018
 
XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...
XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...
XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...
 
Sisteme de Operare: Fire de executie
Sisteme de Operare: Fire de executieSisteme de Operare: Fire de executie
Sisteme de Operare: Fire de executie
 

Destacado

Propositional And First-Order Logic
Propositional And First-Order LogicPropositional And First-Order Logic
Propositional And First-Order Logicankush_kumar
 
Jarrar: First Order Logic
Jarrar: First Order LogicJarrar: First Order Logic
Jarrar: First Order LogicMustafa Jarrar
 
Jarrar.lecture notes.aai.2011s.ch7.p logic
Jarrar.lecture notes.aai.2011s.ch7.p logicJarrar.lecture notes.aai.2011s.ch7.p logic
Jarrar.lecture notes.aai.2011s.ch7.p logicPalGov
 
Knowledge engg using & in fol
Knowledge engg using & in folKnowledge engg using & in fol
Knowledge engg using & in folchandsek666
 
First order logic in knowledge representation
First order logic in knowledge representationFirst order logic in knowledge representation
First order logic in knowledge representationSabaragamuwa University
 
Logic Notes
Logic NotesLogic Notes
Logic Notesacavis
 
Artificial intelligence- Logic Agents
Artificial intelligence- Logic AgentsArtificial intelligence- Logic Agents
Artificial intelligence- Logic AgentsNuruzzaman Milon
 
Applying de morgan’s laws
Applying de morgan’s lawsApplying de morgan’s laws
Applying de morgan’s lawsdeloismccormick
 
Syntax and semantics of propositional logic
Syntax and semantics of propositional logicSyntax and semantics of propositional logic
Syntax and semantics of propositional logicJanet Stemwedel
 
Quantifiers
QuantifiersQuantifiers
Quantifiersmonira21
 
Predicate Logic
Predicate LogicPredicate Logic
Predicate Logicgiki67
 
Quantifiers
QuantifiersQuantifiers
Quantifierscarme73
 

Destacado (20)

Propositional And First-Order Logic
Propositional And First-Order LogicPropositional And First-Order Logic
Propositional And First-Order Logic
 
Jarrar: First Order Logic
Jarrar: First Order LogicJarrar: First Order Logic
Jarrar: First Order Logic
 
First order logic
First order logicFirst order logic
First order logic
 
Discrete Math Lecture 02: First Order Logic
Discrete Math Lecture 02: First Order LogicDiscrete Math Lecture 02: First Order Logic
Discrete Math Lecture 02: First Order Logic
 
Jarrar.lecture notes.aai.2011s.ch7.p logic
Jarrar.lecture notes.aai.2011s.ch7.p logicJarrar.lecture notes.aai.2011s.ch7.p logic
Jarrar.lecture notes.aai.2011s.ch7.p logic
 
Knowledge engg using & in fol
Knowledge engg using & in folKnowledge engg using & in fol
Knowledge engg using & in fol
 
First order logic in knowledge representation
First order logic in knowledge representationFirst order logic in knowledge representation
First order logic in knowledge representation
 
Fol
FolFol
Fol
 
Logic agent
Logic agentLogic agent
Logic agent
 
Logic Notes
Logic NotesLogic Notes
Logic Notes
 
Artificial intelligence- Logic Agents
Artificial intelligence- Logic AgentsArtificial intelligence- Logic Agents
Artificial intelligence- Logic Agents
 
Applying de morgan’s laws
Applying de morgan’s lawsApplying de morgan’s laws
Applying de morgan’s laws
 
Syntax and semantics of propositional logic
Syntax and semantics of propositional logicSyntax and semantics of propositional logic
Syntax and semantics of propositional logic
 
Quantifiers
QuantifiersQuantifiers
Quantifiers
 
Quantifiers
QuantifiersQuantifiers
Quantifiers
 
Predicate Logic
Predicate LogicPredicate Logic
Predicate Logic
 
Quantifiers
QuantifiersQuantifiers
Quantifiers
 
Semantics: Meanings of Language
Semantics: Meanings of LanguageSemantics: Meanings of Language
Semantics: Meanings of Language
 
SEMANTICS
SEMANTICS SEMANTICS
SEMANTICS
 
Semantics
SemanticsSemantics
Semantics
 

Similar a Class first order logic

10-fol.ppt
10-fol.ppt10-fol.ppt
10-fol.pptMDAmin47
 
Theory of first order logic
Theory of first order logicTheory of first order logic
Theory of first order logicDevaddd
 
First order logic.ppt
First order logic.pptFirst order logic.ppt
First order logic.pptvisnuyaathav1
 
10 logic+programming+with+prolog
10 logic+programming+with+prolog10 logic+programming+with+prolog
10 logic+programming+with+prologbaran19901990
 
Predicates and Quantifiers
Predicates and Quantifiers Predicates and Quantifiers
Predicates and Quantifiers Istiak Ahmed
 
Predicates and quantifiers
Predicates and quantifiersPredicates and quantifiers
Predicates and quantifiersIstiak Ahmed
 
Frstorder 9 sldes read
Frstorder 9 sldes readFrstorder 9 sldes read
Frstorder 9 sldes readYasir Khan
 
AI3391 Artificial intelligence session 27 inference and unification.pptx
AI3391 Artificial intelligence session 27 inference and unification.pptxAI3391 Artificial intelligence session 27 inference and unification.pptx
AI3391 Artificial intelligence session 27 inference and unification.pptxAsst.prof M.Gokilavani
 
Basic Knowledge Representation in First Order Logic.ppt
Basic Knowledge Representation in First Order Logic.pptBasic Knowledge Representation in First Order Logic.ppt
Basic Knowledge Representation in First Order Logic.pptAshfaqAhmed693399
 
Resources
ResourcesResources
Resourcesbutest
 
Discrete Structure Lecture #5 & 6.pdf
Discrete Structure Lecture #5 & 6.pdfDiscrete Structure Lecture #5 & 6.pdf
Discrete Structure Lecture #5 & 6.pdfMuhammadUmerIhtisham
 
dfgsdfdsgdfgfdgdrgdfgffdhyrthfgnhgjhgdfs.ppt
dfgsdfdsgdfgfdgdrgdfgffdhyrthfgnhgjhgdfs.pptdfgsdfdsgdfgfdgdrgdfgffdhyrthfgnhgjhgdfs.ppt
dfgsdfdsgdfgfdgdrgdfgffdhyrthfgnhgjhgdfs.pptNobitaNobi489694
 
knowledge representation.pptx
knowledge representation.pptxknowledge representation.pptx
knowledge representation.pptxSwatiHans10
 

Similar a Class first order logic (17)

10-fol.ppt
10-fol.ppt10-fol.ppt
10-fol.ppt
 
Module_5_1.pptx
Module_5_1.pptxModule_5_1.pptx
Module_5_1.pptx
 
Theory of first order logic
Theory of first order logicTheory of first order logic
Theory of first order logic
 
Chapter10
Chapter10Chapter10
Chapter10
 
First order logic.ppt
First order logic.pptFirst order logic.ppt
First order logic.ppt
 
10 logic+programming+with+prolog
10 logic+programming+with+prolog10 logic+programming+with+prolog
10 logic+programming+with+prolog
 
lect14-semantics.ppt
lect14-semantics.pptlect14-semantics.ppt
lect14-semantics.ppt
 
Predicates and Quantifiers
Predicates and Quantifiers Predicates and Quantifiers
Predicates and Quantifiers
 
Predicates and quantifiers
Predicates and quantifiersPredicates and quantifiers
Predicates and quantifiers
 
Frstorder 9 sldes read
Frstorder 9 sldes readFrstorder 9 sldes read
Frstorder 9 sldes read
 
AI3391 Artificial intelligence session 27 inference and unification.pptx
AI3391 Artificial intelligence session 27 inference and unification.pptxAI3391 Artificial intelligence session 27 inference and unification.pptx
AI3391 Artificial intelligence session 27 inference and unification.pptx
 
Basic Knowledge Representation in First Order Logic.ppt
Basic Knowledge Representation in First Order Logic.pptBasic Knowledge Representation in First Order Logic.ppt
Basic Knowledge Representation in First Order Logic.ppt
 
Resources
ResourcesResources
Resources
 
Discrete Structure Lecture #5 & 6.pdf
Discrete Structure Lecture #5 & 6.pdfDiscrete Structure Lecture #5 & 6.pdf
Discrete Structure Lecture #5 & 6.pdf
 
dfgsdfdsgdfgfdgdrgdfgffdhyrthfgnhgjhgdfs.ppt
dfgsdfdsgdfgfdgdrgdfgffdhyrthfgnhgjhgdfs.pptdfgsdfdsgdfgfdgdrgdfgffdhyrthfgnhgjhgdfs.ppt
dfgsdfdsgdfgfdgdrgdfgffdhyrthfgnhgjhgdfs.ppt
 
knowledge representation.pptx
knowledge representation.pptxknowledge representation.pptx
knowledge representation.pptx
 
Thinking with shapes
Thinking with shapesThinking with shapes
Thinking with shapes
 

Último

Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 

Último (20)

Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 

Class first order logic

  • 1. Knowledge Representation using First-Order Logic CS 271: Fall 2007 Instructor: Padhraic Smyth
  • 2. Logistics • Midterm results – Graded, solutions mailed out • Extra-credit projects – Treated as 2 additional homeworks • Lowest 2 scoring homeworks dropped, rest averaged – no- extra-credit project • Single lowest homework score dropped, rest averaged – More information on the Web site (if not now, then soon) • Homework 3 – Should be graded by Thursday • Homework 4 – Up on the Web shortly CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 2
  • 3. Outline • What is First-Order Logic (FOL)? – Syntax and semantics • Using FOL • Wumpus world in FOL • Knowledge engineering in FOL • Required Reading: – All of Chapter 8 CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 3
  • 4. Pros and cons of propositional logic  Propositional logic is declarative - Knowledge and inference are separate  Propositional logic allows partial/disjunctive/negated information – unlike most programming languages and databases  Propositional logic is compositional: – meaning of B1,1 ∧ P1,2 is derived from meaning of B1,1 and of P1,2  Meaning in propositional logic is context-independent – unlike natural language, where meaning depends on context  Propositional logic has limited expressive power – unlike natural language – E.g., cannot say "pits cause breezes in adjacent squares“ • except by writing one sentence for each square CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 4
  • 5. First-Order Logic • 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, … CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 5
  • 6. Logics in General • Ontological Commitment: – What exists in the world — TRUTH – PL : facts hold or do not hold. – FOL : objects with relations between them that hold or do not hold • Epistemological Commitment: – What an agent believes about facts — BELIEF CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 6
  • 7. Syntax of FOL: Basic elements • Constant Symbols: – Stand for objects – e.g., KingJohn, 2, UCI,... • Predicate Symbols – Stand for relations – E.g., Brother(Richard, John), greater_than(3,2)... • Function Symbols – Stand for functions – E.g., Sqrt(3), LeftLegOf(John),... CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 7
  • 8. Syntax of FOL: Basic elements • Constants KingJohn, 2, UCI,... • Predicates Brother, >,... • Functions Sqrt, LeftLegOf,... • Variables x, y, a, b,... • Connectives ¬, ⇒, ∧, ∨, ⇔ • Equality = • Quantifiers ∀, ∃ CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 8
  • 9. Relations • Some relations are properties: they state some fact about a single object: Round(ball), Prime(7). • n-ary relations state facts about two or more objects: Married(John,Mary), LargerThan(3,2). • Some relations are functions: their value is another object: Plus(2,3), Father(Dan). CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 9
  • 10. Models for FOL: Example CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 10
  • 11. Terms • Term = logical expression that refers to an object. • There are 2 kinds of terms: – constant symbols: Table, Computer – function symbols: LeftLeg(Pete), Sqrt(3), Plus(2,3) etc CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 11
  • 12. Atomic Sentences • Atomic sentences state facts using terms and predicate symbols – P(x,y) interpreted as “x is P of y” • Examples: LargerThan(2,3) is false. Brother_of(Mary,Pete) is false. Married(Father(Richard), Mother(John)) could be true or false • Note: Functions do not state facts and form no sentence: – Brother(Pete) refers to John (his brother) and is neither true nor false. • Brother_of(Pete,Brother(Pete)) is True. Binary relation Function CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 12
  • 13. Complex Sentences • We make complex sentences with connectives (just like in propositional logic). property ¬Brother (LeftLeg (Richard ), John ) ∨ (Democrat (Bush )) binary function relation objects connectives CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 13
  • 14. More Examples • Brother(Richard, John) ∧ Brother(John, Richard) • King(Richard) ∨ King(John) • King(John) => ¬ King(Richard) • LessThan(Plus(1,2) ,4) ∧ GreaterThan(1,2) (Semantics are the same as in propositional logic) CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 14
  • 15. Variables • Person(John) is true or false because we give it a single argument ‘John’ • We can be much more flexible if we allow variables which can take on values in a domain. e.g., all persons x, all integers i, etc. – E.g., can state rules like Person(x) => HasHead(x) or Integer(i) => Integer(plus(i,1) CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 15
  • 16. Universal Quantification ∀ ∀ ∀ means “for all” • Allows us to make statements about all objects that have certain properties • Can now state general rules: ∀ x King(x) => Person(x) ∀ x Person(x) => HasHead(x) ∀ i Integer(i) => Integer(plus(i,1)) Note that ∀ x King(x) ∧ Person(x) is not correct! This would imply that all objects x are Kings and are People ∀ x King(x) => Person(x) is the correct way to say this CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 16
  • 17. Existential Quantification ∃ ∀ ∃ x means “there exists an x such that….” (at least one object x) • Allows us to make statements about some object without naming it • Examples: ∃ x King(x) ∃ x Lives_in(John, Castle(x)) ∃i Integer(i) ∧ GreaterThan(i,0) Note that ∧ is the natural connective to use with ∃ (And => is the natural connective to use with ∀ ) CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 17
  • 18. More examples For all real x, x>2 implies x>3. ∀x [(x > 2) ⇒ (x > 3)] x ∈ R (false ) ∃x [(x 2 = −1)] x ∈ R (false ) There exists some real x whose square is minus 1. CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 18
  • 19. CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 19
  • 20. CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 20
  • 21. CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 21
  • 22. CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 22
  • 23. CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 23
  • 24. Combining Quantifiers ∀ x ∃ y Loves(x,y) – For everyone (“all x”) there is someone (“y”) who loves them ∃ y ∀ x Loves(x,y) - there is someone (“y”) who loves everyone Clearer with parentheses: ∃y(∀x Loves(x,y) ) CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 24
  • 25. Connections between Quantifiers • Asserting that all x have property P is the same as asserting that does not exist any x that don’t have the property P ∀ x Likes(x, 271 class)  ¬ ∃ x ¬ Likes(x, 271 class) In effect: - ∀ is a conjunction over the universe of objects - ∃ is a disjunction over the universe of objects Thus, DeMorgan’s rules can be applied CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 25
  • 26. De Morgan’s Law for Quantifiers De Morgan’s Rule Generalized De Morgan’s Rule P ∧ Q ≡ ¬(¬P ∨ ¬Q ) ∀x P ≡ ¬∃x (¬P ) P ∨ Q ≡ ¬(¬P ∧ ¬Q ) ∃x P ≡ ¬∀x (¬P ) ¬(P ∧ Q ) ≡ ¬P ∨ ¬Q ¬∀x P ≡ ∃x (¬P ) ¬(P ∨ Q ) ≡ ¬P ∧ ¬Q ¬∃x P ≡ ∀x (¬P ) Rule is simple: if you bring a negation inside a disjunction or a conjunction, always switch between them (or and, and  or). CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 26
  • 27. Using FOL • We want to TELL things to the KB, e.g. TELL(KB, ∀x , King (x ) ⇒ Person (x ) ) TELL(KB, King(John) ) These sentences are assertions • We also want to ASK things to the KB, ASK(KB, ∃x , Person (x ) ) these are queries or goals The KB should return the list of x’s for which Person(x) is true: {x/John,x/Richard,...} CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 27
  • 28. FOL Version of Wumpus World • Typical percept sentence: Percept([Stench,Breeze,Glitter,None,None],5) • Actions: Turn(Right), Turn(Left), Forward, Shoot, Grab, Release, Climb • To determine best action, construct query: ∀ a BestAction(a,5) • ASK solves this and returns {a/Grab} – And TELL about the action. CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 28
  • 29. Knowledge Base for Wumpus World • Perception ∀b,g,t Percept([Breeze,b,g],t) ⇒ Breeze(t) ∀s,b,t Percept([s,b,Glitter],t) ⇒ Glitter(t) • Reflex ∀t Glitter(t) ⇒ BestAction(Grab,t) • Reflex with internal state ∀t Glitter(t) ∧¬Holding(Gold,t) ⇒ BestAction(Grab,t) Holding(Gold,t) can not be observed: keep track of change. CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 29
  • 30. Deducing hidden properties Environment definition: ∀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 locations: ∀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) ⇔ ∃ r Adjacent(r,s) ∧ Pit(r) – Causal rule---infer effect from cause (model based reasoning) ∀r Pit(r) ⇒ [∀s Adjacent(r,s) ⇒ Breezy(s)] CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 30
  • 31. Set Theory in First-Order Logic Can we define set theory using FOL? - individual sets, union, intersection, etc Answer is yes. Basics: - empty set = constant = { } - unary predicate Set( ), true for sets - binary predicates: x∈ s (true if x is a member of the set x) s1 ⊆ s2 (true if s1 is a subset of s2) - binary functions: intersection s1 ∩ s2, union s1 ∪ s2 , adjoining {x|s} CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 31
  • 32. A Possible Set of FOL Axioms for Set Theory The only sets are the empty set and sets made by adjoining an element to a set ∀s Set(s) ⇔ (s = {} ) ∨ (∃x,s2 Set(s2) ∧ s = {x|s2}) The empty set has no elements adjoined to it ¬∃x,s {x|s} = {} Adjoining an element already in the set has no effect ∀x,s x ∈ s ⇔ s = {x|s} The only elements of a set are those that were adjoined into it. Expressed recursively: ∀x,s x ∈ s ⇔ [ ∃y,s2 (s = {y|s2} ∧ (x = y ∨ x ∈ s2))] CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 32
  • 33. A Possible Set of FOL Axioms for Set Theory A set is a subset of another set iff all the first set’s members are members of the 2nd set ∀s1,s2 s1 ⊆ s2 ⇔ (∀x x ∈ s1 ⇒ x ∈ s2) Two sets are equal iff each is a subset of the other ∀s1,s2 (s1 = s2) ⇔ (s1 ⊆ s2 ∧ s2 ⊆ s1) An object is in the intersection of 2 sets only if a member of both ∀x,s1,s2 x ∈ (s1 ∩ s2) ⇔ (x ∈ s1 ∧ x ∈ s2) An object is in the union of 2 sets only if a member of either ∀x,s1,s2 x ∈ (s1 ∪ s2) ⇔ (x ∈ s1 ∨ x ∈ s2) CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 33
  • 34. Knowledge engineering in FOL 1. Identify the task 3. Assemble the relevant knowledge 5. Decide on a vocabulary of predicates, functions, and constants 7. Encode general knowledge about the domain 9. Encode a description of the specific problem instance 11. Pose queries to the inference procedure and get answers 13. Debug the knowledge base • CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 34
  • 35. The electronic circuits domain One-bit full adder Possible queries: - does the circuit function properly? - what gates are connected to the first input terminal? - what would happen if one of the gates is broken? and so on CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 35
  • 36. The electronic circuits domain 1. Identify the task – Does the circuit actually add properly? 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(X1) = XOR (function) Type(X1, XOR) (binary predicate) XOR(X1) (unary predicate) – – – • CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 36
  • 37. The electronic circuits domain 1. Encode general knowledge of the domain ∀t1,t2 Connected(t1, t2) ⇒ Signal(t1) = Signal(t2) ∀t Signal(t) = 1 ∨ Signal(t) = 0 – 1≠0 ∀t1,t2 Connected(t1, t2) ⇒ Connected(t2, t1) ∀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)) – CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 37
  • 38. The electronic circuits domain 1. Encode the specific problem instance Type(X1) = XOR Type(X2) = XOR Type(A1) = AND Type(A2) = AND Type(O1) = OR Connected(Out(1,X1),In(1,X2)) Connected(In(1,C1),In(1,X1)) Connected(Out(1,X1),In(2,A2)) Connected(In(1,C1),In(1,A1)) Connected(Out(1,A2),In(1,O1)) Connected(In(2,C1),In(2,X1)) Connected(Out(1,A1),In(2,O1)) Connected(In(2,C1),In(2,A1)) Connected(Out(1,X2),Out(1,C1)) Connected(In(3,C1),In(2,X2)) Connected(Out(1,O1),Out(2,C1)) Connected(In(3,C1),In(1,A2)) • CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 38
  • 39. The electronic circuits domain 1. Pose queries to the inference procedure What are the possible sets of values of all the terminals for the adder circuit? ∃i1,i2,i3,o1,o2 Signal(In(1,C_1)) = i1 ∧ Signal(In(2,C1)) = i2 ∧ Signal(In(3,C1)) = i3 ∧ Signal(Out(1,C1)) = o1 ∧ Signal(Out(2,C1)) = o2 • Debug the knowledge base May have omitted assertions like 1 ≠ 0 – – • CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 39
  • 40. Summary • First-order logic: – Much more expressive than propositional logic – Allows objects and relations as semantic primitives – Universal and existential quantifiers – syntax: constants, functions, predicates, equality, quantifiers • Knowledge engineering using FOL – Capturing domain knowledge in logical form • Inference and reasoning in FOL – Next lecture • Required Reading: – All of Chapter 8 – CS 271, Fall 2007: Professor Padhraic Smyth Topic 8: First-Order Logic 40