6/26/2015 let remember from the previous lesson what is knowledge representation? logic, syntax,...

17
03/21/22 Let remember from the previous lesson what is Knowledge representation? Logic, Syntax , Semantics and kinds of knowledge representation . Aim of today’s session We will discus about Propositional Logic which is very simple logic. Despite its limited expressiveness, propositional logic serves to illustrate many of the concepts of logic just as well as first-order logic. We will describe its syntax , semantics, and associated inference procedures. After learn this topics you can understand

Post on 21-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 6/26/2015 Let remember from the previous lesson what is Knowledge representation? Logic, Syntax, Semantics and kinds of knowledge representation. Aim of

04/18/23

Let remember from the previous lesson what is Knowledge representation? Logic, Syntax , Semantics

and kinds of knowledge representation .

Aim of today’s session

We will discus about Propositional Logic which is very simple logic. Despite its limited expressiveness, propositional logic serves to illustrate many of the concepts of logic just as well as first-order logic. We will describe its syntax , semantics, and associated inference procedures. After learn this topics you can understand how convert a general languages in to logic

Page 2: 6/26/2015 Let remember from the previous lesson what is Knowledge representation? Logic, Syntax, Semantics and kinds of knowledge representation. Aim of

04/18/23

In propositional logic, symbol represent whole propositions (facts). A

proposition is a statement that is either true or false but not both.Example:

All the following statements are propositions:

1. Toronto is the capital of Canada.

2. 1+1=2

consider the following sentences:

1. What time it is?

2. Read this carefully.

3. X+1=Z

sentences 1 and 2 are not propositions because they are not statements.sentences 3 is not propositions because it is neither true nor false,since the variables used in this sentence have not been assigned values.

Propositional logic:

Page 3: 6/26/2015 Let remember from the previous lesson what is Knowledge representation? Logic, Syntax, Semantics and kinds of knowledge representation. Aim of

04/18/23

Syntax of propositional logic:'The syntax of propositional logic is simple. The symbols of propositional logic are the logical constants True and False, proposition symbols such as:- P and Q, the logical connectives n, V, q. ~> and ~, and parentheses, ( ). All sentences are made by putting these symbols together using the following rules:• The logical constants True and False are sentences by themselves. • A propositional symbol such as P or Q is a sentence by itself.• Wrapping parentheses around a sentence yields a sentence, for example, (P n Q).• A sentence can be formed by combining simpler sentences with one of the five logical connectives:

Page 4: 6/26/2015 Let remember from the previous lesson what is Knowledge representation? Logic, Syntax, Semantics and kinds of knowledge representation. Aim of

04/18/23

n (and). A sentence whose main connective is n, such as P n (Q `C R), is called a conjunction (logic); its parts are the conjuncts. (The n looks like an `A" for "And.“)

V (or). A sentence using V, such as A V (P n Q), is a disjunction of the disjuncts A and (P n Q). (Historically, the V comes from the Latin "vel," which means "or:' For most people, it is easier to remember as an upside-down and.)

~ (implies). A sentence such as (P n Q) ~ R is called an implication (or conditional). Its premise or antecedent is P n Q, and its conclusion or consequent is R. Impli cations are also known as rules or if-then statements. The implication symbol is sometimes written in other books as ~ or -~.

q (equivalent). The sentence (P n Q) ~ (Q n P) is an equivalence (also called a biconditional).

(not). A sentence such as --~P is called the negation of P. All the other connectives combine two sentences into one; ~ is the only connective that operates on a single sentence.

Page 5: 6/26/2015 Let remember from the previous lesson what is Knowledge representation? Logic, Syntax, Semantics and kinds of knowledge representation. Aim of

04/18/23

Figure 9.1:- gives a formal grammar of propositional logic; The grammar introduces atomic sentences, which in propositional logic consist of a single symbol (e:g., P), and complex sentences, which contain connectives or parentheses (e.g., P ~ Q). The term literal is also used, meaning either an atomic sentence or a negated atomic sentence.

Page 6: 6/26/2015 Let remember from the previous lesson what is Knowledge representation? Logic, Syntax, Semantics and kinds of knowledge representation. Aim of

04/18/23

Strictly speaking, the grammar is ambiguous-a sentence such as P ~ Q V R could be parsed as either (P n Q) V R or as P n (Q V R). This is similar to the ambiguity of arithmetic expressions such as P + Q x R, and the way to resolve the ambiguity is also similar: we pick an' order of precedence for the operators, but use parentheses whenever there might be confusion. The order of precedence in propositional logic is (from highest to lowest): ~, ~, V, ~, and q. Hence, the sentence~PVQ~R ~ Sis equivalent to the sentence

Page 7: 6/26/2015 Let remember from the previous lesson what is Knowledge representation? Logic, Syntax, Semantics and kinds of knowledge representation. Aim of

04/18/23

The semantics of propositional logic is also quite straightforward. We define it by specifying the interpretation of the proposition symbols and constants, and specifying the meanings of the logical connectives.A proposition symbol can mean whatever you want. That is, its interpretation can be any arbitrary fact. The interpretation of P might be the fact that Paris is the capital of France or that the wumpus is dead. A sentence containing just a proposition symbol is satisfiable but not valid- it is true just when the fact that it refers to is the case.With logical constants, you have no choice; the sentence True always has as its interpretation the way the world actually is-the true fact. The sentence False always has as its interpretatiational the way the world is not.A complex sentence has a meaning derived from the meaning of its parts. Each connective can be thought of as a function. Just as addition is a function that takes two numbers as input and returns a number, so and is a function that takes two truth values as input and returns a truth value. We know that one way to define a function is to make a table that gives the output value for every possible input value. For most functions (such as addition), this is impractical because of the size of the table, but there are only two possible truth values, so a logical function with two arguments needs a table with only four entries. Such a table is called a truth table.

Page 8: 6/26/2015 Let remember from the previous lesson what is Knowledge representation? Logic, Syntax, Semantics and kinds of knowledge representation. Aim of

04/18/23

We give truth tables for the logical connectives in Figure 9:2:- To use the table to determine, for example. the value of True V False, first look on the left for the row where P is true and Q is false (the third row). Then look in that row under the P V Q column to see the result: True.

• Truth tables for the five logical connectives:

Page 9: 6/26/2015 Let remember from the previous lesson what is Knowledge representation? Logic, Syntax, Semantics and kinds of knowledge representation. Aim of

04/18/23

• Semantics of propositional logic:

The semantics of propositional logic define by specifying the interpretation of the proposition symbols and constants and specifying the meanings of the logical connectives.

• A BNF (Backus-Naur Form) grammar of sentences in propositional logic:

Truth tables define the semantics of sentences such as True n True. Complex sentences such as (P V Q) n ~S are defined by a process of decomposition: first, determine the meaning d (P n Q) and of ~S, and then combine them using the definition of the n function. This is exactly analogous to the way a complex arithmetic expression such as (p x q) + -s is evaluated.The truth tables for "and," "or," and "not" are in close accord with our intuitions about the English words. The main point of possible confusion is that P V Q is true when either or both P and Q are true. There is a different connective called "exclusive or" ("xor" for short) that gives false when both disjuncts are true. There is no consensus on the symbol for exclusive or; two choices are V and ®.

Page 10: 6/26/2015 Let remember from the previous lesson what is Knowledge representation? Logic, Syntax, Semantics and kinds of knowledge representation. Aim of

04/18/23

• Validity and inference:-Truth table can be used not only to define the connectives, but also to test for valid sentences.-Given a sentence, we make a truth table with one row for each of the possible combinations of truth values for the proposition symbols in the sentence.For each row, we can calculate the truth value of the entire sentence.If the sentence is true in every row, then the sentence is valid.

• Truth table showing valid of a complex sentence “((PH) H)P

Page 11: 6/26/2015 Let remember from the previous lesson what is Knowledge representation? Logic, Syntax, Semantics and kinds of knowledge representation. Aim of

04/18/23

Figure:-Sentences often refer to a world to which the agent has no independent access.

Page 12: 6/26/2015 Let remember from the previous lesson what is Knowledge representation? Logic, Syntax, Semantics and kinds of knowledge representation. Aim of

04/18/23

• Models:

Page 13: 6/26/2015 Let remember from the previous lesson what is Knowledge representation? Logic, Syntax, Semantics and kinds of knowledge representation. Aim of

04/18/23

Figure:-9.3:-Seven inference rules for

propositional logic. The unit resolution rule is a

special case of the resolution rule, which in tern

is a special case of the full resolution rule

for first order logic discussed in next session

Page 14: 6/26/2015 Let remember from the previous lesson what is Knowledge representation? Logic, Syntax, Semantics and kinds of knowledge representation. Aim of

04/18/23

AN AGENT FOR THE WUMPUS WORLD

On each turn, the agent's percepts are converted into sentences and entered into the knowledge base, along with some valid sentences that are entailed by the percept sentences. Let us assume that the symbol

Page 15: 6/26/2015 Let remember from the previous lesson what is Knowledge representation? Logic, Syntax, Semantics and kinds of knowledge representation. Aim of

04/18/23

The agent needs to know this for each square in the world, but here we just show sentences for three relevant squares, labeling each sentence with a rule number:

Another useful fact is that if there is a stench in [1,2], then there must be a wumpus in [1,2] or in one or more of the neighboring squares. This fact can be represented by the sentence

Page 16: 6/26/2015 Let remember from the previous lesson what is Knowledge representation? Logic, Syntax, Semantics and kinds of knowledge representation. Aim of

04/18/23

Given these sentences, we will now show how an agent can mechanically conclude W~,s. All the agent has to do is construct the truth table for KB ~ W,,3 to show that this sentence is valid. There are 12 propositional symbols,° so

the truth table will have 2'2 = 4096 rows, and every row in which the sentence KB is true also has Wt,3 true. Rather than show a114096 rows, we use inference rules instead, but it is important to recognize that we could have done it in one (long) step just by following the truth-table algorithm.

First, we will show that the wumpus is not in one of the other squares, and then conclude by elimination that it must be in [1,3]:

1. Applying Modus Ponens with ~5~,~ and the sentence labeled R~, we obtain

2. Applying And-Elimination to this, we obtain the three separate sentences

Page 17: 6/26/2015 Let remember from the previous lesson what is Knowledge representation? Logic, Syntax, Semantics and kinds of knowledge representation. Aim of

04/18/23