• Aucun résultat trouvé

CLASSICAL LOGIC

Dans le document FUZZY EXPERT SYSTEMS AND FUZZY REASONING (Page 46-53)

3 Fuzzy Logic, Fuzzy Sets, and Fuzzy Numbers: I

3.1 CLASSICAL LOGIC

Fuzzy logic notation and operations are based on classical logic and the pro-positional calculus, the modern form of notation for classical logic; we first review their foundations.

According to the Random House unabridged dictionary of the English language, logic is “the science that investigates the principles that govern correct or reliable inference”. The basic element of logic is aproposition, a statement in which some-thing is affirmed or denied, so that it can therefore be characterized as either true or false. A simple proposition might be “the president’s first name is William” or “the president’s age is 48”. A more complex proposition is “the president’s first name is William AND his age is 48”. Surely, we can determine if these propositions are true or false. In classical logic, propositions are either true or false, with nothing in between. It is often conventional to assign numerical values to the truth of pro-positions, with 1 representing true and 0 representing false. Important principles of classical logic are the Law of the Excluded Middle, which states that a proposition must be either true or false, and the Law of Non-Contradiction, with states that a proposition cannot be both true and false at the same time. We will denote prop-ositions by capital letters P, Q, R,. . .. The truth value of proposition P will be written tv(P), or simply P if the context makes it clear what is meant. In two-valued logic, truth values must be either 0 (false) or 1 (true).

We will be concerned with two kinds of truth values (Dubois and Prade, 1988).

First, we definepossibilityto be the extent to which the available datafail to refute

Fuzzy Expert Systems and Fuzzy Reasoning, By William Siler and James J. Buckley ISBN 0-471-38859-9 Copyright#2005 John Wiley & Sons, Inc.

a proposition. Possibility measures the extent to which a propositionmightbe true.

In the absence of any data to the contrary, the possibility of a proposition is one. (An analogous term isplausibility.) Second, we definenecessityto be the extent to which the available datasupporta proposition. Necessity measures the extent to which a propositionmustbe true. In the absence of any supporting data, the necessity of a proposition is zero. Analogous terms arecredibilityorbelief.

An example: Suppose that we wish to establish the truth of proposition R. Proposition P supports the truth of proposition R; in the lack of other knowledge, the necessity of R is the truth value of P. On the other hand, proposition Q refutes R;

the possibility of R is (NOT Q).

Since this book is concerned with constructing programs to return answers to real-world problems, we will be concerned primarily with necessity; we will want to reach conclusions that are supported by data, not conclusions that might possibly be true.

The truth value of complex propositions is obtained by combining the truth values of the elemental propositions, which enter into the complex proposition. The most common operators (called connectives) are NOT, AND (A AND B is true if both A and B are true) and OR (A OR B is true if either A or B or both are true.)

In this chapter, we will be concerned withtruth-functionaloperators. An operator is called truth-functional if the truth value of the resulting proposition is determined solely by the truth values of its operands. That is, the truth value of (say) A AND B is determined only by the truth values of A and B, and no other information is required. Negation, written NOT P, is the simplest example of a truth-functional oper-ator; the truth value of NOT P depends only on the truth value of P, and not on any-thing else. (For classical logic, this seems obvious; for fuzzy logic, it is not so obvious, as we shall see later in Chapter 4, Section 4.2.2.) We will use throughout this book tv(NOT P)¼12tv(P). The two other most common truth-functional operators, also called connectives, are AND and OR. (As we shall see later, these operators are not necessarily truth-functional, although this is seldom admitted!) A set of truth-functional operators that can generate all the others is called a primitive set of operators. It is well known in propositional calculus that all the other truth-functional operators can be constructed from either the NOT and AND or the NOT and OR oper-ators. Computer scientists, electrical engineers, and logicians use different sets of primitive connectives. The NAND operator is defined as A NAND B¼NOT (A AND B), and from the NAND operator alone all other logical operators may be constructed; electronic engineers, often take NAND as a primitive, since it is easily implemented in circuitry. Logicians sometimes take the implication operator (A IMPLIES B, defined below), as a member of the primitive set; all other logical oper-ators can be defined from the NOT and IMPLIES operoper-ators. Most computer languages furnish AND, OR, and NOT as basic operators. Since our interest is in expert systems implemented in a computer language, we will take AND, OR, and NOT as basic.

3.1.1 Evaluating A AND B and A OR B

The evaluation of tv(P AND Q) and tv(P OR Q), given truth values for P and Q, is shown in Table 3.1, a presentation known as a truth table.

There are many formulas that can be written to compute algebraically the truth of P AND Q and P OR Q from the truth values for P and Q, all of which will give the same answers as listed in Table 3.1 for classical (crisp) truth values of 0 or 1. (In fuzzy logic, these formulas may give different answers!) Here, we list only three of these formulas for P AND Q, all equivalent for classical (but not for fuzzy) logic. In this and succeeding chapters, we may use the symbol tv(A) to indicate the truth value of A, or may simply use A to denote both a proposition and its truth value. For all fuzzy logic operators,

NOT P = 1–P P AND Q:

Zadeh operator:

P AND Q¼min(P, Q) (3:1)

Probabilistic operator, assuming independence:

P AND Q¼PQ (3:2)

Bounded difference operator:

P AND Q¼max(0, PþQ1) (3:3)

Just as there are many formulas for computing P AND Q, there are also many ways of computing P OR Q, which will all give the same result as in Table 3.1 for classical logic, but that are not equivalent for fuzzy logic. We list three of these in (3.4) – (3.6):

P OR Q:

Zadeh operator:

P OR Q¼max(P, Q) (3:4)

Probabilistic operator, assuming independence:

P OR Q¼PþQPQ (3:5)

Bounded sum operator:

P OR Q¼min(1, PþQ) (3:6)

TABLE 3.1 Truth Table for AND and OR Logical Operators

P Q P AND Q P OR Q

0 0 0 0

0 1 0 1

1 0 0 1

1 1 1 1

3.1 CLASSICAL LOGIC 31

Each formula for P AND Q has a corresponding formula for P OR Q, called a dual operator. In the above, (3.1) and (3.4) are a dual pair, as are (3.2) and (3.5), and also (3.3) and (3.6). If the NOT and AND operators are chosen as primitives, we can derive the OR operator as P OR Q¼NOT(NOT P AND NOT Q); if the NOT and OR operators are taken as primitive, we can derive the AND operator from De Morgan’s theorems, given in (3.7) and (3.8):

P AND Q¼NOT(NOT P OR NOT Q) (3:7)

or, conversely,

P OR Q¼NOT(NOTP AND NOTQ) (3:8)

In this way, the formula (3.4) can be derived from (3.1); formula (3.5) can be derived from (3.2); and formula (3.6) can be derived from (3.3). Dual operators satisfy these relationships.

Actually, (3.1) and (3.3), (3.4), and (3.6) represent extremes in the range of fuzzy operators that can be derived from probability theory, and there are similar operator pairs for special purposes that go even beyond these extremes. The problem we now face is—which operator pair do we choose as a default?

Fortunately, there are two approaches to this choice, both of which agree.

First, there are many years of experience by many workers in the field who have chosen the Zadeh operators (3.1) and (3.4) with great success.

Next, there is a theoretical basis. Truth values may be derived from probability theory as the averages of expert binary true – false judgments (Klir and Yuan, 1995, p. 283). If the experts judge two rather than one event, it is likely that their judgments would be strongly positively associated; under this condition, the Zadeh operators are the correct theoretical choice. Of course, under other conditions other operators might be better (Buckley and Siler, 1999).

Exercise AndOrNot—Check on Logic Formulas for AND, OR, and NOT. In this exercise you will calculate NOT A, A AND B, and A OR B from the above for-mulas. To run the exercise, invoke TFLOPS, load program AndOrNot.fps, and run it as you did the programs in Chapter 2 exercises. AndOrNot.fps will ask you to enter truth values a and b, and will then calculate NOT A, and then calculate A AND B and A OR B by all three sets of formulas above; min-max logic, probabil-istic logic and bounded sum/difference logic. To quit the program, enter a negative truth value for b.

We suggest that you first check that for crisp (not fuzzy) logic (truth values 0 or 1), all three logics give the same answers. Then try truth values between zero and one, anticipating fuzzy logic, and see what answers the three logics give. Rule r0 in AndOrNot.fps uses a truth value test. The antecedent (in Data a.cf¼0) checks that the truth value of a in data element Data is zero. This is the case if no value is currently assigned to attribute a. (Note that truth values of attributes are also attributes.)

In rule r2, AndOrNot.fps adds modification of a data element and FLOPS’

calculator to the available tools. Consider the consequent command in 1 Zand = (min(<A>, <B>)) Zor = (max(<A>, <B>))

This command will modify attributes in the first data element in the antecedent (in 1). Attribute Zand will be set to the minimum of variable,A. and variable ,B. by FLOPS’ calculator, called by the open parenthesis after “Zand¼”, and closed by the corresponding close parenthesis. min() and max() are among the func-tions supplied by the calculator.

Rule r3 sets all the truth values in Data to zero by the simple expedient of deleting the old instanceand creating a new instance in which no attri-buteshave been assigned values.

:Exercise AndOrNot.fps

message "Compiling AndOrNot.fps";

declare Data

a flt :truth value a

b flt :truth value b

Nota flt :truth value of NOT a Zand flt :a AND b using Zadeh logic Zor flt :a OR b using Zadeh logic

Pand flt :a AND b using probabilistic logic and independence

Por flt :a OR b using probabilistic logic Band flt :a AND b using bounded logic

Bor flt; :a OR b using bounded logic :rule r0

rule (goal Input a and b truth values) IF (in Data a.cf = 0)

THEN

write "Input a", read 1 a,

write "Input b (negative to quit)", read 1 b;

:rule r1

rule (goal Quit if b negative) IF (in Data b < 0)

THEN exit;

:rule r2

rule (goal Calculate Nota, aANDb, aORb by various multi-valued logics)

3.1 CLASSICAL LOGIC 33

IF (in Data a = <A> AND b = <B> AND Nota.cf = 0 AND b > = 0) THEN

in 1 Nota = (1 - <A>),

in 1 Zand = (min(<A>, <B>)) Zor = (max(<A>, <B>)), in 1 Pand = (<A> * <B>) Por = (<A> + <B> - <A> * <B>), in 1 Band = (max(0, <A> + <B> - 1)) Bor =

(min(<A> + <B>, 1));

:rule r3

rule (goal Print results and try again)

IF (in Data Nota = <NOTA> AND Zand = <ZAND> AND Zor = <ZOR>

AND Pand = <PAND> AND Por = <POR> AND Band = <BAND> AND Bor = <BOR> AND a = <A> AND b = <B>)

THEN

write "a <A> b <B>\n",

write "Min-max Zadehian logic\n",

write "a AND b <ZAND> a OR b <ZOR> NOT a <NOTA>\n", write "Probabilistic logic\n",

write "a AND b <PAND> a OR b <POR> NOT a <NOTA>\n", write "Bounded sum logic\n",

write "a AND b <BAND> a OR b <BOR> NOT a <NOTA>\n\n", delete 1,

make Data;

message "Ready to run";

run;

It is easy to see that rule-based systems may not be optimal for efficient numerical computation. By using the advanced feature of recursion, we can solve differential equations, compute factorials, and the like. (Recursion here means computation when one or more rules or rule blocks makes itself refireable until some goal is reached.) But if heavy numerical computation is needed, it is often better to do this in a more numerically oriented language like C or FORTRAN, and to use a blackboard system for inter-program communication and control.

3.1.2 The Implication Operator

Another basic truth-functional operator used in fuzzy logic is logical implication, written P implies Q, P!Q or IF P, then Q. Table 3.2 is the truth table for P!Q. Three different methods for determining tv(P!Q), among many other methods listed in Klir and Yuan (1995, p. 309), are

tv(P!Q)¼1 if tv(P) tv(Q), else tv(P!Q)¼0 (3:9)

tv(P!Q)¼min(1, 1tv(P)þtv(Q)) (3:10)

tv(P!Q)¼max(1tv(P), min(tv(P), tv(Q))) (3:11)

Equation (3.11) may also be expressed in terms of OR and NOT as

P!Q¼(NOT P) OR Q (3:12)

The classical truth table for P!Q is shown in Table 3.2.

The reader will probably find it difficult to accept that if P is false, P!Q is true whether Q is true or false. Note that formal logic is not concerned with objective truth in the ordinary sense of the word, but with consistency between premises and conclusions. P being false is consistent with Q being true or false, since if P is false we have no idea what Q might be. P!Q does not only mean that if P is true, then Q is true; it is a measure of the consistency of the truth value of P with the truth value of Q. (Logicians have had no trouble with this for a very long time!) Note that the implication operator, of its very nature, returns a possibility, not a necessity. This is clear when we look at truth table 3.2 for the classical implication operator P!Q, where 0!1 is true. Clearly, if the truth value of P is zero, we cannot conclude that thisrequiresthe truth value of Q to be one, as would be the case with necessity; on the other hand, if P is false, the truth value of Qmightbe one for all we know, as is the case with possibility. For this reason, the implication operator is of little or no use in a fuzzy reasoning system based on necessity; it is included here because texts of fuzzy theory pay considerable attention to it.

Classical logic now continues using NOT, AND, OR and!to derive other con-nectives and prove theorems about disjunctive normal forms, various sets of primi-tives, and so on. An important tool in classical logic for deriving new propositions from old is the modus ponens, which can be written

if P AND (P!Q) then Q (3:13)

which can be read “If P is true and P implies Q then Q is true”. Note that the classical modus ponens employs the implication operator.

The formulation of the modus ponens in (3.13) can be (and has been) misleading, because of its strong resemblance to a rule in a rule-based language. However, note that in the modus ponens and its counterpart, the fuzzy modus ponens, discussed in Chapter 4, Section 4.3, both the antecedent (if. . .) and the consequent (then. . .) are

TABLE 3.2 Truth Table for Logical Operator P Implies Q

P Q P implies Q

0 0 1

0 1 1

1 0 0

1 1 1

3.1 CLASSICAL LOGIC 35

logical propositions, and the resulting truth values are possibilities rather than necessities. In a useful rule, we employ necessities rather than possibilities.

This means that the fuzzy modus ponens that employs an implication operator is not applicable to a rule-based system such as we are describing in this book.

Exercise Imply.fps: Evaluating Implications. Program Imply.fps calculates the truth value of using the fuzzy implication operators given in (3.7) – (3.9), and for arbitrary truth values for P and Q. As before, run TFLOPS and load Imply.fps from folder Examples. First, check for crisp values of P and Q to make sure the for-mulas give the classical values of the implication for crisp inputs. Then check for values of P and Q between zero and one. It will be very quickly obvious that the different formulas are not equivalent, but can produce different values for the truth value of the implication.

When running Imply.fps, try both P and Q¼0. In this case, for all fuzzy impli-cation operators that reduce to the classical values for crisp operands, the truth value of P!Q is 1. This can be interpreted as “If we don’t know anything, then anything is possible.”

If we use the implication operator to evaluate the truth value of the consequent of the rule “if P then Q”, we would conclude that Q is true. In other words, the implication operator returns the possibility that Q might be true, judging from that rule alone. In fuzzy math terms, the implication operator returns the possibility that Q might be true, rather than thenecessityof Q being true. In expert systems that assign a single truth value to data, this could be seriously misleading; in such expert systems, we would ordinarily expect a truth value to reflect the extent to which the data support a conclusion, rather than the extent to which the data fail to refute a conclusion.

The problem is further complicated by the number of fuzzy implication operators available (Klir and Yuan, 1996 list 14), and the lack of any clear guidelines as to which fuzzy implication one should use (Klir and Yuan, 1995, p. 312), “To select an appropriate fuzzy implication for approximate reasoning under each particular situation is a difficult problem”. In general, however, if any implication is employed to evaluate a rule, if the antecedent is false the rule will always be fireable; if the antecedent is true the rule may or may not be fireable, depending on the particular implication operator chosen. If the antecedent has truth value 1 and the prior truth value of the consequent is 0, the rule will never be fireable no matter what impli-cation operator is chosen.

All these facts lead us to conclude that the implication operator is of dubious value in a fuzzy expert system.

3.2 ELEMENTARY FUZZY LOGIC AND FUZZY PROPOSITIONS

Dans le document FUZZY EXPERT SYSTEMS AND FUZZY REASONING (Page 46-53)