first-order predicate logic(fopl)

26
First-Order Predicate Logic(FOPL) IT8601 First-Order Predicate Logic 1 S. Prabhavathi AP/IT

Upload: others

Post on 23-Nov-2021

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: First-Order Predicate Logic(FOPL)

First-Order Predicate Logic(FOPL)

IT8601 First-Order Predicate Logic 1 S. Prabhavathi AP/IT

Page 2: First-Order Predicate Logic(FOPL)

The limitation of propositional logic

•  Propositional logic has nice properties: – Propositional logic is declarative: pieces of syntax correspond to facts, which are either true or false. – 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)

•  Limitation: – Propositional logic has very limited expressive power,

unlike natural language. E.g., we cannot express o  "Some humans are intelligent", or o  "Sachin likes cricket.” in PL

IT8601 First-Order Predicate Logic 2

Page 3: First-Order Predicate Logic(FOPL)

First-order logic

•  First-order logic is also known as Predicate logic or First-order predicate logic.

•  First-order logic is another way of knowledge representation in artificial intelligence. It is an extension to propositional logic.

•  Whereas propositional logic assumes that a world contains facts, first-order logic (like natural language) assumes the world contains

– Objects: people, houses, numbers, theories, colors, cricket games, wars, centuries . . . – Relations: red, round, bogus, prime, multistoried . . ., brother of, bigger than, inside, part of, has color, occurred after, owns, comes between, . . . – Functions: father of, best friend, third inning of, one more than, end of . . .

IT8601 First-Order Predicate Logic 3

Page 4: First-Order Predicate Logic(FOPL)

Basic Elements of First-order logic Syntax

Constant 1, 2, A, John, Mumbai, cat,.... Variables x, y, z, a, b,.... Predicates Brother, Father, >,.... Function sqrt, LeftLegOf, .... Connectives ∧, ∨, ¬, ⇒, ⇔ Equality == Quantifier ∀, ∃

IT8601 First-Order Predicate Logic 4

Page 5: First-Order Predicate Logic(FOPL)

IT8601 First-Order Predicate Logic 5

Page 6: First-Order Predicate Logic(FOPL)

Atomic sentences: •  It is a basic sentences of first-order logic formed from a

predicate symbol followed by a parenthesis with a sequence of terms.

•  Represent atomic sentences as Predicate (term1, term2, ......, term n) Example: Ravi and Ajay are brothers: => Brothers(Ravi, Ajay). Chinnu is a cat: => cat (Chinnu). Complex Sentences: •  Complex sentences are made by combining atomic sentences

using connectives. First-order logic statements can be divided into two parts:

IT8601 First-Order Predicate Logic 6

Page 7: First-Order Predicate Logic(FOPL)

Quantifiers in First-order logic

•  A quantifier is a language element which generates

quantification, and quantification specifies the quantity of specimen in the universe of discourse.

•  These are the symbols that permit to determine or identify the range and scope of the variable in the logical expression.

•  There are two types of quantifier: –  Universal Quantifier, (for all, everyone, everything) –  Existential quantifier, (for some, at least one).

IT8601 First-Order Predicate Logic 7

Page 8: First-Order Predicate Logic(FOPL)

Universal Quantifier(∀x ) Universal quantifier is a symbol of logical representation, which specifies that the statement within its range is true for everything or every instance of a particular thing. •  Represented by a symbol ∀ •  If x is a variable, then ∀x is read as:

•  For all x •  For each x •  For every x.

IT8601 8

Note: In universal quantifier we use implication "→".

Example

Page 9: First-Order Predicate Logic(FOPL)

Existential Quantifier(∃x ) It express that the statement within its scope is true for at least one instance of something. •  Represented by a symbol ∃ •  If x is a variable, then ∃(x) is read as:

•  There exists a 'x.' •  For some 'x.' •  For at least one 'x.'

IT8601 9

Note: In Existential quantifier we always use AND or Conjunction symbol (∧).

Example

Page 10: First-Order Predicate Logic(FOPL)

Do it

1. All birds fly. 2. Every man respects his parent. 3. Some boys play cricket. 4. Not all students like both Mathematics and Science.

IT8601 First-Order Predicate Logic 10

Page 11: First-Order Predicate Logic(FOPL)

Answers 1. All birds fly. In this question the predicate is "fly(bird)." And since there are all birds who fly so it will be represented as follows. ∀x bird(x) →fly(x). 2. Every man respects his parent. In this question, the predicate is "respect(x, y)," where x=man, and y= parent. Since there is every man so will use ∀, and it will be represented as follows: ∀x man(x) → respects (x, parent). 3. Some boys play cricket. In this question, the predicate is "play(x, y)," where x= boys, and y= game. Since there are some boys so we will use ∃, and it will be represented as: ∃x boys(x) → play(x, cricket). 4. Not all students like both Mathematics and Science. In this question, the predicate is "like(x, y)," where x= student, and y= subject. Since there are not all students, so we will use ∀ with negation, so following representation for this: ¬∀ (x) [ student(x) → like(x, Mathematics) ∧ like(x, Science)]. IT8601 First-Order Predicate Logic 11

Page 12: First-Order Predicate Logic(FOPL)

Exercise

Free and Bound Variables

IT8601 First-Order Predicate Logic 12

Page 13: First-Order Predicate Logic(FOPL)

IT8601 De Morgan rules for quantified and unquantified sentences

13

There is no one who does not like icecream

Page 14: First-Order Predicate Logic(FOPL)

IT8601 14

Objects: Richard, John, left legs of Richard and John, crown Binary Relations: brother, onhead Unary Relation(property): person, king Function: left leg

Page 15: First-Order Predicate Logic(FOPL)

Knowledge Engineering in First-order logic The process of constructing a knowledge-base in first-order

logic is called as knowledge- engineering. Knowledge engineer •  Investigates a particular domain, learns important

concept of that domain, and generates a formal representation of the objects and relation in the domain.

IT8601 First-Order Predicate Logic 15

Page 16: First-Order Predicate Logic(FOPL)

The knowledge-engineering process

Example: Digital circuit (One-bit full adder)

IT8601 First-Order Predicate Logic 16

Page 17: First-Order Predicate Logic(FOPL)

The knowledge-engineering process

1. Identify the task: The first step of the process is to identify the task, and for the digital circuit, there are various reasoning tasks. At the first level or highest level, we will examine the functionality of the circuit: o  Does the circuit add properly? o  What will be the output of gate A2, if all the inputs are

high? At the second level, we will examine the circuit structure details such as: o  Which gate is connected to the first input terminal? o  Does the circuit have feedback loops?

IT8601 First-Order Predicate Logic 17

Page 18: First-Order Predicate Logic(FOPL)

The knowledge-engineering process

2. Assemble the relevant knowledge: •  In the second step, we will assemble the relevant

knowledge which is required for digital circuits. So for digital circuits, we have the following required knowledge:

•  Logic circuits are made up of wires and gates. •  Signal flows through wires to the input terminal of the

gate, and each gate produces the corresponding output which flows further.

•  In this logic circuit, there are four types of gates used: AND, OR, XOR, and NOT.

•  All these gates have one output terminal and two input terminals (except NOT gate, it has one input terminal).

IT8601 First-Order Predicate Logic 18

Page 19: First-Order Predicate Logic(FOPL)

The knowledge-engineering process 3. Decide on vocabulary: Translate the important domain-level concepts into logic-level names. •  Select functions, predicate, and constants to represent the circuits,

terminals, signals, and gates. •  Distinguish the gates from each other by a constant, such

as, Gate(X1), Gate(X2). •  The functionality of each gate is determined by its type, which is

taken as constants such as AND, OR, XOR, or NOT. •  Circuits will be identified by a predicate: Circuit (C1). •  For the terminal, use predicate: Terminal(x). •  For gate input, use the function In(1, X1) for denoting the first input

terminal of the gate •  For output terminal,use Out (1, X1). •  The function Arity(c, i, j) is used to denote that circuit c has i input,

j output. •  The connectivity between gates can be represented by

predicate Connect(Out(1, X1), In(1, X1)). •  Unary predicate On (t), which is true if the signal at a terminal is on.

IT8601 First-Order Predicate Logic 19

Page 20: First-Order Predicate Logic(FOPL)

•  Ontology: The word ontology means a particular theory

of the nature of being or existence. The ontology determines what kinds of things exist, but does not determine their specific properties and interrelationships.

•  The result is a vocabulary that is known as the ontology

of the domain.

IT8601 First-Order Predicate Logic 20

Page 21: First-Order Predicate Logic(FOPL)

The knowledge-engineering process

4. Encode general knowledge about the domain: •  The knowledge engineer writes down the axioms for all

the vocabulary terms. •  This step reveals misconceptions or gaps in the

vocabulary that must be fixed by returning to step 3 and iterating through the process. –  All gates are logic circuits: ∀ g Gate(g) → Circuit (g). –  If two terminals are connected, then they have the same signal:

∀t1, t2 Terminal(t1)∧Terminal(t2)∧Connected(t1,t2) ⇒ Signal(t1)=Signal(t2)

–  Connected is a commutative: ∀ t1, t2 Connect(t1, t2) → Connect (t2, t1).

IT8601 First-Order Predicate Logic 21

Page 22: First-Order Predicate Logic(FOPL)

The knowledge-engineering process

5. Encode a description of the problem instance: Writing simple atomic sentences about instances of concepts that are already part of the ontology. For XOR gate: Type(x1)= XOR, Type(X2) = XOR For AND gate: Type(A1) = AND, Type(A2)= AND For OR gate: Type (O1) = OR. Connections between gates: Connected (Out (1, X1 ), In (1, X2 )) Connected (Out (1, X1 ), In (2, A2 )) Connected (Out (1, A2 ), In (1, O1 )) Connected (Out (1, A1 ), In (2, O1 )) etc

IT8601 First-Order Predicate Logic 22

Page 23: First-Order Predicate Logic(FOPL)

The knowledge-engineering process

6. Pose queries to the inference procedure and get answers: •  Find all the possible set of values of all the terminal for the

adder circuit. 7. Debug the knowledge base: •  The last step of the complete process, debug the issues

of knowledge base to see what kinds of erroneous behaviors emerge.

•  In the knowledge base, we may have omitted assertions like 1 ≠ 0, then system will be unable to prove any outputs for the circuit

•  Pinpoint the problem by asking for the outputs of each gate.

IT8601 First-Order Predicate Logic 23

Page 24: First-Order Predicate Logic(FOPL)

GATE CS 2013 1. What is the logical translation of the following statement? "None of my friends are perfect."

(A) A (B) B (C) C (D) D

GATE CS 2012 2. What is the correct translation of the following statement into mathematical logic? “Some real numbers are rational” (A) A (B) B (C) C (D) D

IT8601 First-Order Predicate Logic 24

Page 25: First-Order Predicate Logic(FOPL)

GATE CS 2009 3. Which of the above two are equivalent? (A) I and III (B) I and IV (C) II and III (D) II and IV

IT8601 First-Order Predicate Logic 25

Page 26: First-Order Predicate Logic(FOPL)

IT8601 First-Order Predicate Logic 26