FUZZY LOGIC AND FUZZY EXPERT SYSTEMS

Atmika Singh

Abstract: Fuzzy logic is a superset of classical logic introduced by Dr. Lotfi Zadeh. This paper discusses a mathematical basis of fuzzy logic along with the concepts of fuzzy sets, membership functions and rules of reasoning.Fuzzy expert systems accept inputs numbers and convert them into linguistic values which are then manipulated by if-then rules given by ahuman expert. The concept of a fuzzy expert system with its rule-base and set membership functions is discussed in detail. After defining the rules and membership functions, the application of this knowledge to the input variables to compute the values of the output variables is studied. A case study is presented alongwith an implementation in MATLAB.

1.Introduction.In the classical two-valued logic, propositions can take only twotruth values from the set.It has been shown using De Morgan's algebras that the propositional logic obtained when the set of truth assignments consists of all values in the unit interval with conjunction, disjunction and negation as defined in the table 1 (Appendix C) is the same as fuzzy logic [4]. De-Morgan algebra is a structure such thatis a bounded distributive lattice. ¬ is a De Morgan involution such that. When the classical set of truth values is extended to include a third value called 'undecided', the De Morgan algebra generated gives rise to three-valued logic. A structure forms a De Morgan's algebra.Using this as the algebra of truth values, classical fuzzy logic is generated. It has been shown that the equational class of all De-Morgan's algebras can be generated by both three-valued logic and fuzzy logic, hence they are the same. Fuzzy logic extends propositional logic to all values in the interval [0,1]. In such a case,a statement may have a truth value that is neither completely true nor completely false. Basic fuzzy logic operations as defined by Dr. Zadeh are shown in the table 1 in appendix C.

2. Fuzzy sets and membership functions.A fuzzy set is a class of objects in which there is no sharp boundary between those objects that belong to the class and those that do not. Some common examples are the sets of all young women or the set of small cars. In a fuzzy set an object may have a grade of membership intermediate between full membership, represented by 1, and non-membership, represented by 0. Mathematically, the transition from regular sets (crisp sets) to fuzzy sets can be explained by assuming a universal set such that is a crisp subset of. Define a function such that is 1 if and is 0 when. This function is the characteristic function of any crisp subset of. Fuzzy sets generalize the characteristic function by allowing all values in the unit interval. This is known as the membership function. Any fuzzy subset of is defined by its membership function. Then where denotes the grade of membership of x in the fuzzy set. is called the universe of discourse. A fuzzy subset (or fuzzy set as it is commonly referred to) is defined as a set of ordered pairs. The membership function is denoted by for the fuzzy setF.

For example, let X be the set of people and F be the set of 'Tall' people. Each person is assigned a degree of membership in thefuzzy subset TALL. For this we define a membershipfunction based on the person's height. The intervals of 5ft and 7ft are arbitrarily chosen for the sake of the example and can be replaced by any other suitable intervals.

Based on the above definition if there is two individuals 3 ft and 6ft tall would have 0 and 0.5 membership grade respectively [2].

3. Fuzzy logical operations. Some fuzzy set theorems are presented in table 2 in appendix C.The negation operation defined in table 1 is standard. The computation of AND and OR are however not standard. The AND and OR operators in fuzzy logic are generalizations from classical logic and are called t-norms and t-conorms respectively. T-norms and t-conorms are functions from into[1]. If, then all belong to the interval. All t-norms and t-conorms have the properties of commutativity, monotonicity, boundary and associativity. Let tv be a truth assignment, then for any t-norm. The basic t-norms are:

1) (Zahedian intersection)

2) (Bounded difference intersection)

3) (Algebraic product)

As for t-norms, If C is a t-conorm then, . The basic t-conorms are:

1) (Standard Union)

2) (Bounded sum)

3) (Algebraic sum)

4. Fuzzy propositions and truth assignments. A fuzzy proposition is a statement that takes a fuzzy truth value. It includes logical connectives like AND, OR, NOT and Implication. An atomic fuzzy proposition cannot be decomposed into simpler fuzzy propositions and are combined together to create compound propositions. For example, a fuzzy rule of the form (x is fast) is an atomic fuzzy proposition because it can not be decomposed into simpler propositions. Other examples are x and size is small. A compound fuzzy proposition consists of atomic propositions that are conjuncted, disjuncted, complemented or connected by implication. An example of a complex fuzzy proposition is ((x is A) AND (x is B) AND (y is C) AND (z is D)). The truth value of a proposition x, that simply asserts that x exists is the truth value of x. If, for example, x is assigned a value 10 with truth value 0.75, then truth value of the proposition is 0.75. Most fuzzy propositions involve only single valued data like integers or strings [1]. They are of the general form (A(comparison operator)B). For example, A :() where value of and the membership values are comparison operator = 1. Therefore, truth value of A = min(0.8,1,0.7) = 0.7. For propositions of the form (Size is small), the truth value (tv)of the fuzzy set size, tv(size) = 1, of the comparison operator 'is' is 1. The truth value of SMALL in size is its grade of membership in size, for example 0.4. Then tv((Size is small)) = min(1,1,0.4) = 0.4. Truth values of complex propositions are obtained by evaluating the logical operators. For example [1], let P be a complex proposition,. The truth values of A, B and C are 0.6, 0.8 and 0.3 respectively. Then, tv(A)= 0.6, tv(A AND B) = min(0.6,0.8) = 0.6, tv(NOT C) = 1 - 0.3 = 0.7. Therefore, tv((A AND B) OR (NOT C)) = max(0.6,0.7) = 0.7.

5. Linguistic variables and linguistic values. A linguistic variable is a variable whose value is expressed in terms of spoken language. These terms are imprecise and are represented by fuzzy sets.Lett be a variable that denotes temperature over an interval [0, T]. Let X be the domain of real numbers. Let there be three fuzzy sets L, M and H that have the member ship functions respectively. Each of these fuzzy sets can be referred to as LOW, MEDIUM and HIGH. TEMPERATURE can be treated as a linguistic variable. LOW, MEDIUM and HIGH are linguistic values of the linguistic variable TEMPERATURE. Thereforetcan be LOW, MEDIUM or HIGH.

6. Fuzzy rules andinference. Inference involves the modification of the values or truth values of data using rules [1]. A fuzzy rule is a proposition in the if-then format. It contains a main implication connective and fuzzy propositions. These can be of the form,

((x is A) AND (x is B) AND (y is C) AND (z is D)) => (r is Q)

where x, y and z are input variables, r is anoutput variable, A,B and Care membership functions defined on x, y and z respectively and Q is a membership function defined on r.

The rule's premise(left hand side) is called the antecedent and it describes to what degree the ruleapplies, while the conclusion (right hand side)is called the consequent. Thisassigns amembership function to each of one or more output variables. The set of rules used for inferencing in a fuzzy expert system is known as the rulebaseor knowledge base.

The most common tool used for fuzzy logical inference is approximate reasoning, used to infer new logical propositions from old ones. Approximate reasoning employs the generalized modus ponens. Classical modus ponens isif A then B. The fuzzy version is formulated as: If X is A then Y is B, from X = A' infer that Y = B'. Here A and A' are fuzzy sets belonging to the same universe and B and B' are also defined on the same universe which maybe different from that of A and A'.

7. Fuzzy expert systems. An expert system involves the collection and encoding of human knowledge about prediction and classification, together with an inference engine for evaluating the rule base for a given set of inputs [1].

The basic components of a fuzzy expert systemare aset of fuzzy rules, a set of fuzzy set membership functions and a fuzzy inference engine[2].They are used in several wide-ranging fields including, linear and nonlinear control, pattern recognition, and financial systems and data analysis.The fuzzy inference engine contains a scheduler that selects the rules in a sequence for processing. A scheduler is needed because certain rules must be checked before others. Some rules fire and make their consequents true. These consequents are the antecedents in the certain rules. Thus a firing order is needed implemented by a scheduler. It also contains a rule processor that examines the left hand side of a rule to check the truth values of the conditions. It uses these truth values to fire the rule. Aset membership builder builds an approximate membership functionfor the output from the firing of the rules using approximate reasoning. A defuzzifierthen convertsthe inferred fuzzy values of the consequents to a non-fuzzy value. The operation of the expert system proceeds as follows.

1. Fuzzification: This process involves finding grades of membership of the linguistic values of a linguistic variable corresponding to an input value given by the user or process. The degree of truth for each rule antecedent is calculated by applying the membership functions to the input values.

2. Inference:The if–then rules are implemented and the truth value of each rule is computed using the truth values of the linguistic values. Approximate reasoning as describe earlier isused. Commonly used inference rules are minandproduct. In min inferencing, the output membership function is determined by either the truth value of the implemented rule or the original value of the membership function, whichever is lower (fuzzy logic AND). In product inferencing, the output membership function is scaled by the rule premise's truth value.

3. Composition: All of the fuzzy subsets assigned to each outputvariable are combined together to form a single fuzzy subset for each output linguistic variable. The methods used are maxand sum. In max composition, the fuzzy sets for the output variable are ORed with each other so that the maximum value from all the fuzzy subsets is used (fuzzy logic OR). In sum composition, the fuzzy subsets associated with the output value are summed to generate a single fuzzy subset.

4. Defuzzification: This is the process of calculating a scalar value from the fuzzy output. From composition we obtain a single fuzzy set. Defuzzification aggregates the set into a single value. The common techniques used are the centroid and maximum methods. In the centroid method, the scalar value of the output variable is computed by finding the variable value of the center of gravity of the membership function for the fuzzy value. The general formula is where [a, b] is the interval of the aggregated membership function. In the maximum method, the value at which the fuzzy subset has its maximum truth value is chosen as the value for the output variable.

8. Implementation of a simple fuzzy expert system. To demonstrate the use of fuzzy expert systems, a fuzzy washing machine is implemented. The details of the system were obtained from reference [5]. A detailed implementation of the expert system is provided in appendix A.

1. Developing membership functions: The washing machine receives input from the user in the form of scalar values on a scale of 1 to 10. These correspond to two linguistic variables, "degree of dirtiness" and "type of dirt". Each has 3 linguistic values, Degree of dirtiness (Dd) = {Low, Medium, High}= and Type of dirt (Dt) = {Not greasy, Medium greasy, Greasy}= . The expected output from the expert system is the linguistic variable "duration of the wash cycle (Wd)" ranging from 0 to 60 minutes. The linguistic values for the output are Wd = {Very short, Short, Medium, Long, Very long}= . The linguistic variables are the fuzzy sets and each of the 11 linguistic values (6 for the inputs and 5 for the outputs) are fuzzy membership functions. The function definitions are listed in appendix A.

2. Developing the rule-base: We have2 inputs comprising of 3 membership functions each. Thus we will have 3x3 = 9 rules of inference comprising the rule base.

If degree of dirtiness is High and type of dirt is Greasy, then duration of wash cycle is Very long;

If degree of dirtiness is Medium and type of dirt is Greasy, then duration of wash cycle is Long;

If degree of dirtiness is Low and type of dirt is Greasy, then duration of wash cycle is Long;

If degree of dirtiness is High and type of dirt is Medium, then duration of wash cycle is Long;

If degree of dirtiness is Medium and type of dirt is Medium, then duration of wash cycle is Medium;

If degree of dirtiness is Low and type of dirt is Medium, then duration of wash cycle is Medium;

If degree of dirtiness is High and type of dirt is not greasy, then duration of wash cycle is Medium;

If degree of dirtiness is Medium and type of dirt is not greasy, then duration of wash cycle is Short;

If degree of dirtiness is Low and type of dirt is not greasy, then duration of wash cycle is Very short

Since none of the above rules depend on the firing on any of the other rules, a scheduler for the firing of rules is not needed.

3. The expert system algorithm:

  1. Accept user inputs from an interface. These are values on a scale of 1 to 10.
  2. Fuzzify the inputs, i.e. determine the membership values in each of the 6 membership functions for both inputs.
  3. Apply the membership values of the inputs to the rule-base to generate the truth values of the consequents of the 9 rules.
  4. Use MIN inferencing to generate new output membership functions. The new membership values are compared point wise to the original membership functions to get the modified output membership functions
  5. Combine the new membership functions to form a single membership function using MAX composition method. In this all the newly generated membership functions are combined with each other using the fuzzy OR and the maximum possible membership value is chosen for each output value.
  6. Perform defuzzification using the centroid method to get a scalar output value for the actual duration of the wash cycle.

9. Conclusion. Fuzzy expert systems provide a convenient way of handling uncertain values. They are used in several wide-ranging fields including, linear and nonlinear control, pattern recognition, and financial systems and data analysis. A table of the results obtained for the fuzzy washing machine expert system is attached in appendix A. The performance can be improved by using better defined rules of inference and membership functions.

References:

[1] – Siler, W; Buckley, J. J., Fuzzy expert systems and fuzzy reasoning, John Wiley & Sons, Inc., ISBN 0-471-38859-9, 2005.

[2] - Kantrowitz, M., Horstkotte, E., Joslyn, J.,"FAQ: Fuzzy Logic and Fuzzy Expert Systems 1/1", , March 1997

[3] - Looney, C. G.,"Fuzzy Rules and Approximate Reasoning.", ,January 2004

[4] - Gehrke, M; Walker, Cl; Walker, E., "A mathematical setting for fuzzy logics. ", Internat. J. Uncertain. Fuzziness Knowledge-Based Systems5 (1997), no. 3, 223--238.

[5] – Zhang, W (Aptronix Inc.), "Controller for washing machine", , July 1992

APPENDIXA: Implementation of the fuzzy expert system for a fuzzy washing machine.

1. Define membership functions:

Degree of dirtiness (Dd) = {Low, Medium, High}=

Type of dirt (Dt) = {Not greasy, Medium greasy, Greasy}=

Duration of the wash cycle (Wd) = {Very short, Short, Medium, Long, Very long}=

The function definitions for the input and output membership functions:

Figure 1: Plots of the membership functions for the inputs

Figure 2: Plot of membership functions of the output.

3. Working of the expert system for randomly selected set of inputs:

  • Let Dd = 8 and Dt = 4.
  • Fuzzify the inputs, i.e. determine the membership values in each of the 6 membership functions for both inputs. The values for the given inputs are
  • Generate the truth values of the consequents of the 9 rules. For the current inputs, the inferred values are,

Rule 1: If degree of dirtiness is High and type of dirt is Greasy, then duration of wash cycle is Very long =

Similarly for the other rules,

Rule 2:

Rule 3:

Rule 4:

Rule 5:

Rule 6:

Rule 7:

Rule 8:

Rule 9:

  • The new membership values are compared point wise to the original membership functions to get the following modified output membership functions denoted by a superscript m.

Figure 3: New output membership functions after inferencing

  • The new membership functions generated by inferencing are now combined to form a single membership function for the output duration of wash cycle. For this max composition is used. In this all the newly generated membership functions are combined with each other using the fuzzy OR and the maximum possible membership value is chosen for each output value. The final function is defined as,