AN ALGORITHM FOR APPROXIMATING VALIDITY FUNCTIONS by Phillip F. Smith Submitted in Partial Fulfillment of the Requirements for the Degree of Master of Science in the Mathematics and Computer Science Program Date Dean of the 07, Date YOUNGSTOWN STATE UNIVERSITY December, 1987 ii ABSTRACT AN ALGORITHM FOR APPROXIMATING VALIDITY FUNCTIONS Phillip F. Smith Master of Science Youngstown State University, 1987 In this thesis, an algorithm is presented for the approximation of validity functions. It can be applied to approximate logical entailment in uncertain knowledge bases and is practical even if the knowledge base is large. In the process of developing the algorithm, several interesting results concerning validity functions are shown. A directed graph is used to conceptualize both the knowledge base and the behavior of the algorithm. Finally, this graph indicates a method for estimating conditional validities. iii ACKNOWLEDGEMENTS I wish to thank my research advisor, Dr. Santos, and Dr. Burden and Dr. Schueller for reading this thesis. I also would like to express my thanks to Dr. Faires for his help in many ways. iv TABLE OF CONTENTS PAGE ABSTRACT .... ii Remarks Procedure Three Procedure One Procedure Two 1 4 4 7 10 10 11 11 12 15 17 19 21 24 26 53 71 iv iii Sample Knowledge Bases Source Code for ENTAIL CONCLUSION . . . . V. EMPIRICAL STUDIES Procedure Four . Introduction to the Algorithm Initial Procedure validity Functions VI. IV. APPROXIMATING CONDITIONAL VALIDITY II. PRELIMINARIES III. ALGORITHM ENTAIL .. BIBLIOGRAPHY APPENDIX A. APPENDIX B. ACKNOWLEDGEMENTS TABLE OF CONTENTS CHAPTER I. INTRODUCTION. 1 CHAPTER I INTRODUCTION In the last several years, much interest has developed in trying to incorporate into knowledge based systems the ability to use and manipulate uncertain information. This is expecially true in the field of "expert systems." Very seldom does an expert have complete information or know all data with certainty. Thus, a great need arose for researchers to address this problem and since then the field has flourished. One of the first AI systems to include methods for dealing with uncertainty was MYCIN,1 a medical diagnosis system which used certainty factors. Many other techniques have since been developed and are based on a variety of concepts: 2 3 Bayes rule, Schafer-Dempster theory, logic of likelihood,4 fuzzy reasoning,5 "probabilistic logic",6 and others. 1E . H. Shortliffe, Computer Based Medical Consultations: MYCIN (New York: Elsevier, 1976). 2R. O. Duda, P.E. Hart, and N.J. Nilsson, "Subjective Bayesian Methods for Rule-base Inference Systems," in: Proceedinqs 1976 National Computer Conference, AFIPS 45 (1976) pp. 1075-1082. 3G. A. Schafer, Mathematical Theory of Evidence (Princeton: Princet~nUniversity Press, 1979). J.Y. Halpern and M.O. Rabin, "A Logic to Reason About Likelihood," Artificial Intelligence, 32 (1987) pp. 379-405. 5 L.A. Zadeh, "Fuzzy Logic and Approximate Reasoning," Synthese, 30(1975) pp. 407-428. 6 N.J. Nilsson, "Probabilistic Logic," Artificial Intelligence, 28 (1986) pp. 71-87 . 2 The main objective of a knowledge based system is general logical entailment: Given a.sentence S and a knowledge base~,what is the truth value of S (probability of S, belief value of S, etc.) based on , "V? h" '1 7 h d' the 1nformat1on 1n~.One approac 1S glven by N1 sson w 0 1scusses construction of a large matrix M used in the "probabilistic entailment" of S. Given M, linear programming can be used to determine the probability bounds of S. However, M can have dimensions, in general, n o 2 n (where n is the number of sentences in the knowledge base) which makes linear programming applicable only when the the knowledge base is very small. Even the construction of M itself is very difficult and time-consuming. Most of the other approaches mentioned share this same problem of being impractical for a realistic knowledge base. Clearly, an alternate approach is needed. In this thesis, an algorithm will be presented which provides approximate bounds for the entailment of a sentence S, given a consistent knowledge base~(even if~is large). The knowledge base is restricted to contain only sentences which are minterms (conjunctions of atomic propositions or their negations). This is not a severe restriction since many knowledge bases could be expressed in this form. Also, it will be clear that the techniques presented could be modified to apply to more generalized knowledge bases. The algorithm is based on results from validity functions in Santos. 8 A directed graph is used to conceptualize the knowledge base and 7 , 9 N1lsson, pp. 75-7. 8E . S . Santos and E. Santos Jr., "Reasoning With Uncertainty in a Knowledge Based System," in: Proceedings the Seventeenth International Symposium on Multiple-Valued Logic, (May 1987) pp. 75- 81. 3 information inferred through the algorithm. A study of the graph then indicates how the algorithm can estimate conditional validities. 4 CHAPTER II PRELIMINARIES Validity Functions The symbols -, v, A, --1, =, V, 3, c, :J, n, u, E, T and F will denote, respectively, negation, disjunction, conjunction, implication, equivalence, for every, there exists, subset, superset, intersection, union, member, true, and false. * * Let~be a collection of atomic propositions.~(~),or~, * denotes the set of all finite sentencesover~.~ciis a knowledge base if~is finite. * Let v be a function from~into [0,1], the closed unit interval. v is a validity function if and only if v satisfies the following conditions: (2) v(T) = 1, v(F) = 0; v(S) may be viewed as the probability that S is true, the. certainty factor of S, the belief value of S, or any other appropriate interpretation. Theorem 1 Let v be a validity function. Then (a) v(-S) 1-v(S), Proof. 9 See Santos. 5 * Let~k~. A.function f from~into [0,1] is extensible if and only if there exists a validity function v such that v(S)=f(S) for all S E~.v is called an extension of f. A function g from~into 2[0,1], the power set of [0,1], is extensible if and only if there exists a validity function v such that v(S) E g(S) for all S E~.v is called an extension of g. g is a generalization of f. The functions f and g represent two ways of specifying what is known about the sentencesin~.Clearly, f signifies more complete knowledge of~than does g. If S E~and f is given, there is full knowledge of S because v(S)=f(S). If g is given then there is only partial knowledge of S since v(S) E g(S). Given Se, a sentence to be entailed (Se~~),it is, in general, not possible to determine the validity of Se uniquely but only up to a certain bound. obvious if g is given but also holds for f as well.) (This is Define V(g,Se) = {v(Se) : v is an extension of g}. + Let v (g,Se) - lub V(g,Se) and v (g,Se) glb V(g,Se). - + V (g,Se) and v (g,Se) are called the lower and upper validity, respectively. - + [v (g,Se),v (g,Se)] is the bound mentioned above and is the interval of consistent values for V(Se). + If v (g,Se) = V (g,Se) then Se is uniquely entailed by~ with respect to g. 9 Santos and Santos, p. 4. 6 + In the rest of this discussion, v (g,S) and v (g,S) will be + denoted v (S) and v (S). The function g is implied and assumed to be given with the knowledge base. * * Let X(~),or X , denote the set of all finite mintermsover~. * X c X is a restricted knowledge base if X is finite. * Suppose Se E X is the sentence to be entailed (Se~X). av (Se) + and av (Se) will be used to denote the approximate lower and upper validity of Se calculated by the ensuing algorithm. It should be - - + + noted that av(Se)~V(Se)~V(Se)~av(Se). (1) That is, the approximate upper and lower validity will approach the actual upper and lower validity always from the outside. This is extremely important. If an approximate bound [a,b] is found but it is - + not known whether [v (Se), v (Se)]~[a,b], then the bound is not helpful. In fact, many approximations just find some single point value c E [0,1]. Clearly, that is not nearly as meaningful as (1). Finally, X will be used to refer to a (restricted) knowledge base in o * general; X eX, called the original knowledge base, refers to a specific set of sentences along with their associated validities; w * X eX, called the working knowledge base, refers to the sentences "created" by the algorithm as it tries to entail Se (the sentence of . . v o . lnterest), glven "'- (Note: X W n X O = ¢.) X W also includes the- current approximate upper and lower validity associated with each sentence in X w . 7 Introduction to the Algorithm The algorithm that will be discussed is called ENTAIL. Its general workings are as follows: Given a knowledge base X O and Se, the sentence to be entailed, ENTAIL calls four procedures, each with - + distinct goals in trying to approximate v (Se) and v (Se). When ENTAIL is finished, it returns aV-(Se) and av+(Se), the approximate lower and upper validity for Se. Sometimes information can be inferred directly o from X . Usually, however, these procedures recursively call ENTAIL with a new sentence, Sei, to be entailed. (This is somewhat similar to backward-chaining theorem provers where given an initial goal, new subgoals are continually derived until one is proven true.) The entailing of this 'new' sentence Sei will cause ENTAIL to be called recursively with even more sentences which in turn will do the same. ENTAIL can be viewed as constructing and then traversing a directed * tree-like graph where each vertex corresponds to a sentence. Let V be * * a set of vertices such that there exists a function t:X~Vwhere t * * is onto and one-to-one. Therefore, V SEX t(S)EV . Define a graph * G=(V,E) where vev and E is a set of directed edges. V = {t(S): S E X O w or SEX}. In other words, V contains vertices which correspond to every sentence in both the working knowledge base and the original knowledge base. (jl,j2) E E implies that the sentence S2=t 1 (j2) was used in entailing the sentence SI=t (jl)' Specifically, it does not mean that S2 did affect the validity of SI' but rather that it could have affected it. (This will be important later when discussing the approximation of conditional validities.) 8 Suppose that the sentence being entailed is Se=AABACAD and that both Sl=AAB and S2=CAD were entailed directly because of Se. In turn, assume that both S3=-AAB and S4=A were entailed while working on Sl. This could be viewed as the graph in figure 1. Fig. 1.--Graphical representation of the partial entailment of Se It is evident that ENTAIL traverses the graph in a depth-first order. Thus, some means must be provided to prevent ENTAIL from diving indefinitely. This is accomplished with a parameter called LEVEL. The value of LEVEL is the maximum depth that ENTAIL is allowed to reach. This is implemented by decrementing the value of LEVEL every time a recursive call to ENTAIL is made. For example, if ENTAIL is called with sentence Sl and LEVEL=4, denoted ENTAIL(Sl,4), and S2 is now entailed, the LEVEL parameter for S2 will be equal to 3 (ENTAIL(S2,3)). Clearly, at some point a sentence Si will be entailed with LEVEL=O. When this occurs, ENTAIL will not try to entail the - + sentence at all, but rather will return av (Si)=O and av (Si)=l, meaning that nothing is known about Si. Two more points need to be made before discussing the algorithm in detail. If ENTAIL is called with the sentence Sand S E~o(S is part of the original knowledge base) then the algorithm will not try to - + + entail S but will simply return av (S)=v (S) and av (S)=v (S). (The values returned are the given validities for S.) This means that S E~o --73 jlEV such that (j,jl)E E where j=t(S). (t(S) will have no 9 children.) Vertices in the sett(~o)={t(S):S E~o}are called anchor vertices. No edges originate from them. Edges can only terminate there. Also, all information inferred form the traversal of the graph is ultimately dependent on the sentences in~owhich correspond with o the sett(~). Secondly, what if ENTAIL is called with sentence S but S has already been enatiled? Should the approximate validities calculated previously be returned, or should S be entailed again? This question is handled by making use of the value of the LEVEL parameter. Suppose S had already been entailed with LEVEL=5 and now it is to be entailed with LEVEL=4. Clearly, there is no need to entail S any further for the depth of the subgraph rooted at t(S) is greater than what is needed. (The subgraph rooted at t(S) is the subgraph traversed while entailing S.) For j E V, let L(j) denote the value of the LEVEL parameter used in entailing S=t-l(j). Suppose L(t(S»=2 and ENTAIL is called with sentence S again and LEVEL=4. It would not make much sense to return the current approximate validity of S because LEVEL=4 implies that more effort should be expended in entailing S than has already been done. Therefore, the subgraph rooted at t(S) is extended (to a depth of four) and the approximate upper and lower validity is updated. The fact that a sentence S can be entailed more than once indicates that t(S) can have many parents and therefore the graph G cannot be a tree. 10 CHAPTER III ALGORITHM ENTAIL The algorithm is divided into five procedures: an initial and four main. It is assumed the algorithm was invoked as ENTAIL(Se,LEVEL) . Initial Procedure Let Pe denote a parent sentence of Se. (More accurately, Pe is a sentence whose entailment resulted in the current entailing of Se.) v o - - + + if Se E~then return av (Se)=v (Se) and av (Se)=V (Se) if Se E X W (Se has already been entailed) then do + ifL(Se)~LEVELthen return av (Se) and av (Se) (calculated previously) else do set L(Se) :=LEVEL goto PROCEDURE ONE end do end do + if LEVEL=O then return av (Se)=O and av (Se)=l add t(Se) to V add Se to X W L (t (Se)) :=LEVEL goto PROCEDURE ONE (Se has never been entailed.) 11 Procedure One This procedure uses disjoint sentences to reduce the value of av+ (Se). Let K P 1 = {S E X O : SI\Se = F}. K P 1 contains all sentences in X O which are disjoint with Se. Clearly, v+(Se)~1- v (S) v o . Suppose Se = Al\B, Sl = -AI\C, S2 = -BI\-C, and Sl,S2 E~Se is disjoint with both Sl and S2. However, Sl and S2 are also disjoint. + - - Therefore, v (Se)=l-(v (Sl)+V (S2)). Based on this idea, procedure one searches for a subset K S1 of K P1 in which every sentence in K S1 is disjoint with every other sentence in K S1 and the subset is maximum with respect to the sum of the lower validities of each sentence in K S1 is not necessarily a unique set. This does not matter, though, because what is important is not what K S1 contains but rather the value of the maximum sum (v-(K S1 )) mentioned above. The search for K S1 can be thought of as being over all subsets of K P1 . In actuality, some simple heuristics are used to shorten this search. However, the worst case complexity of this search is d! where d is the size of K P1 . It should be noted that procedure one does not entail any new sentences. It works directly with information in X o . Procedure Two Let K P2 = {S E X O : S~Se}. For any S E K P2 there exists a sentence denoted (S-Se) which has no atoms in common with Se and such 12 that SeA(S-Se) = S. Call ENTAIL((S-Se),LEVEL-1). It is obvious that - - V(Se)~V(S). Set av(Se)~V(S). For the upper validity, the following theorem can be used: Theorem 2 + + V (Se) $; 1 - v ((S-Se)) + v (S) (2) ~V(Se)+ viiS-Sell - 1 $; V(SeA(S-Se)) v(S) ~V(Se)$; 1 + v(S) - v((S-Se)) (Theorem 1) Since v is arbitrary, =>:3 Va (a specific validity function) + such that v (Se)$; 1 + va (S) - va ((S-Se)) + - $; 1 + v (S) - v ((S-Se)) 0 + + Thus, set av (Se) $; 1 - av ((S-Se)) + v (S). o + 0 For example, suppose Se=AAB, Sl=AABAC EX, v (Sl)=.5, and SlEX . (3) - entailed and assume it returns av (C)=.6. Equation (3) then yields + av (Se)$; 1 - .6 +.5 .9. Procedure two also uses another technique in approximating lower validities. o 0 Suppose Se=AAB, Sl=AABADAE EX, S2=AABA-D EX, - V (Se)~v (Sl)=.3 and v (Se)~v (S2)=.4. But Sl and S2 are disjoint. - - Therefore, v (Se)~v (Sl) + v (S2) = .3 + .4 = .7. In a similar manner as in procedure one, procedure two searches for a subset K S2 of K P2 in which every S E K S2 is disjoint with every other S E K S2 and Procedure Three Let K P3 = {s E X O : 3 S' such thatS'~Se,S'~,and S'fT}. K P3 contains all sentences in X O which share at least one common atom with 13 Se. If S E K P3 , let c(S) denote the sentence comprised of all atoms that Sand Se havei~common. For example, if S=AABAC and Se=AACADAE then c(S)=AAC. Let K C = {c(S) S E K P3 }. For every Sc E K C , call ENTAIL(Sc,LEVEL-l) . Clearly, Sc E K C . . + + lmplles v (Se)~v (Sc) and thus + + set av (Se)~V (Sc). Let Sl' S2' ... , Sn c E K such that SlAS2A...ASn C Se. ( 4) Theorem 3 Given that (4) is true, - - - - V (Se)~v (Sll+v (S2)+...+v (Sn) - (n-l). (5) Proof. (Via mathematical induction) For proof when n=2 see 10 Santos. Assume true for n0 THEN DO; SNUM-li IF NOL>LEVEL(SNUM) THEN DO; PUT FILE(OUT) EDIT ( 'ENTAJ:L ',SENT(SNUM) ,NOL, 'DO MORE') (COL(SP) ,A,A,F(3) ,X(3) ,A) ; LEVEL(SNUM)-NOL; GOTO REDO; ENDi PUT FILE (OUT) EDIT ( 'ENTAIL ' , SENT (SNUM) , 'ALREADY DONE') (COL(SP) ,A,A,A) i LB-BOUNDS (SNUM) •LOWER; UB-BOUNDS(SNUM).UPPER; RETURN; END; IF NOL-O THEN DO; LB-Oi UB-li SNUM-O; RETURN; ENT00010 ENT00020 ENT00030 ENT00040 ENT00050 ENT00060 ENT00070 ENTOOOSO ENT00090 ENT00100 ENTOOllO ENT00120 ENT00130 ENT00140 ENT00150 ENT00160 ENT00170 ENT001SO ENT00190 ENT00200 ENT00210 ENT00220 ENT00230 ENT00240 ENT00250 ENT00260 ENT00270 ENT002S0 ENT00290 ENT00300 ENT00310 ENT00320 ENT00330 ENT00340 ENT00350 ENT00360 ENT00370 ENT003S0 ENT00390 ENT00400 ENTOOUO ENT00420 ENT00430 ENT00440 ENT00450 ENT00460 ENT00470 ENT004S0 ENT00490 ENT00500 ENT00510 ENT00520 ENT00530 ENT00540 ENT00550 ENT00560 ENT00570 ENT005S0 ENT00590 Elt"T00600 59 END: SNUM-CREATES(S,NOL): PUT FILE(OUT) EDIT('ENTAIL ',SENT(SNUM),NOL) (COL(SP),A,A,F(3»: REDO: SP-SP+1: DO 1-1 TO (SP-1) BY 10: PUT FILE(OUT) EDIT(']') (COL(I),A): END: PUT FILE(OUT) EDIT('El') (COL(SP),A): CALL ENTAILl (SNUM) : DO I-1 TO (SP-1) BY 10: PUT FILE(OUT) EDIT(']') (COL(I),A): END: PUT FILE(OUT) EDIT('E3') (COL(SP),A): CALL ENTAIL3(SNUM,NOL,AVAIL,S): DO I-1 TO (SP-1) BY 10: PUT FILE(OUT) EDIT(']') (COL(I),A): END: PUT FILE(OUT) EDIT('E4') (COL(SP),A): CALL ENTAIL4(SNUM,NOL,AVAIL,S): DO I-1 TO (SP-1) BY 10: PUTFI~(OUT)EDIT(']') (COL(I),A): END: PUT FILE(OUT) EDIT('E6') (COL(SP),A): CALL ENTAIL6(SNUM,NOL,S) : LB-BOUNDS(SNUM).LOWER: UB-BOUNDS(SNUM).UPPER: SP-SP-1: DO I-1 TO (SP-1) BY 10: PUT FILE(OUT) EDIT(']') (COL(I) ,A): END: PUT FILE(OUT) EDIT(SENT(SNUM), '(',LB, " ',UB, ') ') (COL(SP) ,A(20) ,A,F(8,4) ,A,F(8,4) ,A): RETURN: END ENTAIL: 60 ENT00610 ENT00620 ENT00630 ENT00640 ENT00650 ENT00660 ENT00670 ENT00680 ENT00690 ENT00700 ENT00710 ENT00720 ENT00730 ENT00740 ENT00750 ENT00760 ENT00770 ENT00780 ENT00790 ENT00800 ENT00810 ENT00820 ENT00830 ENT00840 ENT00850 ENT00860 ENT00870 ENT00880 ENT00890 ENT00900 ENT00910 ENT00920 ENT00930 ENT00940 ENT00950 CREATES: PROC(S,NOL) RETURNS (FIXED BIN(31»; DCL (I,NOL) FIXED BIN(31), CH CHAR(l), MT CHAR(20) VAR INIT("), HASH CHAR(26) INIT('ABCDEFGHIJKLMNOPQRSTUVWXYZ'); DCL 1 S(*), 2 ATOM FIXEDBIN(~l), 2 VALUE FIXED BIN(31): DCL 1 GB EXT, 2 KNB(500,26), 3 VALUE FIXED BIN(31), 3 NEXTS FIXED BIN(31), 3 NEXTA FIXED BIN(31), 2 LEVEL(500) FIXED BIN(31), 2 SENT(500) CHAR(20), 2 STARTA(26) FIXED BIN(31), 2 ENDA(26) FIXED BIN(31), 2 STARTS (500) FIXED BIN(31), 2 LASTSENT FIXED BIN(31), 2 BOUNDS(500), 3 UPPER FLOAT(6), 3 LOWER FLOAT (6) , 2 ORIGSENT FIXED BIN(31), 2 NUMLEVEL FIXED BIN(31) ; LASTSENT-LASTSENT+l: STARTS(LASTSENT)-S(l).ATOM: I-l: DO WHILE(S(I).ATOMA-O): IF ENDA (S (I) •ATOM) -0 THEN DO: STARTA(S(I).ATOM)-LASTSENT: ENDA(S(I).ATOM)-LASTSENT: END: ELSE DO: KNB(ENDA(S(I).ATOM),S(I).ATOM).NEXTS-LASTSENT; ENDA(S(I).ATOM)-LASTSENT; END: KNB(LASTSENT,S(I).ATOM).NEXTA-S(I+l).ATOM: KNB(LASTSENT,S(I) .ATOM).VALUE-S(I).VALUE; KNB (LASTSENT ,S (I) •ATOM) •NEXTS-O ; CH-SUBSTR(HASH,S(I).ATOM,l) ; MT-MTJ JCH: IF S(I).VALUE--l THEN MT-MTJ) 'A'; I-I+l: END; LEVEL(LASTSENT)-NOL; BOUNDS(LASTSENT).LOWER-O: BOUNDS(LASTSENT).UPPER-l: SENT (LASTSENT)-MT: RETURN (LASTSENT) : END CREATES: CRE00010 CRE00020 CRE00030 CRE00040 CRE00050 CRE00060 CRE00070 CRE00080 CRE00090 CRE00100 CREOOllO CRE00120 CRE00130 CRE00140 CRE00150 CRE00160 CRE00170 CRE00180 CRE00190 CRE00200 CRE00210 CRE00220 CRE00230 CRE00240 CRE00250 CRE00260 CRE00270 CRE00280 CRE00290 CRE00300 CRE00310 CREOOnO CRE00330 CRE00340 CRE00350 CRE00360 CRE00370 CRE00380 CRE00390 CRE00400 CRE00410 CRE00420 CRE00430 CRE00440 CRE00450 CRE00460 CRE00470 CRE004jO CRE00490 CRE00500 CRE00510 CRE00520 CRE00530 61 ENTAIL1: PROC(SNUH); /* CORRESPONDS TO PROCEDURE ONE */ DCL (SNUH,K;J,I,LISTPTR,LAST2,LIST(ORIGSENT» FIXED BIN(:31), LIST2(ORIGSENT) FIXED BIN(:31), (ONLIST(ORIGSENT) ,FLAG) BIT(l), UPDATE ENTRY EXT, (SUM, HOLD) FLOAT(6); DCL 1 GB EXT, 2 KNB(SOO,26), :3 VALUE FIXED BIN(:31), :3 NEXTS FIXED BIN(:31), :3 NEXTA FIXED BIN(:31), 2 LEVEL(SOO) FIXED BIN(:31), 2 SENT(SOO) CHAR(20), 2 STARTA(26) FIXED BIN(:31), 2 ENDA(26) FIXED BIN(:31), 2 STARTS(SOO) FIXED BIN(:31), 2 LASTSENT FIXED BIN(:31), 2 BOUNDS(SOO), :3 UPPER FLOAT(6), :3 LOWER FLOAT(6), 2 ORIGSENT FIXED BIN(:31), 2 NUHLEVEL FIXED BIN(:31); LISTPTR-O; SUM-O; ONLIST-'O'B; J-STARTS(SNUH); DO WHILE (J"-O) ; K-STARTA (J) ; DO WHILE«K"-O)&(K<-oRIGSENT»; IF (KNB(K,J) .VALUE"-O)&(KNB(K,J).VALDE"-KNB(SNUH,J) .VALUE) &("ONLIST (K) ) THEN DO; LISTPTR-LISTPTR+1; LIST (LISTPTR) -K; ONLIST(K)-'l'B; END; K-KNB(K,J).NEXTS; END; J-KNB(SNUH,J).NEXTA; END; FLAG-'O'B; LAST2-0; I-l; DO WHILE«LAST2"-O») (I<-LISTPTR» ; DO WHILE (I<-LISTPTR) ; IF DIFF (LIST (I» THEN DO; FLAG-'l'B; LAST2-LAST2+1; LIST2 (LAST2) -I; END; I-I+l; END; HOLD-O; IF FLAG THEN DO; FLAG-'O'B; DO J-l TO LAST2; HOLD-HOLD+BOUNDS(LIST(LIST2(J»).LOWER; END; ENT00010 ENT00020 ENT00030 ENT00040 ENT00050 ENT00060 ENT00070 ENT00080 ENT00090 ENT00100 ENTOOllO ENT00120 ENT00130 ENT00140 ENT00150 ENT00160 ENT00170 ENT001SO ENT00190 ENT00200 ENT00210 ENT00220 ENT00230 ENT00240 ENT00250 ENT00260 ENT00270 ENT002S0 ENT00290 ENT00300 ENT00310 ENT00320 ENT00:330 ENT00340 ENT00350 ENT00360 ENT00370 ENT003S0 ENT00390 ENT00400 ENT00410 ENT00420 ENT00430 ENT00440 ENT00450 ENT00460 ENT00470 ENT004S0 ENTO'0490 ENT00500 ENT00510 ENT00520 ENT00530 ENT00540 ENT00550 ENT00560 ENT00570 ENT005S0 ENT00590 ENT00600 62 END: IF HOLD>SUM THEN SUM-HOLD: I-LIST2(LAST2)+1: LAST2-LAST2-1; END; SUM-1-SUM; HOLD-O; CALL UPDATE (SNUH,HOLD, SUM) ; RETURN: DIFF: PROC (A) RETURNS(BIT(l»; DCL (A,B,C,Z) FIXED BIN(31), FLAG BIT (1) : DO Z-l TO LAST2: B-LIST(LIST2(Z»: C-STARTS (A) : FLAG-'O'B: DO WHILE«CA-O)&(AFLAG»: IF KNB(A,C).VALUE-«-l)*KNB(B,C).VALUE) THEN FLAG-'l'B: C-KNB(A,C) .NEXTA: END: IF AFLAG THEN RETURN('O'B); END: RETURN('l'B) : END DIFF: END ENTAILl.: ENT00610 ENT00620 ENT00630 ENT00640 ENT00650 ENT00660 ENT00670 ENT00680 ENT00690 ENT00700 ENT00710 ENT0072 0 ENT00730 ENT00740 ENT00750 ENT00760 ENT00770 ENT00780 ENT00790 ENT00800 ENT00810 ENT00820 ENT00830 ENT00840 ENT00850 ENT00860 63 ENTAIL3: PROC (SNUM,NOL,AVAIL, S) RECURSIVE: /* CORRESPONDS TO */ DCL (SNUM,NOL,I,SN,J,K,LASTS) FIXED BIN(31), /* PROCEDURE TWO */ AVAIL(*) BIT(l), (TEHP,UB,LB) FLOAT(6), (TRY(ORIGSENT),FLAG) BIT(l): DCL UPDATE ENTRY EXT, ENTAIL ENTRY EXT: DCL 1 S(*), 2 ATOM FIXED BIN(31), 2 VALUE FIXED BIN(31): DCL (LISTPTR,LAST2,LIST(ORIGSENT» FIXED BIN(31), LIST2(ORIGSENT) FIXED BIN(31), (SUM, HOLD) FLOAT(6): DCL 1 GB EXT, 2 KNB(500,26), 3 VALUE FIXED BIN(31), 3 NEXTS FIXED BIN(31), 3 NEXTA FIXED BIN(31), 2 LEVEL(500) FIXED BIN(31), 2 SENT(500) CHAR(20), 2 STARTA(26) FIXED BIN(31), 2 ENDA(26) FIXED BIN(31), 2 STARTS(500) FIXED BIN(31), 2 LASTSENT FIXED BIN(31), 2 BOUNDS (500) , 3 UPPER FLOAT(6), 3 LOWER FLOAT(6), 2 ORIGSENT FIXED BIN(31), 2 NUMLEVEL FIXED BIN(31): LISTPTR-O: TEHP-O: TRY-'O'B: I-STARTS (SNUM) : DO WHILE(IA-O) : J-STARTA (I) : DO WHILE«JA-O)&(J<-oRIGSENT»: IF (AVAIL(J»&(ATRY(J» THEN DO: X-STARTS(SNUM): TRY(J)-'l'B: FLAG-'O'B; DO WHILE«XA-O)&(AFLAG»: IF KNB(J,X).VALUEA-KNB(SNUM,X).VALUE THEN FLAG-'l'B: X-KNB(SNUM,X) .NEXTA: END: IF AFLAG THEN DO: K-STARTS (J) : LASTS-O: AVAIL(J)-'O'B: DO WHILE (XA_O) : IF KNB (SNUM, X) •VALUE-O THEN DO: LASTS-LASTS+1 ; S(LASTS).VALUE-KNB(J,X).VALUE: S (LASTS) •ATOM-X: S(LASTS+l).ATOM-O; END: X-KNB(J,X).NEXTA: END; L!STPTR-LISTPTR+l; 64 ENT00010 ENT00020 ENT00030 ENT00040 ENT00050 ENT00060 ENT00070 ENT00080 ENT00090 ENT00100 ENTOOllO ENT00120 ENT00130 ENT00140 ENT00150 ENT00160 ENT00170 ENT00180 ENT00190 ENT00200 ENT00210 ENT00220 ENT00230 ENT00240 ENT00250 ENT00260 ENT00270 ENT00280 ENT00290 ENT00300 ENT00310 ENT00320 ENT00330 ENT00340 ENT00350 ENT00360 ENT00370 ENT00380 ENT00390 ENT00400 ENT00410 ENT00420 ENT00430 ENT00440 ENT00450 ENT00460 ENT00470 ENT00480 ENT00490 ENT00500 ENT00510 ENT00520 ENT00530 ENT00540 ENT00550 ENT00560 ENT00570 ENT00580 ENT00590 ENT00600 LIST (LISTPTR) -J: CALL ENTAIL(S,NOL-l,LB,UB,SN): UB-l-LB+BOUNDS(J).UPPER: LB-BOUNDS(J).LOWER; CALL UPDATE (SNUH, LB, UB) ; END: END; JYKNB(J,I).NEXTS; END; I-KNB(SNUH,I).NEXTA; END: SUM-a: FLAG-'O'B; LAST2-0; I-l: DO WHILE((LAST2 A -O») (I<-LISTPTR»: DO WHILE (I<-LISTPTR) ; IF DIFF(LIST(I» THEN DO: FLAG-'l'B; LAST2-LAST2+1: LIST2(LAST2)-I; END: I-I+l; END; HOLD-O; IF FLAG THEN DO; FLAG-'O'B; DO J-l TO LAST2; HOLD-HOLD+BOUNDS(LIST(LIST2(J»).LOWER; END; END; IF HOLD>SUM THEN SUM-HOLD: I-LIST2(LAST2)+1: LAST2-LAST2-1: END: HOLD-l: CALL UPDATE (SNUH, SUM, HOLD) : RETURN: DIFF: PROC (A) RETURNS(BIT(l»: DCL (A,B,C,Z) FIXED BIN(31), FLAG BIT(l): DO Z-l TO LAST2: B-LIST(LIST2(Z» : C-STARTS (A) : FLAG-'O'B: DO WHlLE((CA-O)&(AFLAG»: IF KNB(A,C).VALUE-((-l)*KNB(B,C).VALUE) THEN FLAG-' l'B: C-KNB(A,C).NEXTA; END: IF AFLAG THEN RETURN ( '0' B) : END: RETURN ( '1 'B) : END DIFF: END ENTAIL3: ENT006l0 ENT00620 ENT00630 ENT00640 ENT00650 ENT00660 ENT00670 ENT00680 ENT00690 ENT00700 ENT00710 ENTOOnO ENT00730 ENT00740 ENT00750 ENT00760 ENT0077 0 ENT00780 ENT00790 ENT00800 ENT008l0 ENT00820 ENT00830 ENT00840 ENT00850 ENT00860 ENT00870 ENT00880 ENT00890 ENT00900 ENT00910 ENT00920 ENT00930 ENT0094 0 ENT00950 ENT00960 ENT00970 ENT00980 ENT00990 ENT01000 ENT01010 ENT01020 ENT01030 ENT01040 ENT01050 ENT01060 ENT01070 ENT01080 ENT01090 ENTOllOO ENTO 1110 ENTOl120 ENT01l30 ENTOl140 ENT01l50 ENTOl160 65 ENTAIL4: PROC (SNUM, NOL, AVAIL, S) RECURSIVE; /* CORRESPONDS TO PROCEDURE THREE */ DCL (SNUM,NOL,SN,I,J,K,LASTS,LIST(ORIGSENT),LASTL,LIST2(ORIGSENT), LISTJ(ORIGSENT),LAST2) FIXED BIN(31), AVAIL(*) BIT (1) , (JUB,LB,UB,TEMP) FLOAT (6) ; DCL ENTAIL ENTRY EXT, UPDATE ENTRY EXT, FIND ENTRY EXT RETORNS(FIXED BIN(31»; DCL 1 S(*), 2 ATOM FIXED BIN(31), 2 VALUE FIXED BIN(31); DCL 1 GB EXT, 2 KNB(SOO,26), 3 VALUE FIXED BIN(31), 3 NEXTS FIXED BIN(31), :3 NEXTA FIXED BIN(31), 2 LEVEL(SOO) FIXED BIN(31), 2 SENT(SOO) CHAR(20), 2 STARTA(26) FIXED BIN(31), 2 ENDA(26) FIXED BIN(31), 2 STARTS(SOO) FIXED BIN(31), 2 LASTSENT FIXED BIN(31), 2 BOUNDS(SOO), 3 UPPER FLOAT(6), :3 LOWER FLOAT (6) , 2 ORIGSENT FIXED BIN(31) , 2 NUMLEVEL FIXED BIN(31); LASTL-O; 1-STARTS(SNUM); DO WHILE (1"-0) ; J-STARTA(I) ; DO WHILE«J"-O)&(J<-oRIGSENT»; IF AVAIL(J) THEN DO; K-STARTS (J) ; LASTS-O; AVAIL(J)-'O'B; DO WHILE (K"-O) ; IF KNB(SNUM,K).VALUE"-O THEN DO; LASTS-LASTS+1 ; S (LASTS) .ATOM-K; S(LASTS).VALUE-KNB(SNUM,K).VALUE; S(LASTS+1).ATOM-O; END; K-KNB(J,K).NEXTA; END; SN-FIND (S) ; IF SN-O THEN CALL ENTAIL(S,NOL-1,LB,UB,SN); IF SN>O THEN CALL ADDLIST (SN ;J) ; END; J-KNB(J,I).NEXTS; END; 1-KNB(SNUM,I) .NEXTA; END; UB-l; DO 1-1 TO LASTL; IF BOUNDS(LIST(I».UPPER LB THEN LB-TEMP; IF SAME THEN DO; JUB-SHARE r TEHP-O; DO J-1 TO LAST2r TEHP-TEMP+BOUNDS(LISTJ(LIST2(J») •LOWER; ENDr TEHP-TEMP-(LAST2-1)*JUBr IF TEMP>LB THEN LB-TEMP; ENDr LAST2-LAST2-1; ENDr ELSE DOr I-LIST2(LAST2)+lr LAST2-LAST2-1; ENDr ENDr CALL UPDATE (SNUM, LB, OB) r RETURNr SAME: PROC RETORNS(BIT(l»; DCL (Z,I) FIXED BIN(31)r Z-STARTS(SNUM)r DO WHILE (Z"'-O) ; DO I-1 TO LAST2; IF KNB(LISTJ(LIST2(I»,Z).VALOE-(-1)*KNB(SNOM,Z).VALOE THEN RETURN ( '0 'B) ; ENDr Z-KNB(SNUM,Z).NEXTAr END; RETORN('l'B) r END SAMEr SHARE: PROC RETURNS (FLOM (6) ) r DCL (JLB,JOB) FLOAT (6) , (I,J,K) FIXED BIN(31), FLAG BIT (1) r X-Or I-STARTS(LISTJ(LIST2(1») r DO WHILE (I"'-O) r FLAG-'O'B: IF (KNB(SNUM,I).VALDE-O) THEN DOr ENT00610 ENT00620 ENT00630 ENT00640 ENT00650 ENT00660 ENT00670 ENT00680 ENT00690 ENT00700 ENT00710 ENT00720 ENT00730 ENT00740 ENT00750 ENT00760 ENT00770 ENT00780 ENT00790 ENT00800 ENT00810 ENT00820 ENTOOB30 ENTOOB40 ENTOOB50 ENT00860 ENTOOB70 ENTOOB80 ENTOOB90 ENT00900 ENT00910 ENT00920 ENT00930 ENT00940 ENT00950 ENT00960 ENT00970 ENT00980 ENT00990 ENT01000 ENT01010 ENT01020 ENT01030 ENT010'O ENT01050 ENT01060 ENT01070 ENT010BO ENT01090 ENTOllOO ENT01110 ENT01l20 ENTOl130 ENT01HO ENT01l50 ENTOl160 ENT01l70 ENTOllBO ENT01l90 ENT01200 67 DO J-2 TO LAST2 WHILE ("FLAG) ; IF (KNB(LISTJ(LIST2(J»,I) .VALUE " KNB(LISTJ(LIST2(1»,I).VALUE) THEN FLAG-'l'B; END; IF "FLAG THEN DO; K-K+l; S(K).ATOM-I; S(K).VALDE-KNB(LISTJ(LIST2(1»,I) .VALUE; END; END; I-KNB(LISTJ(LIST2(1»,I).NEXTA; END; S(K+l).ATOM-O; CALL ENTAIL(S,NOL-l,JLB,JUB,I); RETURN (JUB) ; END SHARE; ADDLIST: PROC(N,J); DCL (N,J) FIXED BIN(31); LASTL-LASTL+1 ; LIST (LASTL) -N; LISTJ (LASTL) -J; RETURN; END ADDLIST; COVERED: PROC(N) RETURNS(BIT(l»; DCL (M,N,A) FIXED BIN(31), FLAG BIT(l); A-STARTS (N) ; DO WHILE (A"-O) ; FLAG-'O'B; DO M-l TO LAST2 WHILE ("FLAG) ; IF KNB(LIST(LIST2(M»,A).VALDE-KNB(N,A).VALUE THEN FLAGa'l'B; END; IF "FLAG THEN RETURN ( , 0 ' B) ; A-KNB(N,A).NEXTA; END; RETURN('l'B) ; END COVERED; END ENTAIL4; ENT01210 ENT01220 ENT01230 ENT01240 ENT01250 ENT01260 ENT01270 ENT01280 ENT01290 ENT01300 ENTOl310 ENT01320 ENT01330 ENT01340 ENT01350 ENT01360 ENT01370 ENT01380 ENT01390 ENT01400 ENTOl410 ENT01420 ENT01430 ENT01440 ENT01450 ENT01460 ENT01470 ENT01480 ENT01490 ENT01500 ENT01510 ENT01520 ENT01530 ENT01540 ENT01550 ENT01560 ENT01S70 ENT01580 68 ENTAIL6: PROC (SNUH,NOL, S) RECURSIVE: /* DCL (SNUH,SN,NOL,J,I,K) FIXED BIN(31), (LB,UB,LB1,UB1) FI.OAT(6): DCL UPDATE ENTRY EXT, ENTAIL ENTRY EXT: DCL 1 S(*), 2 ATOH FIXED BIN(31), 2 VALOE FIXED BIN(31): DCL 1 GB EXT, 2 KNB(500,26), 3 VALUE FIXED BIN(31), 3 NEXTS FIXED BIN(31), 3 NEXTA FIXED BIN (31) , 2 LEVEL(500) FIXED BIN(31), 2 SENT (500) CHAR(20), 2 STARTA(26) FIXED BIN(31), 2 ENDA(26) FIXED BIN(31), 2 STARTS(500) FIXED BIN(31), 2 LASTSENT FIXED BIN(31), 2 BOUNDS (500) , 3 UPPER FLOAT (6) , 3 LOWER FLOAT (6) , 2 ORIGSENT FIXED BIN(31), 2 NUMLEVEL FIXED BIN(31): K-1: DO WHILE('l'B): I-STARTS(SNUH): J-1: DO WHILE (IA-O) : S(J).ATOH-I: S(J).VALUE-KNB(SNUH,I).VALOE: I-KNB(SNUH,I).NEXTA: J-J+1: END: S(J).ATOH-O: S(K).VALOE-S(K).VALDE*(-l): IF (K-J) '!'HEN LEAVE: CALL ENTAIL(S,NOL-1,LB1,UB1,SN): DO I-K TO (J-1): S(I).ATOH-S(I+1).ATOH: S(I).VALUE-S(I+1).VALOE: END: CALL ENTAIL (S , NOL-1, LB, UB, SN) : UB-UB-LB1: LB-LB-UB1: CALL UPDATE (SNUH, LB, UB) : K-K+1: END: RETURN: END ENTAIL6: CORRESPONDS TO PROCEDURE */ /* FOUR */ ENT00010 ENT00020 ENT00030 ENT00040 ENTOOOSO ENT00060 ENT00070 ENT00080 ENT00090 ENT00100 ENT00110 ENT00120 ENT00130 ENT00140 ENT001SO ENT00160 ENT00170 ENT00180 ENT00190 ENT00200 ENT00210 ENT00220 ENT00230 ENT00240 ENT002S0 ENT00260 ENT00270 ENT00280 ENT00290 ENT00300 ENT00310 ENT00320 ENT00330 ENT00340 ENT003S0 ENT00360 ENT00370 ENT00380 ENT00390 ENT00400 ENT00410 ENT00420 ENT00430 ENT00440 ENT004S0 ENT00460 ENT00470 ENT00480 ENT00490 ENTOOSOO ENTOOS10 ENT00520 ENTOOS30 ENTOOS40 UPDATE: PROC (SNUH, LB, UB) ; DCL (SNUH,SP,I)F~XEDBr.N(31) , (LB,UB) FLOAT (6) , (FLAG1,FLAG2) BIT(l), OUT FILE STREAM OUTPUT PRINT; DCL 1 GB EXT, 2 XNB(500,26), 3 VALVEF~XEDBr.N(31) , 3 NEXTSF~XEDBr.N(31), 3 NEXTAF~DBr.N(31), 2 LEVEL(500)F~XEDBIN(31), 2 SENT (500) CHAR(20), . 2 STARTA(26) FIXED Br.N(31) , 2 ENDA(26) FIXED BIN(31), 2 STARTS (500) FIXED BIN(31), 2 LASTSENT FIXED BIN(31), 2 BOUNDS (500) , 3 UPPER FLOAT (6) , 3 LOWER FLOAT (6) , 2 ORZGSENTF~DBIN(31), 2 NUMLEVEL FIXED BIN(31); FLAG1-'O'B; FLAG2-'0'B; SP-10*(NUMLEVEL-LEVEL(SNUH»+1; DO I-l TO (SP-l) BY 10; PUT FILE(OUT) EDIT('J') (COL(I),A); END; IF BOUNDS (SNCH) • LOWERUB THEN DO; BOUNDS (SNUH) .UPPER-US; FLAG2-'1'B; END; IF (FLAG1JFLAG2) THEN DO; PUTF~LE(OUT) EDIT (SENT (SNUH) , ' (' ,LB, " I,UB, I) ') (COL(SP) ,A(20) ,A,F(8,4) ,A,F(8,4) ,A); IF FLAGl THEN PUTF~LE(OUT)EDIT('LOWER') (X(3),A); IF FLAG2 THEN POTF~LE(OUT)ED~T('UPPER') (X(3) ,A) ; END I RETURN; END UPDATE; 70 EUP00010 EUP00020 EUP00030 EUP00040 EUP00050 EUP00060 EUP00070 EUP00080 EUP00090 EUP00100 EUPOOllO EUP00120 EUP00130 EUP00140 EUP00150 EUP00160 EUP00170 EUP00180 EUP00190 EUP00200 EUP00210 EUP00220 EUP00230 EUP00240 EUP002S0 EUP00260 EUP00270 EUP00280 EUP00290 EUP00300 EUP00310 EUP00320 EUP00330 EUP00340 EUP00350 EUP00360 EUP00370 EUP00380 EUP00390 EUP00400 EUP00410 EUP00420 71 BIBLIOGRAPHY Books Schafer, G.A.. Mathematical Theory of Evidence. Princeton: Princeton University Press, 1979. Shortliffe, E. H.. Computer Based Medical Consultations: MYCIN. New York: Elsevier, 1976. Articles Duda, R.O., Hart, P.E., and Nilsson, N.J.. "Subjective Bayesian Methods for Rule-base Inference Systems," in: Proceedings 1976 National Computer Conference, AFIPS 45 (1976) pp. 1075-1082. Halpern, J.Y. and Rabin, M.O .. "A Logic to Reason About Likelihood," Artificial Intelligence, 32 (1987) pp. 379-405. Nilsson, N.J.. "Probabilistic Logic," Artificial Intelligence, 28 (1986) pp. 71-87. Santos, E.S. and Santos, E. Jr.. "Reasoning With Uncertainty in a Knowledge Based System," in: Proceedings the Seventeenth International Symposium on Multiple-Valued Logic, (May 1987) pp. 75-81. Zadeh, L.A.. "Fuzzy Logic and Approximate Reasoning," Synthese, 30(1975) pp. 407-428.