Docsity

Introduction to Propositional Logic in CS 1571: Knowledge Representation and Reasoning - P, Assignments of Computer Science

Partial preview of the text

Download Introduction to Propositional Logic in CS 1571: Knowledge Representation and Reasoning - P and more Assignments Computer Science in PDF only on Docsity!

CS 1571 Intro to AI M. Hauskrecht

CS 1571 Introduction to AI

Lecture 13

Milos Hauskrecht [email protected] 5329 Sennott Square

Propositional logic

Announcements

  • Homework assignment 5 is out

Midterm exam: Wednesday, October 25, 2006

Course web page: http://www.cs.pitt.edu/~milos/courses/cs1571/

CS 1571 Intro to AI M. Hauskrecht

Knowledge representation

Knowledge-based agent

  • Knowledge base (KB):
    • A set of sentences that describe facts about the world in some formal (representational) language
    • Domain specific
  • Inference engine:
    • A set of procedures that use the representational language to infer new facts from known ones or answer a variety of KB queries. Inferences typically require search.
    • Domain independent

Knowledge base Inference engine

CS 1571 Intro to AI M. Hauskrecht

Logic

  • Logic:
    • defines a formal language for logical reasoning
  • A tool that helps us to understand how to construct a valid argument
  • Logic Defines:
    • the meaning of statements
    • the rules of logical inference

Logic

A formal language for expressing knowledge and ways of reasoning. Logic is defined by :

  • A set of sentences
    • A sentence is constructed from a set of primitives according to syntax rules.
  • A set of interpretations
    • An interpretation gives a semantic to primitives. It associates primitives with values.
  • The valuation (meaning) function V
    • Assigns a value (typically the truth value) to a given sentence under some interpretation V : sentence ×interpretation →{ True , False }

CS 1571 Intro to AI M. Hauskrecht

Propositional logic

  • The simplest logic
  • Definition:
    • A proposition is a statement that is either true or false.
  • Examples:
    • Pitt is located in the Oakland section of Pittsburgh.
      • (T)

Propositional logic

  • The simplest logic
  • Definition:
    • A proposition is a statement that is either true or false.
  • Examples:
    • Pitt is located in the Oakland section of Pittsburgh.
      • (T)
    • 5 + 2 = 8. -?

CS 1571 Intro to AI M. Hauskrecht

Propositional logic

  • Examples (cont.):
    • How are you? -?

Propositional logic

  • Examples (cont.):
    • How are you?
      • a question is not a proposition
    • x + 5 = 3 -?

CS 1571 Intro to AI M. Hauskrecht

Propositional logic

  • Examples (cont.):
    • How are you?
      • a question is not a proposition
    • x + 5 = 3
      • since x is not specified, neither true nor false
    • 2 is a prime number. -?

Propositional logic

  • Examples (cont.):
    • How are you?
      • a question is not a proposition
    • x + 5 = 3
      • since x is not specified, neither true nor false
    • 2 is a prime number.
      • (T)
    • She is very talented. -?

CS 1571 Intro to AI M. Hauskrecht

Propositional logic. Syntax

  • Formally propositional logic P:
    • Is defined by Syntax+interpretation+semantics of P Syntax:
  • Symbols (alphabet ) in P:
    • Constants : True, False
    • Propositional symbols Examples: - P - Pitt is located in the Oakland section of Pittsburgh., - It rains outside, etc.
    • A set of connectives : ¬ ,∧,∨,⇒, ⇔

Propositional logic. Syntax

Sentences in the propositional logic:

  • Atomic sentences:
    • Constructed from constants and propositional symbols
    • True, False are (atomic) sentences
    • or Light in the room is on, It rains outside are (atomic) sentences
  • Composite sentences:
    • Constructed from valid sentences via connectives
    • If are sentences then

or are sentences

P , Q

A , B

¬ A ( A ∧ B ) ( A ∨ B ) ( A ⇒ B ) ( A ⇔ B )

( A ∨ B )∧( A ∨¬ B )

CS 1571 Intro to AI M. Hauskrecht

Propositional logic. Semantics.

The semantic gives the meaning to sentences.

the semantics in the propositional logic is defined by:

1. Interpretation of propositional symbols and constants - Semantics of atomic sentences 2. Through the meaning of connectives - Meaning (semantics) of composite sentences

Semantic: propositional symbols

A propositional symbol

  • a statement about the world that is either true or false Examples: - Pitt is located in the Oakland section of Pittsburgh - It rains outside - Light in the room is on
  • An interpretation maps symbols to one of the two values: True (T), or False (F) , depending on whether the symbol is satisfied in the world I : Light in the room is on -> True, It rains outside -> False I’ : Light in the room is on -> False, It rains outside -> False

CS 1571 Intro to AI M. Hauskrecht

Semantics: composite sentences.

  • The meaning (truth value) of complex propositional sentences. - Determined using the standard rules of logic:

P Q ¬ P P ∧ Q P ∨ Q P ⇒ Q P ⇔ Q

True True True True True True True False

False False False (^) False False False False False False False

False False

True True (^) True True True True

True True

Translation

Assume the following sentences:

  • It is not sunny this afternoon and it is colder than yesterday.
  • We will go swimming only if it is sunny.
  • If we do not go swimming then we will take a canoe trip.
  • If we take a canoe trip, then we will be home by sunset. Denote:
  • p = It is sunny this afternoon
  • q = it is colder than yesterday
  • r = We will go swimming
  • s= we will take a canoe trip
  • t= We will be home by sunset

CS 1571 Intro to AI M. Hauskrecht

Translation

Assume the following sentences:

  • It is not sunny this afternoon and it is colder than yesterday.
  • We will go swimming only if it is sunny.
  • If we do not go swimming then we will take a canoe trip.
  • If we take a canoe trip, then we will be home by sunset. Denote:
  • p = It is sunny this afternoon
  • q = it is colder than yesterday
  • r = We will go swimming
  • s= we will take a canoe trip
  • t= We will be home by sunset

¬ p ∧ q

Translation

Assume the following sentences:

  • It is not sunny this afternoon and it is colder than yesterday.
  • We will go swimming only if it is sunny.
  • If we do not go swimming then we will take a canoe trip.
  • If we take a canoe trip, then we will be home by sunset. Denote:
  • p = It is sunny this afternoon
  • q = it is colder than yesterday
  • r = We will go swimming
  • s= we will take a canoe trip
  • t= We will be home by sunset

¬ p ∧ q r → p

CS 1571 Intro to AI M. Hauskrecht

Contradiction and Tautology

Some composite sentences may always (under any interpretation) evaluate to a single truth value:

  • Contradiction (always False )
  • Tautology ( always True )

P ∧¬ P

¬( P ∧ Q )⇔ (¬ P ∨¬ Q )

¬( P ∨ Q )⇔ (¬ P ∧¬ Q )

DeMorgan’s Laws

P ∨¬ P

Model, validity and satisfiability

  • A model (in logic): An interpretation is a model for a set of sentences if it assigns true to each sentence in the set.
  • A sentence is satisfiable if it has a model;
    • There is at least one interpretation under which the sentence can evaluate to True.
  • A sentence is valid if it is True in all interpretations
    • i.e., if its negation is not satisfiable (leads to contradiction)

P Q (^) P ∨ Q ( P ∨ Q )∧¬ Q True True True True True False True False False False False

True True (^) True True

True

(( P ∨ Q )∧¬ Q )⇒ P

True False

False

False

CS 1571 Intro to AI M. Hauskrecht

Model, validity and satisfiability

  • A model (in logic): An interpretation is a model for a set of sentences if it assigns true to each sentence in the set.
  • A sentence is satisfiable if it has a model;
    • There is at least one interpretation under which the sentence can evaluate to True.
  • A sentence is valid if it is True in all interpretations
    • i.e., if its negation is not satisfiable (leads to contradiction)

P Q (^) P ∨ Q ( P ∨ Q )∧¬ Q True True True True True False True False False False False

True True (^) True True

True

(( P ∨ Q )∧¬ Q )⇒ P

True False

False

False

Model, validity and satisfiability

  • A model (in logic): An interpretation is a model for a set of sentences if it assigns true to each sentence in the set.
  • A sentence is satisfiable if it has a model;
    • There is at least one interpretation under which the sentence can evaluate to True.
  • A sentence is valid if it is True in all interpretations
    • i.e., if its negation is not satisfiable (leads to contradiction) Satisfiable sentence P Q (^) P ∨ Q ( P ∨ Q )∧¬ Q True True True True True False True False False False False

True True (^) True True

True

(( P ∨ Q )∧¬ Q )⇒ P

True False

False

False

CS 1571 Intro to AI M. Hauskrecht

Sound and complete inference.

Inference is a process by which conclusions are reached.

  • We want to implement the inference process on a computer !!

Assume an inference procedure i that

  • derives a sentence from the KB :

Properties of the inference procedure in terms of entailment

  • Soundness: An inference procedure is sound
  • Completeness: An inference procedure is complete

α KB i^ α

If KB i^ αthen it is true that KB |=^ α

If KB |= α then it is true that KB i^ α

Logical inference problem

Logical inference problem :

  • Given:
    • a knowledge base KB (a set of sentences) and
    • a sentence (called a theorem) ,
  • Does a KB semantically entail? In other words: In all interpretations in which sentences in the KB are true, is also true?

Question: Is there a procedure (program) that can decide this problem in a finite number of steps? Answer: Yes. Logical inference problem for the propositional logic is decidable.

KB |= α?

α α

α

Solving logical inference problem

In the following: How to design the procedure that answers:

Three approaches:

  • Truth-table approach
  • Inference rules
  • Conversion to the inverse SAT problem
    • Resolution-refutation

KB |= α?