Вы находитесь на странице: 1из 4

.

46

i.
PART 2 Knowledge Representation

LISP and Other AI Programming

Languages

Chap. 3

'" ,3.15"Write,'a function called sum-squares which uses mapcar to find the sum of the squares of a list of integers. The function takes a single list as its argument. Write a lambda function which mapcar uses to find the square of the integers in the list. For example,

;;:Y
3.16 Write a PROLOG

(sum-squares program

(2 3 1 4)) should return 30.

'-tr! /.
that answers questions about family members and relationships. Include predicates and rules which define sister, 9rother, father, mother, grandchild, grandfather, and uncle. The program should be able to answer queries such as the following: ?- father(X, bob). ?- grandson(X, V). ?- uncle(bill, sue). ?- mother(mary, X).

4
Formalized Symbolic Logics

3.11 Trace the search sequence

PROLOG

follows in satisfying the following

goal:

?- member(c,[a,b,c,dJ). 3.18 Write a function called match that takes two arguments, a pattern and a clause. 'If the

first argument, the pattern, is a variable identified by a question mark followed by a lowercase letter (like ?x or ?y), the function should return a list giving the variable and the corresponding clause, since a variable matches anything. If the, pattern is not a variable, should return t only if the pattern and the clause are identical. Otherwise, the function it should return nil.

,'"

Starting with this chapter, we begin a study of some basic too and methodologies used in AI and the design of knowledge-based systems. T e first representation scheme we examine is one of the oldest and most importa ,First Order Predicate ~gic ~ It was developed by logicians as a mea s for formal reasoning, primanly IIIthe areas of mathematics. Following our study f FOPL, we then investigate five additional representation methods which hav become popular over the past .twenty years. Such methods were developed by esearchers in Alar related fields for use in representing different kinds of kno edge. After completing these chapters, we should be in a position to best choose which representation methods to use for a given application, to see how automated reasoning can be programmed, and to appreciate how the essential parts of a system fit together. ~ 4.1 INTRODUCTION The use of symbolic logic to represen owledge is not new in that it predates the modem computer by a number ecades. Even so, the application of logic as a practical means of represe . g and manipulating knowledge in a computer was not demonstrated until' early 1960s (Gilmore, 1960). Since that time, numerous
47

48 Formalized Symbolic Logics Sec. 4.2 Syntax and Semantics for Propositional Logic 49

systems have been implemented with varying degrees of success. Tod~..order Predicate Logic(F()PL) or Predicate Calculus as it is s9metimes c~, has assumed one of the most important roles in AI for the representation of knowledge ,_lLfamiharity'with'POPL is important to the student of AI f()[several reasons. FIr:~t,logic offers the only formal approach to reasoning that has a sound theoretical foundation. This is especially important in our attempts ,to mechanize or automate the reasoning process in that inferences should be correct and logically sound. Second, the structure of FOPL is flexible enough to permit the accurate representation of natural Janguage reasonably well. This too is important in AI systems since most knowledge must originate with and be consumed by humans, To be effective, transfor, mations between natural language and any representation scheme must be natural and easy, Finally, FOPL is widely accepted by workers in the AI field as one of the most useful representation methods, Ii is commonly used in program designs and widely discussed in the literature. To understand many of the AI articles and research papers requires a comprehensive knowledge of FOPL as well as some related logics. ~rmal method for reasonil}g.Many concept. ich can be verbalized can be translated int;sy'mEohc representations which cI y approximate the meaning of these concepts, These symbolic structures ca en be manipulated in programs to deduce various facts, to carry out a form automated reasoning. In FOPL, statements from a n tur anguage like English are translated into symbolic structures comprised of pre !Cates,functions, variables, constants, quantifiers, and logical connectives. The symbols form the basic building bl,ocks for the knowledge, and their combination into valid structures is accomplished using the syntax (rules of combination) for FOPL. Once structures have been created to represent basic facts or procedures or other types of knowledge, inference rules may then be applied to compare, combine and transform these "assumed" structures into new "deduced" structures. This is how automated reasoning or inferencing is performed. As a simple example of the use of logic, the statement" All employees of the AI-Software Company are programmers" might be written in FOPL as
(\fx) (AI-SOFTWARE-CO-EMPLOYEE{x) --> PROGRAMMER(x})

The. above suggests how knowledge in the form of English sentences can be translated into FOPL statements. Once translated, such statements can be typed into a knowledge base and subsequently used in a program to perform inferencing. , We begin the chapter with an introduction to Propositional Logic, a special case of FOPL. This will be constructive since many of the concepts which apply to this case apply equally well to FOPL. We then proceed in Section 4.3 with a more detailed study of the use of FOPL as a representation scheme. In Section 4.4 we define th'e syntax and semantics of FOPL and examine equivalent expressions. inference rules. and different methods for mechanized reasoning. The chapter concludes with an example of automated reasoning using a small knowledge base.

y alid

s~menL:i...!2L'entences

in Ple.are

<'fe'fern1!.'2~9!lE~<.>r~i_r:lL~),E~~_rul.~,2..9f..p19.Posi,

tional synU!x. This syntax governs the combination of basic building blocks such as propositions and logical connectives. Propositions ?re elementary' atofl~,:~<:.n.,~~_'lces. (We shall also use the termjimllu!as or Wl'!!~timlll'dformll!as in place of sentences.) Propositions may be eitb.yue QLJ:aJ.-:;e but may take on no other value. Some examples of simple proposition~".?re
It is raining.
,,.'-'

My car is painted silver ,r""" John and Sue have five children. Snow is white.

People live on the moon.


Compound propositions are formed from, atomic ,formlll.f1_~~iJ.!KJ11~Jgical connectives not ang,or if .-:--,then,ana-'i.1ancr;miy';CFor-e"xarnple, the following are compound formulas.

Here, 'rIx is read as "for all x" and -'> is read as "implies" or "then." The predicates AI-SOFTW ARE-CO-EMPLOYEE(x), and PROGRAM R(x) are read as "if x is an AI Software Company employee," and "x is a grammer" respectively. The symbol'x is a variable which can assume a per' n's name, If it is also known that Jim is an employee of AI oft ware Company,
AI-SOFTWARE-CO-EMPL

tions: T and F are specialsymbolshavingthe values


one can draw the conclusion that Jim is a programmer.
PROGRAMMER(jimJ

followed by digits, to stand for propositrue and false, respectively. The following symbols will also be used for logical connectives
We will use capital letters. sometimes - for not or negation

--"
"\',

& f9.u.u1d
'''j ( ',) ,

or ~!:IJ_l:~::Eig!L,,,~

-,~-"".-

'''''''''~~''''''''

50 Formalized Symbolic Logics ~ V for or or disjunction ---7 for if. . . then or implication Chap. 4

51

Soc. 4.'

SV''''/,'''I''

foe P,op"llIoo"

Logl,

~/

*-' for

if and only if or double implication

In addition, left and right parentheses, left and nght braces, and the period will be used as delimiters for punctuation. So, for example, to represent the compound sentence "It is raining and the wind is blowing" we coulC! write (R & B) where R and B stand for the propositions "It is raining" and "the wind is blowing," respectively. If we write (R V B) we mean "it is raining or the wind is blowing or both" that is, V indicates inclusive disjunction.
Syntax

/'
of PL is definedrecursively follows. as F are formulas.

~~x ~nd

semantic~ The semanrics or peaning of a sentelJ(,:eis just the val!.u:.lJ:!.g; fal.~; that is. it is or an assignment of a truth value to the sentence. The values true and 'false should not be confused with the symbols T and F which can appear within a sentence. Note however, that we are not concerned here with philosophical issues related to meaning but only in determining the truthfulness or falsehood of formulas when a particular interpretation !.S~iventoits propositions. An interpretation for a sente'pce an 'asslgninenCor-aT(1itfi'Valuftoeach propositional ~y-mbol. or group ~ As an~mple, consider the stateiTient(P & -Q). One 'Interpretation (/1) assigns true to P and false to Q. A different interpretation (/2) assigns true to P and true to Q. Clearly, there are four distinct interpretations for this sentence. Once an interpretation has been given to a statement, its truth value can be determined. This is done by repeated application of semantic rules to larger and larger parts of the statement until a single truth value is determined. The semantic rules are summarized in Table 4.1 where t, and t' denote any true statements, J, and J' denote any false statements, and a is any statement.
TABLE 4.1 SEMANTIC RULES FOR STATEMENTS Rule number True statements T 1&1' / Va aV/ a-->I 1--> a /<->/' False statements F
/

.-" -' If 8-'andQ are formulas.the followingare formulas: rp,

(P & Q) (P V Q)

/
/
for brevity:

I
,, i

(P--> Q)
(P...Q)

All

formulas are generated from a finite number of the above operations.

;
t
1

I. 2. 3 4. 5. 6. 7. 8.

I& a a&I [Vf' I-->I I<->I

I-I'

I-I

An exampleof a compoundformulais
(P & rQ V R) -->
(Q --> S))

We can now find the meaning of any statement given an interpretation I for the statement. For example, let I assign true to P, false to Q and false to R in the statement
(P & -Q) --> R) V Q

When

& CQ) can be written as -( P & -Q). When omitting parentheses, the precedence given to the connectives from highest to lowest is -, &, V, ---7, and *-'. So, for to add parentheses correctly to the sentence
P & -Q V R --> S ... U V W

np

there

is no chance

for ambiguity,

we will omit parentheses

Application of rule 2 then gives -Q as true, rule 3 gives (P & -Q) as true, rule 6 gives (P & -Q) ---7R as false, and rule 5 gives the statement value as false. Properties of Statements

'"'' & -'QII V RI-

$I -IU V

I i

Satisfiable. which it is true.

A statement

is satisfiable

if there is some interpretation

for

!, 52

Formalized Symbolic Logics Contradiction. pretation for which'~ ~ence ~::.m

Chap. 4

Sec. 4.2

Syntax and Semantics for Propositional


TABLE4.2
Idempotency

Logic

53

is contradictory (unsatisfiable) if there is no inter-

SOME EOUIVALEN

Valid. tau.t&ogies. valid if it is (rue for every interpretation. Valid sentences is are also called A sent~
Associativity

pvp=p P&P=P

Equivalence.
under every interpr/

Two sentences are equivalent if they have the same truth value
' Distributivity

Logical consequence. A sentence is a logical consequence of another if it is satisfied by all inte etations which satisfy the first. More generally, it is a logical consequence of other statements if and only if for any interpretation in which the statements are true, the resulting statement is also true. A valid statement is satisfiable, and a contradictory statement is invalid, but converse statements. the following is not necessarily true. As examples of the above definitions consider P is satisfiable but not valid assigns false to the sentence P.since an interpretation that assigns false to P P V T). is valid since every interpretation results in a value of true for (P V -P P (P & a contradiction since every interpretation results in a value of false for& -Pis -Pi. interpretation. equivalent since each has the same truth values under every P and -(Pi are P & Q) is true, P is also true. (P is a logical consequence of (P & Q) since any interpretation for which
The notion of logical consequence provides us with a means to perform valid inferencing in PL. The following are two important theorems which give criteria for a statement to be a logical consequence of a set of statements. of .\'1, , .1'"if

De Morgan's laws Conditional elimination

logical cons~ence valid, that is, i~nd

. . , .1'"if and only if of Sl' only i -Cst & S2 &. . . & .1'"

1 & S2 & . . . & .1'"---,> is .I' s) is inconsistent. But

& s" ---,> = -erst & S2& . s)


= -- (Sl S2&
= SI & .1'2&

/----

Theorem 4.1. The sentence s is a logical consequence and only if .1'1 .1'2 & & . & s" ---,> .I'is valid.
j

s" if
TABLE4.3 P
true true false fals"

at if s is a logical which .1'1& S2 &, . .' & .1'"---,>.I' then for any since .I' is a

TRUTH TABLE FOR EOUIVALE Q 'p


false fahc true true

SENTENCES (Q -7 P)
[rue true false true (I' -> Q) & (Q -7 PI true false false true

('I' V Q)
,true faise true true

-7 Q)
tnrc false true true

trLle false true fa be

s,

Вам также может понравиться