RR 93:01ISSN - 0283-3638 Technical Diagnosis of TelecommunicationEquipment An Implementation of a Task Specific Problem Solving Method (TDFL) using GCLA II by Go"ran Falkman & Jonas Warnby KBS-lab December 1992 goran@sics.se & jonasw@sics.se Swedish Institute of Computer ScienceBox 1263, S-164 28 Kista, Sweden ------------------------------------------------------ Abstract: This paper describes an implementation of a small knowledge-based system in GCLA II. GCLA II isperhaps best described as a logical programming language, with some properties usually found among functional languages, and it includes hypothetical and non-monotonic reasoning as integral parts, whichmakes it easy to handle hypothetical queries, negation and AI-techniques like simulation and planning in a natural way. It also makes implementation of reasoning in knowledge-based systems (KBS) moredirect than in Prolog. The application is an already existing KBS that guides a service technician in the task of diagnosing aspecific device which is a measuring instrument for testing telecommunications equipment. The method used in the application is a problem solving method called TDFL. The TDFL method is a task specificproblem solving method for technical diagnosis that gives strong support for knowledge acquisition. The method is adapted to cope with some features of the application. For example, it gives support for reduc-ing the time required for observations and it handles parts that are not directly testable. This paper describes how to adjust the TDFL method to remedy some errors present in the original ver-sion; avoiding unnecessary search of the device and eliminating unnecessary confirmations. Some future extensions to both the TDFL method and the implementation are also presented; allowing the search formore than one fault and the possibility of turning the diagnosis backwards. Keywords: Expert systems, Diagnosis, GCLA II, Knowledge-Based System, Logic Programming. Table of contents i Table of contents 1 Introduction 11.1 Background 1 1.2 The organization of this paper 1 2 The implementation language 32.1 Introduction to GCLA 3 2.2 GCLA II 42.2.1 The declarative part 4 2.2.2 The procedural part 62.2.3 Queries 8 2.2.4 The disease example 9 3 The TDFL method 113.1 Decomposition model tailored to diagnosis 11 3.2 The top level tasks 113.3 The diagnose method 13 3.3.1 Testing more likely hypotheses first 143.3.2 Hypotheses that are not directly testable 14 4 Refinements of the method and domain 174.1 Modelling the HP device 17 4.2 Avoiding unnecessary search of the device 184.3 Changes to the preconditions of the TDFL method 19 4.4 Eliminating unnecessary confirmations 214.5 Summary 23 5 The implementation 255.1 A survey of the build-up of the program 25 5.2 The notions of behaviour, fault and hypothesis 255.3 Representation of the domain knowledge 27 5.3.1 Representing the functional and physical structure 285.3.2 Representing the top-level functional structure 30 5.3.3 Representing the norm 305.3.4 Representing causal dependencies 30 5.4 Turning the TDFL method into a GCLA II program 315.4.1 The declarative part 31 5.4.2 The rule definition 325.5 Diagnosing the HP device 37 5.5.1 The queries 37 Technical Diagnosis of Telecommunication Equipmentii 6 Conclusions and future work 396.1 Diagnosing the HP device 39 6.1.1 Finding more than one fault 396.1.2 Planning--turning the diagnosis backwards 42 6.2 GCLA II as an implementation language 466.2.1 GCLA II programming in general 46 6.2.2 How we have used the specific properties of GCLA II 476.2.3 Summary 486.3 The GCLA II programming environment 48 7 Acknowledgements 49 References 51 Appendix A 53 Appendix B 57 Appendix C 61 Appendix D 69 1 Introduction 1 1 Introduction 1.1 Background A knowledge based system (KBS) is a system which bases its reasoning on domain knowledge tofind solutions to specific problems in a domain. When it comes to implementing such a system many languages have been used; expert system shells, AI languages like Prolog and traditional lan-guages. Compared to Prolog, the language GCLA II is better suited for implementation of expert sys-tems since it includes hypothetical and non-monotonic reasoning as integral parts, which makes it easy to handle hypothetical queries, negation and AI-techniques like simulation and planning, ina natural way. In this paper we will describe how to: l implement a small KBS using GCLA II. The purpose of this implementation is to explorethe possibilities of GCLA II as an implementation language for such systems. l implement a task specific problem solving method called TDFL (Top-Down-Fault-Localization), a method fully described in [Ors92]. l adjust the TDFL method to remedy some errors present in the original version. Instead of developing a new application from scratch, we have used an already existing KBSdeveloped in 1989 by Infologics and Swedish Telecom. The KBS guides a service technician in the task of diagnosing a specific device which is a measuring instrument for testing telecommuni-cations equipment. The application and the corresponding device is henceforth called HP and HP device respectively.HP is a consultation system that makes a sequence of requests for tests to be performed by the user, who inputs the results of each test to the system. The system finally reports which part of thedevice is faulty. A complete description of the HP device is found in [Hp74]. Using our program the presumptive user may pose queries like: "Find a faulty part in the device."and "Assuming that these parts are correct and those parts are faulty, find a faulty part in the device." We will also describe how to adapt our program to allow the user to pose queries like: "Find everyfaulty part in the device." and "What conclusions about the behaviours of the other parts can be drawn, using the fact that this specific part is faulty?" 1.2 The organization of this paper The rest of this paper is organized as follows. In section 2 we give a short introduction to the imple-mentation language, GCLA II. This presentation will focus on the syntax, and we also present a few examples. In section 3 the top-down-fault-localization method (TDFL) will be presented. Thepresentation there follows the one given in [Ors92]. The original version of the TDFL method contained some errors. In section 4 we present our solutions to remedy these errors. In this section we Technical Diagnosis of Telecommunication Equipment2 also describe some changes to the domain knowledge necessary due to changes to the precondi-tions of the TDFL method itself. Section 5 describes the implementation. The notions of behaviour, fault and hypothesis are discussed. Then we present how the domain knowledge is rep-resented and how to implement the TDFL method in GCLA II. Finally we give some examples of how to use our program; which queries you can pose and which you cannot pose. A summary ofthe paper and a discussion of future work, is given in section 6. Appendices A through C contain the complete code of the program. Appendix A contains the definition, appendix B contains therule definition and appendix C contains the code of the domain knowledge. Appendix D, finally, contains a description of the decomposition model. 2 The implementation language 3 2 The implementation language 2.1 Introduction to GCLA The programming system GCLA (Generalized Horn Clause LAnguage) [Aro90] has been devel-oped for some years at SICS. It is perhaps best described as a logical programming language, with some properties usually found among functional languages.GCLA has a number of noteworthy properties. It includes hypothetical and non-monotonic reasoning as integral parts, which makes it easy to handle hypothetical queries, negation and AI-techniques like simulation and planning, in a natural way. It also makes implementation of reasoning in knowledge-based systems (KBS) more direct than in Prolog. GCLA has a similar syntax as Prolog, but its declarative semantics is completely different. WhileProlog is based on first order predicate logic, uses definite Horn clauses as programs and SLD resolution as computation rule, GCLA uses generalized Horn clauses as programs. Generalized Hornclauses are a generalization of definite Horn clauses, not within the traditional logical framework, but rather within the framework of partial inductive definitions (PID), a framework developed byLars Hallna"s[Hal91, HS-H88]. Partial inductive definitions gives a definitial framework which, in a sense, is of a more prim-itive and general nature than a standard logical framework. In GCLA, a program is not looked upon as a set of true facts and implications from which conclusions are drawn using a specific compu-tation rule (for example SLD resolution as in Prolog), but rather as a definition of rules determining the possible inferences. In a sense the program defines the "systems mind", meaning that the infer-ence rules of the logic are given by the program. This contrasts with Prolog where the inference rule is given a priori and the program is executed within this given framework. Compared to Prolog, what has been added to GCLA is the possibility to assume conditions. Forexample, the clause: a <= (b -> c). should be read as "a holds if c can be proved while assuming b". There is also a richer set of queries in GCLA than in Prolog. An ordinary Prolog query is written: :- a. and should be read as "Does a hold (in the definition D)?" In GCLA one can also assume thingsin the query, for example: c \- a. which should be read as "Assuming c, does a hold (in the definition D)?", or "Is a derivable from c?" To execute a program, a query G is posed to the system, asking whether there is a substitution ssuch that Gs holds according to the logic defined by the program. The goal G has the form \Gamma |- c, where \Gamma is a list of assumptions, and c is the conclusion from the assumption \Gamma . The system triesto construct a deduction showing that Gs holds in the given logic. Technical Diagnosis of Telecommunication Equipment4 The clauses in the program could be used both for forming the introduction rules, applicable to theconsequence of the goal (to the right of |-), and for forming the elimination rules, applicable to the assumptions of the goal (to the left of |-). 2.2 GCLA II Two versions of the GCLA system can be discerned. One older version interpreting a GCLA pro-gram, having some inference rules given beforehand, called GCLA I [Aro90]. GCLA I had a very restricted set of control primitives, which led to a large search space for larger programs. From the GCLA I system the GCLA II system was developed. GCLA II generalizes GCLA I inthe sense that the inference rules that interpreted the GCLA I program can be defined by the user. The search order among the inference rules can also be freely defined by the user. By this gener-alization a GCLA II program consists of two parts; the declarative and the procedural part. These parts are also referred to as the object level and the meta level respectively.The declarative part consists of a definition D and a set of sequents S. The procedural part consists of the rule definition, R, and the proviso definition, P. For a more complete and comprehensive description of GCLA II's theoretical properties and itsrelation to PID see [Kre92]. [Aro92] demonstrates the program development methodology used in GCLA II. Various imple-mentation techniques, including functional and object oriented programming, are also demonstrated. This short presentation will focus on the syntax. We will also present a few examples. 2.2.1 The declarative part 2.2.1.1 The definition The definition contains the declarative knowledge of the domain. In GCLA I this part was calledthe program. The syntax of the definition is given by: i) VariablesA variable is a capitalized alphanumeric string, that is a string beginning with an uppercase letter or the character '_'. The variable consisting of just the character '_' denotes ananonymous variable. ii) AtomsIf f is a term-constructor (a non capitalized alphanumeric string), and term1, ..., termn areterms, then f(term1, ..., termn) is an atom. iii) TermsA term is an atom or a variable. 2 The implementation language 5 iv) ConditionsAll terms are conditions, and if C1 and C2 are conditions, then so are C1 -> C2, (C1,C2), (C1;C2), true and false. If X is an object level variable and C a condition, then pi X\ Cis a condition. v) GuardsIf Vi is a variable and Ti is a term then, {V1 \= T1, ..., Vn \= Tn} is a guard. Theguard Vi\= Ti restricts Vi not to be equal to Ti for the rest of the execution. vi) ClausesIf A is an atom, C a condition and G a guard, then A <= C and A#G <= C are clauses. vii) DefinitionsA definition is a sequence of clauses, each clause terminated by '.'. The following is an example of a definition: p(a,[],[]) <= true. p(b,[],C) #{C \= []} <= true. p(b,B,[]) #{B \= []} <= true. p(f(A),[B|C],[(D + E)|F]) <= pi G\ q(B,G), r(G,D) -> E; p(A,C,F). q(a,c) <= false. q(A,(A + A)) <= r(A,A) -> false. 2.2.1.2 Sequents The sequents S are used to query the definition D. The syntax of the sequents is given by: i) ConsequentsAll conditions are consequents. ii) AntecedentsIf C1, ..., Cn are conditions, then [C1, ..., Cn] is an antecedent, and so is []. iii) Object level sequentsIf A is an antecedent and C is a consequent, then A \- C. is a object level sequent. The following are examples of sequents: Technical Diagnosis of Telecommunication Equipment6 [true,q(a,c),A] \- p(a,A,B). [] \- d. [false,p,r(A,1)] \- q(b(2),N),(true -> p(a,A,B)). 2.2.2 The procedural part The procedural part contains the procedural knowledge of the domain, that is, the knowledge usedfor drawing conclusions based on the declarative knowledge in the definition. This part implements proviso definitions, inference rules and search strategies among the rules and among theassumptions in the object level sequents. One should note that even though the procedural part defines how the declarative part is to be uti-lized, the coding of the rules and strategies is a subset of GCLA I and can thus be given a declarative reading. When the GCLA II system is started, the user is furnished with a general set of provisos and infer-ence rules, implementing the behaviour of GCLA I or, in fact, the rules for the calculus OLD in [Kre92]. 2.2.2.1 The rule definition a) Proof terms Proof terms are representations of proofs (or set of proofs). They can be seen as functional expres-sions that compute sequents from proofs with respect to a certain rule definition. Sequents are normal forms of proof terms, e.g. evaluating a proof term r1(r2(...), ...) gives as result a sequent: Assumptions |- Conclusion. b) The inference rules The underlying idea of the rule definition is that the inference rules are coded as functions, fromthe premises of a rule to the conclusion, with a possible proviso. The inference rule: is coded by the function: Rule_name(P1, ..., Pn) <= (Proviso, (P1 -> S1, ..., (Pn -> Sn)) -> S. where Si and S are object level sequents and Pi are proof terms. The arrow construct "A -> B"should be read as "if A then B". So these rules are partial functions from sequents to sequents. Each proof term Pi represents the derivation leading to Si. This representation is the nested func-tional expression of rulenames leading to S i, so Pi can be replaced by this expression. S1 ... Sn, , S----------------------- Rule_name Proviso 2 The implementation language 7 If Aj are arbitrary arguments (commonly used for specifying which term in a sequent that this ruleoperates on), PTi are proof terms, Seqi and Seq are object level sequents and Pk are provisos then: Rule_name(A1, ..., Am, PT1, ..., PTn) <= (P1, ..., Pr, (PT1 -> Seq1), ..., (PTn -> Seqn)) -> Seq is an inference rule. The rule should be read as "if Pk holds, and if PTi maps to Seqi, then Rule_name(A1, ..., Am, PT1, ..., PTn) maps to Seq". An example of an inference rule is: axiom(A,C,I) <= term(C), % C must be term term(A), % A must be term unify(C,A), % C must unify with A -> (I@[A|R] \- C). where @ is the append operator over lists. c) The search strategies Until now we have thought of the proof terms as either uninstantiated or instantiated to a rule term.In the former case, the proof term was thought of as representing all possible derivations that were possible to perform. When search strategies are now introduced, they will replace the uninstanti-ated proof term, and refer to a particular search strategy instead. The search strategies can be seen as indeterministic functions, representing several possible derivations. The simplest form of a search strategy is: Strat_name(Pts) <= PT1, ..., PTn. where each PT1, ..., PTn is a vector of proof terms. PT1 is tried first and PTn last. Note that thecomma is to be interpreted disjunctively in this vector, because the vector will occur to the left of the meta level derivability symbol | |- . Strat_name can also contain one or more arguments, Pts. Strategies can also contain restrictions (provisos) on their applicability. These strategies are writ-ten: Strat_name(A1, ..., Am) <= (P1 -> Seq1), ..., (Pm -> Seqm). Strat_name(A1, ...,Am) <= PT1, ..., PTn. If the first clause holds, the vector in the second clause is used. Since the clauses occur to the leftof the meta level derivability symbol | |- , they should be read conjunctively. This contrasts to the usage to the right of the meta level derivability symbol | |- , where clauses are read disjunctively. Technical Diagnosis of Telecommunication Equipment8 An example of a strategy of the first, simple kind is: arl <= axiom(_,_,_), % first try the axiom rule right(arl), % then try the rules that operate to the right left(arl). % and last try the rules that operate to the left where right and left are sub-strategies. An example of a strategy of the second, more complicated kind is: left(T,I,Pt) <= (I@[T|_] \- _). % first choose a condition in the antecedent left(T,I,Pt) <= % then choose appropriate left rule for T d_left(I,T,Pt), % try definition_left rule a_left(I,L,Pt). % or try arrow_left rule Both these strategies (and the example inference rule given above) are included in the set of defaultrules, which are loaded when the GCLA II system is started. 2.2.2.2 The proviso definition The proviso definition consists of provisos. A proviso contains restrictions when an inference ruleis applicable. To distinguish the proviso definition from the inference rules and the search strategies, the proviso clauses are written as: Head :- B1, ..., Bn. where Head is a nonvariable term, and B1, ..., Bn are all atoms. In the current implementation the provisos are common Horn clauses--and thus could be any kindof Prolog clauses--and are in principle compiled to Prolog clauses which are directly executed by the underlying Prolog system. 2.2.3 Queries If Proof_term is a proof term (a meta level term coding the proof of Sequent), and Sequent is anobject level sequent, then: Proof_term \\- Sequent is a meta level sequent. The meta level sequent can thus be seen as an interface between the declar-ative part and the procedural part of the program. A query in GCLA II is equal to a meta level sequent. Given the query: Rule_name(PT1, ..., PTn) \\- (Assumptions \- Conclusion). the system tries to find a proof term whose canonical form is the query (the object level sequent)and an (object level) answer substitution. 2 The implementation language 9 The following are examples of queries: left(gcla) \\- p(b,[],A) \- q(a,c). gcla \\- false \- A. 2.2.4 The disease example Assume we are going to construct a system for the diagnostics of infectious diseases. Part of thecode could look like: disease(cold) <= symptom(cough), temp(normal). disease(pneumonia) <= symptom(persistent_cough), symptom(chill), temp(high). A typical situation here is when we have some symptoms and want to ask about a possible diag-nosis. In this case we would pose a query like: [symptom(cough), temp(normal)] \- disease(X). which should be read as: "Assume we have observed the symptoms cough and normal temp, whichare the possible diseases?" In this case the system would respond with X=cold. We might also be in the situation where we do not have complete knowledge. We could then posea query like: [symptom(chill), system(persistent_cough), temp(X)] \- disease(Y). Here the system would respond with X=high, Y=pneumonia. Assume we want to list the typical symptoms of a given disease. This could be done by posing thefollowing query: disease(pneumonia) \- X. The first (trivial) answer would be X=disease(pneumonia), as the assumption follows triviallyfrom itself. Then the interesting answers follows: X=symptom(persistent_cough), X=symptom(chill) and X=temp(high). With a different set of strategies the set of answers could be restricted or their order reversed. Technical Diagnosis of Telecommunication Equipment10 3 The TDFL method 11 3 The TDFL method The Top-Down Fault-Localization (TDFL) method is a problem solving method under develop-ment by Klas Orsva"rn. The TDFL method is a task specific problem solving method for technical diagnosis that gives strong support for knowledge acquisition. Instead of developing a new appli-cation from scratch, this example is the result of reverse engineering from an existing operational KBS that guides a service technician in the task of diagnosing a specific measuring instrument,which is a measuring instrument for testing telecommunications equipment. No task specific problem solving methods were used in the development of the KBS. It is specified with a decision tree(with some extensions) and implemented as a rule-based system. The goal of the reverse engineering was to specify the system as an application of task specific problem solving methods.The TDFL method is adapted to cope with some features of the application. For example, it gives support for reducing the time required for observations and it handles parts that are notdirectly testable. We will leave out some parts of the method that are not relevant to us. For a more detailed description we refer to [Ors92]. In the presentation of the different tasks we will use a Prolog-like syntax with its usual proceduralinterpretation. Added is an if-then-else construct with backtracking over the test, and an infix "assign-operator", =. 3.1 Decomposition model tailored to diagnosis By decomposition model we mean the domain knowledge that is used to realize the tasks in theTDFL method. We have to make some assumptions about the decomposition model in order to make the method work: l The decomposition of a device into primitive components must be well defined, and wewant primitive parts that are physical parts so that they can be replaced or repaired. l In iterative decomposition we want to introduce intermediate levels of decomposition,that is, composite parts. By doing this we keep down the total time required for observations when we observe composite parts instead of all the primitive parts within them.A composite physical part must be such that it can be physically removed from the other parts. l In diagnosis we want a functional decomposition, that is we want the subparts to be func-tional parts of the composite part, since it is the functions we are testing. l Another important assumption about the decomposition model is that the parts haveinputs that can be controlled and outputs that can be observed during diagnosis. 3.2 The top level tasks The top level task is troubleshooting, which has a reference to a device as input. The device has anumber of distinct functions that can be used independently. For example, the HP device can be used to control the amplitude and frequency of an output signal and to measure amplitude and fre Technical Diagnosis of Telecommunication Equipment12 quency of an input signal. The functionalPart task has these functions as solutions. This task isonly applied to the top level device. Each of these functions is tested until one is found to be faulty. The test is divided into three different tasks: specify, establish and consistent. When we havelocalized the fault to a specific function we want to localize it to the smallest possible level. That is what the topDownDiagnose task is doing. To do this we use the diagnose task iteratively to finda more and more detailed description of the fault. troubleshooting(Device,LowestLevelFault) :- functionalPart(Device,FuncionalPart), specify(FunctionalPart,Behaviour), establish(Behaviour,ActualBehaviour), not(consistent(Behaviour,ActualBehaviour)), topDownDiagnose(ActualBehaviour,LowestLevelFault). topDownDiagnose(Fault,LowestLevelFault) :- diagnose(Fault,RefinedFault), if(topDownDiagnose(RefinedFault,RefinedFault2), then( LowestLevelFault=RefinedFault2), else( LowestLevelFault=RefinedFault)). Figure 3.1 The troubleshooting and topDownDiagnose tasks. The specify task takes a part as input and gives a behaviour, or norm, as output. The norm is a setof necessary and sufficient conditions for the part to be functioning correctly. It is a description of the correct behaviour of the part. Before we carry on with further description of the TDFL method we need to know somethingabout hypotheses. Hypotheses are statements about behaviours. They state that the actual behaviour of the part they are referring to is incorrect. More precisely, the statement is the negation ofthe statement that the part has the behaviour specified by the norm, that is the correct behaviour. We call this a negated behaviour. If the hypothesis refers to a set of parts, the statement is the nega-tion of the statement that they all have a specific behaviour, which is their respective correct behaviour. The establish task is described in figure 3.2. The input is a hypothesis, a statement that needs to beverified. It refers to a specific behaviour. The output is the actual behaviour of the part corresponding to the hypothesis. establish(Hypothesis,Observation) :-- observables(Hypothesis,Observables), observe(Observables,Observation). Figure 3.2 The establish task. The observables task takes a statement as input. The statement is a behaviour, or the negation of abehaviour. We have to look at the norm and see what observations need to be done in order to test whether the statement is satisfied or not. The Observables are the attributes which are referred toin the norm. The observe task is a transfer task, that is, it is solved by an external action. Its output is the actual observation made of the observables by the user. The consistent task succeeds if the two expressions, Hypothesis and Observation, are consistent.If both parameters are behaviours, the test is performed by an equality test. If the Hypothesis is a 3 The TDFL method 13 negated behaviour, the test succeeds if the negated behaviour is different from the behaviour inObservation. 3.3 The diagnose method The diagnose task, which plays the key role in the method, is described in figure 3.3. The input todiagnose is a reference to the actual faulty behaviour of the faulty part. The output, which becomes input to a subsequent invocation of diagnose, is a reference to the actual faulty behaviour of thelower level part. The task begins by decomposing the part of the device to which we have located the fault. Since Fault is the actual behaviour of the faulty part we decompose the fault into hypoth-eses about faults of subparts. The hypothesis is then a statement that can be verified. The decompose task generates two hypotheses. The first one is the hypothesis which we want to verify,Hypothesis, and the second is the hypothesis that state that the rest of the faulty part, when we have removed the part corresponding to Hypothesis, is faulty. This one is called Rest. diagnose(Fault,RefinedFault) :-- decompose(Fault,Hypothesis,Rest), if(testable(Hypothesis,Fault), then( establish(Hypothesis,ActualBehaviour), if(consistent(Hypothesis,ActualBehaviour), then( RefinedFault = [ActualBehaviour,Fault]), else( establish(Rest,[ActualBehaviour,Fault],RestBehaviour), RefinedFault = [RestBehaviour,Fault]))), else( generateElimination(Fault,Hypothesis,LargerHypothesis,Rest1, Rest2), establish(LargerHypothesis,LargerBehaviour), if(consistent(LargerHypothesis,LargerBehaviour), then( establish(Rest2,Rest2Behaviour), if(consistent(Rest2,Rest2Behaviour), then( RefinedFault = [Rest2Behaviour,LargerBehaviour,Fault]), else( establish(Hypothesis,[Rest2Behaviour,LargerBehaviour], HypothesisBehaviour), RefinedFault = [HypothesisBehaviour,LargerBehaviour, Fault] ))), else( establish(Rest1,[LargerBehaviour,Fault],Rest1Behaviour), RefinedFault = [Rest1Behaviour,Fault])))). Figure 3.3 The diagnose method. Most parts of the HP device cannot be tested completely independent of the rest of the device. Inparticular you cannot control the inputs of a part with anything else but the external controls of the device. If you want to control an input of a component, which is internal to the device, you haveto input an external signal to the whole device and let it go through other components until it reaches the one you want to control. You have to make sure that the signal has not been corruptedon the way. The testable task succeeds if the part corresponding to Hypothesis is testable in the part cor Technical Diagnosis of Telecommunication Equipment14 responding to Fault, that is if and only if the input attributes of Hypothesis are also input attributesof Fault, and the input values of the tuples in Hypothesis are contained in the input values of Fault. If the hypothesis is testable we try to verify it. If it is refuted, that is, if it is not consistent with theactual behaviour, we make the conclusion by elimination that the part corresponding to Rest is faulty. What to do when the hypothesis is not testable will be explained in section 3.3.2. 3.3.1 Testing more likely hypotheses first In order to keep down the total time used for observation we have to choose a hypothesis that ismore likely to be true than others. We can do this by recognizing the effects of some specific faults. For example, in the HP application one specific component has the property that if it breaks theamplitude of the output signal of the device will be reduced by half. If we can associate the actual fault with a specific cause, then the corresponding hypothesis is more likely than other hypotheses,and we should test it first. The decompose task uses a set of relations--causes(Fault, Effect)--which tells us that Faultalways results in Effect. If we have an actual fault, Fault, and we want to decompose it and find a hypothesis, Hypothesis, we try to find a relation that says that Hypothesis always results in Fault,that is if there is a relation causes(Hypothesis, Fault) we have found our most likely hypothesis. The part corresponding to Hypothesis can be a direct subpart of the part corresponding to Fault,but it may also be found on a deeper level in the decomposition model. 3.3.2 Hypotheses that are not directly testable If the hypothesis is not testable we have to use the method of test by elimination, which is basedon finding a subsuming hypothesis that is testable, and begin by testing that, etc. Let us take an example to illustrate the idea. Suppose we have located the fault to a block of components that areconnected together in a single signal chain, as in figure 3.4. The only component that is directly testable is the first component in the chain, the one that has the same input as the whole chain. Wemust know the input to a component before we can test it. Let us now assume that our hypothesis is that the third component in the signal flow is faulty. Whatwe do then is to measure the output of the third component, knowing the input to the chain. If that observation is ok we have refuted the hypothesis. However, if the observation is not ok we havenot confirmed the hypothesis. We must also measure the input of the third component, by measuring the output of the second component. If that observation is ok we have confirmed the hypoth-esis, the third component is faulty. If the observation is not ok we have instead confirmed another hypothesis, namely that the fault is in the first or second component. We have to identify otherhypotheses that can be tested and can be used to make a conclusion by elimination about the desired hypothesis.In this application it is necessary to identify three auxiliary hypotheses. The generateElimination task, which is described in figure 3.5, takes the actual fault and the desired input signal output signal Figure 3.4 A chain of components. 3 The TDFL method 15 hypothesis as input and generates the auxiliary hypotheses. The first one is the subsuming hypoth-esis. It is the smallest part that contains both the desired part and is testable. This will be a part that shares the outputs with the hypothesis part and which inputs are also inputs to the faulty part, andtherefore have been observed. We call this hypothesis LargerHypothesis. The next auxiliary hypothesis is the rest of the subsuming part minus the desired hypothesis part. We call this oneRest2. It will be testable since its inputs are also inputs of the faulty part. The task also generates a hypothesis about the rest of the faulty part when the part corresponding to LargerHypothesis isremoved. This hypothesis is called Rest1. generateElimination(Fault,Hypothesis,LargerHypothesis,Rest1,Rest2) :-- decompose(Fault,LargerHypothesis,Rest1), testable(LargerHypothesis,Fault), decompose(LargerHypothesis,Rest2,Hypothesis), testable(Rest2,LargerHypothesis). Figure 3.5 The generateElimination task. The task first decomposes Fault into two hypothesis. If the first hypothesis is testable we havefound a probable LargerHypothesis. Otherwise, we backtrack and make another decomposition until we found one hypothesis that is testable. After finding the LargerHypothesis we try to decom-pose it into two hypothesis where the first hypothesis, Rest2, is testable in LargerHypothesis and the second hypothesis is equal to Hypothesis, that is our original hypothesis. If a such decomposi-tion is impossible we have to backtrack to the first decompose and try with a new LargerHypothesis. When we find our real LargerHypothesis, we also get Rest1 in the firstdecompose. Technical Diagnosis of Telecommunication Equipment16 4 Refinements of the method and domain 17 4 Refinements of the method and domain To accomplish our task there are two things that we have to do: l We must turn the domain knowledge into some kind of abstract model, which to be codedin GCLA. l Turn the TDFL method into a GCLA program. In reality, the process turned out not to be as simple as described above. The reason for this is thatthe initial version of the TDFL method, as presented in section 3, did have some flaws in it. The changes we made to the method to overcome these flaws, had implications on the modelof the domain. The changes made to the model had in turn implications on the method, and so on. Another reason is that during this process, the preconditions of the domain itself changed. Thischange had of course implications on the model, which in turn had implications on the method ... In the following subsections we will describe the above process in greater detail. 4.1 Modelling the HP device To be able to use the domain knowledge we must have a model of the HP device.This modelshould contain all the information about the functional, physical and causal dependencies that exists among the various parts of the HP device.The model can be based on several different decomposition models, for example the decomposition made in the design of the device or the physical configuration of the device.To aid us in this task we had the decision tree (with some extensions) which specified the original KBS (HP), and the technical documentation of the HP device. The creation of the model was complicated for several reasons. First of all the decision tree whichspecified HP was neither complete nor accurate. Secondly, due to our lack of knowledge in electrical engineering, the reading of the technical documentation did not give us as much information,as it could have had. Furthermore we did not have access to the domain expert who participated in the development of the original KBS.For these reasons we do not claim our model to be a totally correct representation of the HP device, but we think it is correct enough to be realistic. We believe that once a correct model hasbeen made, it could easily replace our current model without having to change the rest of the program. At the top-level the HP device has a number of distinct functions that can be used independently.The device can for example be used to control the amplitude and frequency of an output signal. It can also be used to measure amplitude and frequency of an input signal. To put it another way, atthe top-level the HP device has a sender function and a receiver function, which both have two distinct inputs that can be tested independently: level and frequency. These two functions are theonly ones considered in our application. We chose to regard the above two functions as four different functions: sender-level, sender-frequency, receiver-level and receiver-frequency. Each top-level function of the HP device consists of lower-level functions which in turn consists Technical Diagnosis of Telecommunication Equipment18 of sub-functions, which consists of sub-sub-functions and so on. At the bottom-level we find thephysical parts that realize the sub-functions. These parts are considered atomic in our model, and that can not be decomposed any further. We call these parts primitive parts. NoteThe TDFL method is based on the functional decomposition of the device. The functional decomposition is strongly influenced by the physical decomposition and some-times they both have the same structure. When we talk about the decomposition we mean the functional decomposition (which sometimes coincide with the physicaldecomposition), when we talk about composite parts we mean functional parts that can be further decomposed, when we talk about parts we mean functional or physicalparts and when we talk about primitive parts we mean physical parts (or sometimes functional parts that we also consider atomic). Each part can have multiple inputs and multiple outputs. A directed acyclic graph (DAG) is a suitable representation of the functions; the nodes representsthe parts, the edges the lines connecting the parts and the direction of the graph corresponds to the direction of the signal flow.Strictly speaking this representation of the HP device is not strong enough to capture all aspects of an electrical device, since a real device may contain feedback loops, that is an input ofa part may be connected directly or indirectly to an output of the same part. In order to describe this behaviour in terms of TDFL we need a way to detect feedback loops and we need to test theloop by observing the correctness of the feedback input. If so, the faulty part in the loop can be diagnosed in the usual way. Since we currently have no way of detecting feedback loops we adoptthe solution used in HP, that is we simply assume that the feedback input is correct. The only fault that can be detected then, is the fault that is located somewhere along the feedback path, before itsend. 4.2 Avoiding unnecessary search of the device In the original TDFL method, the first thing that was done in the function called diagnose, was todecompose the incoming faulty part into two hypotheses: Hypothesis and Rest. Since these hypotheses are statements about parts of the HP device, the construction of Hypothesis and Restnecessarily involves a traversal of the DAG. After the decomposing step a test is performed to see if Hypothesis is directly testable. IfHypothesis is directly testable then you try to confirm either Hypothesis or Rest and the diagnosing process continues with the one confirmed. But if Hypothesis is not testable, then a new set ofhypotheses is constructed: LargerHypothesis, Rest1 and Rest2. It is difficult to see how the construction of this set would not involve another traversal of the DAG.But what happened to the original Rest? The answer is that if Hypothesis is not testable then Rest is discarded, and all the work constructing it is wasted. But if you look at figure 4.1, it is easyto see that Rest is equal to Rest1+Rest2, and that LargerHypothesis is equal to Hypothesis+Rest2. Instead of throwing Rest away we could introduce a new function that generatesLargerHypothesis, Rest1 and Rest2 from Hypothesis and Rest, but once again, it is hard to see how this would not require another traversal of the DAG. A better solution would be if we already inthe decomposing step could construct LargerHypothesis, Rest1 and Rest2 once and for all, thus avoiding one traversal of the DAG.The effort spent on the construction of these three hypothesis would not be greater than the 4 Refinements of the method and domain 19 effort spent on the construction of the single hypothesis Rest since both of them can be accom-plished by just one traversal of the DAG. Even if it did require some more effort the total work would be less anyway since most of the parts are not directly testable (only the first part in a chainof parts is directly testable), that is it is more likely that LargerHypothesis, Rest1 and Rest2 have to be constructed than that they do not.This is of course only true under the assumption that you are interested in generating all (or at least most of all) possible hypotheses. If you are only interested in finding one single hypothesisit is always possible to generate a testable hypothesis. The decomposing task should generate all testable hypotheses before generating a non-testable hypothesis. Of course, if a particular hypoth-esis is more likely to be true than any other it should be generated first, regardless of it being testable or not. 4.3 Changes to the preconditions of the TDFL method At this stage the preconditions of the TDFL method itself changed. We said before that a part couldhave multiple inputs and multiple outputs. From now on a part can still have multiple inputs but only one single output. This stronger constraint on the domain made some parts of our work easier, but other parts becamemore complicated than before. Easier because we no longer needed a DAG to represent the HP device but rather a tree, an in every way much easier structure to work with. More complicatedbecause, as we had understood the HP device, many parts do have multiple outputs. Obviously at least some primitive parts do, for example a micro-processor of any kind. These multiple-outputparts had to be transformed into single-output parts in some way. Our solutions to overcome this problem included: l Decompose the part even further. In many cases this was the most natural solution, sincein a part with multiple outputs each output often corresponds to a particular sub-function of the actual part. The part could then be decomposed even further into these lower-levelfunctional parts. l A part may be used by several different higher-level parts. If this part could not be decomHypothesis Rest Rest1 LargerHypothesis Rest2 Figure 4.1 Hypothesis, Rest, LargerHypothesis, Rest1 and Rest2. Technical Diagnosis of Telecommunication Equipment20 posed into lower-level functional parts it had to be duplicated, and a copy placed in everyother higher-level part depending on it. l If a part was used by many different higher-level parts it was "lifted up" in the decompo-sition model to a level above those other parts. The part was placed in a position that guarantees that the part is tested before every other higher-level part that is depending on it.For example, the power supply part of the HP device is "used" by every other part. Instead of putting a duplicate of the power supply part in every other part, the power sup-ply part was lifted up to the level just below the top-level device functions. This means that if a top-level device function is found to be faulty, the power supply part is testedfirst, once and for all, before all other parts used by the top-level function. For some of the parts none of the solutions above were applicable. When this happened we decom-posed the part in a arbitrary way or simply deleted it. This is of course not a very satisfactory solution but, as we have said before, it is mostly a result from our lack of knowledge in electricalengineering. A complete description of the decomposition model used in our application can be found in appen-dix D. If we look again at figure 4.1 we see that Rest consists of two connected parts; Rest1 and Rest2.Now, when the inner structure of a composite part is always a tree a situation like this can never occur. This should be clear if we look at figure 4.2. We see that Rest1 is the (possibly empty) singletree that results when removing the tree corresponding to LargerHypothesis from the tree corresponding to the incoming faulty behaviour. Rest2 is the (possibly empty) set of trees that resultwhen removing the tree corresponding to Hypothesis from the tree corresponding to LargerHypothesis. Since the inner structure of the part corresponding to the incoming faultybehaviour is a tree the set of trees corresponding to Rest2 can have no connection to the single tree corresponding to Rest1. In the following subsection we will see that this property has very important implications on theTDFL method. Hypothesis Rest Rest1 LargerHypothesis Rest2 Figure 4.2 Hypothesis, Rest, LargerHypothesis, Rest1 and Rest2. 4 Refinements of the method and domain 21 4.4 Eliminating unnecessary confirmations In the original TDFL method, it can happen that some unnecessary confirmations are made, thatis you try to confirm or refute some hypotheses whose behaviours you in fact already know. In some other cases you do not already know the behaviour of a hypothesis but somehow you cancompute the actual behaviour without having to ask the user. Since one of the prime goals of the TDFL method is to minimize the interaction with the user,these unnecessary confirmations have to be avoided as much as possible. For example, in the original TDFL method, when the Hypothesis has been found not to be directlytestable and the new set of hypotheses, that is LargerHypothesis, Rest1 and Rest2, has been constructed, you try to confirm LargerHypothesis which involves asking the user for the actual behav-iour of the corresponding part. In this case we already know the actual behaviour of the part corresponding toLargerHypothesis if the output of the part that corresponds to Hypothesis is equal to the output of the composite part corresponding to the incoming faulty behaviour. If this is the case thenLargerHypothesis is equal to the incoming faulty behaviour which, of course, is known. It turns out that the answers to the questions: "When are we able to avoid unnecessary confirma-tions?" and "When are we able to precompute actual behaviours?" are directly connected to the answer of the question: "Where is the subtree that corresponds to Hypothesis positioned in the treethat corresponds to the incoming faulty behaviour?" There are four cases: 1) Hypothesis is both a top subtree and bottom subtreeHypothesis may be both a top subtree and a bottom subtree, that is the root of the tree corresponding to Hypothesis is equal to the root of the tree corresponding to the incomingfaulty behaviour and all the leaf nodes of the tree corresponding to Hypothesis are also leaf nodes of the tree corresponding to the incoming faulty behaviour. This means that theoutput of the part corresponding to the incoming faulty behaviour is equal to the output of the part corresponding to Hypothesis and all the inputs of the part corresponding toHypothesis are also inputs of the part corresponding to the incoming faulty behaviour, that is Hypothesis is equal to LargerHypothesis which in turn is equal to the incoming faultybehaviour. We notice that when Hypothesis is both a top subtree and bottom subtree the tree rep-resentations of both Rest1 and Rest2 are empty, that is Rest is empty which is equal to say that both Hypothesis and LargerHypothesis are already confirmed and that Hypothesis isdirectly testable. Thus, we see that in the decompose step we can precompute the behaviours of bothHypothesis and LargerHypothesis and we can also conclude that Hypothesis is directly testable.In reality this case is of no interest since there is no meaning in generating a hypothesis that is equal to the incoming faulty behaviour. 2) Hypothesis is a top subtreeHypothesis may be a top subtree, that is the root of the tree corresponding to Hypothesis is equal to the root of the tree corresponding to the incoming faulty behaviour. This meansthat the output of the part corresponding to the incoming faulty behaviour is equal to the output of the part corresponding to Hypothesis and to the output of the part correspondingto LargerHypothesis, that is LargerHypothesis is equal to the incoming faulty behaviour. Technical Diagnosis of Telecommunication Equipment22 Since this behaviour of, course is, known we have already confirmed LargerHypothesis.This means that we already in the decompose step can precompute not only the actual behaviour of the part corresponding to LargerHypothesis but also the faulty behaviour ofthe part corresponding to Hypothesis. We also notice that when Hypothesis is a top subtree then the tree representation ofthe part that corresponds to Rest1 is equal to the empty tree, that is Rest2 is equal to Rest and non-empty, and this is equal to say that Hypothesis is not testable.Thus, in the decompose step we can conclude that LargerHypothesis is already confirmed and that Hypothesis is not directly testable. 3) Hypothesis is a bottom subtreeHypothesis may be a bottom subtree, that is all the leaf nodes of the tree corresponding to Hypothesis are also leaf nodes of the tree corresponding to the incoming faulty behav-iour. This means that all the inputs of the part corresponding to Hypothesis are also inputs of the part corresponding to the incoming faulty behaviour, that is LargerHypothesis isequal to Hypothesis. In this case there is no way we can precompute the actual or faulty behaviours of Hypothesis and LargerHypothesis, so we have to ask the user, that is noneof the hypotheses are already confirmed. Since LargerHypothesis is equal to Hypothesis the tree representation of the part thatcorresponds to Rest2 is equal to the empty tree, that is Rest1 is equal to Rest and nonempty, and this is equal to say that Hypothesis is directly testable.Thus, we see that in the decompose step we can not precompute the actual or faulty behaviours of either Hypothesis or LargerHypothesis, but we can precompute the faultybehaviour of Rest1 and we can conclude that Hypothesis is directly testable. 4) Hypothesis is an intermediate subtreeHypothesis may be an intermediate subtree, that is, the root of the tree corresponding to Hypothesis is not equal to the root of the tree corresponding to the incoming faulty behav-iour and not all of the leaf nodes of the tree corresponding to Hypothesis are also leaf nodes of the tree corresponding to the incoming faulty behaviour. This means that the out-put of the part corresponding to hypothesis is not equal to the output of the part corresponding to the incoming faulty behaviour and at least one of the inputs to the partcorresponding to Hypothesis are not also an input of the part corresponding to the incoming faulty behaviour. As in case 3 there is no way we can precompute the actual or faultybehaviours of Hypothesis and LargerHypothesis, that is none of the hypotheses are already confirmed.We notice that when Hypothesis is an intermediate subtree both Rest1 and Rest2 is non-empty, and this is equal to say that Hypothesis is not directly testable.Thus, we see that in the decompose step we can not precompute the actual or faulty behaviours of either Hypothesis or LargerHypothesis, but we can precompute the faultybehaviour of Rest1 and we can conclude that Hypothesis is not directly testable. In the program the obvious solution is to test Rest1 and Rest2 for emptiness. If both Rest1 andRest2 are empty, LargerHypothesis and Hypothesis are already confirmed, the actual behaviours and the faulty behaviours of Hypothesis and LargerHypothesis can be precomputed and we canconclude that Hypothesis is directly testable. If Rest1 is empty LargerHypothesis is already confirmed, the faulty behaviour of Hypothesis can be precomputed and we can conclude thatHypothesis is not directly testable. If Rest2 is empty none of the hypotheses are already confirmed, only the faulty behaviour of Rest1 can be precomputed and we can conclude that Hypothesis isdirectly testable. If none of Rest1 and Rest2 are empty none of the hypotheses are already confirmed, only the faulty behaviour of Rest1 can be precomputed and we can conclude that 4 Refinements of the method and domain 23 Hypothesis is not directly testable. 4.5 Summary In this section we have seen: l That the decomposition of a device is not an easy task, not even for a device as simple asthe HP device. l By generating the necessary hypotheses already in the decompose step we can avoidunnecessary search of the device. l By observing where the subtree that corresponds to the Hypothesis is positioned in thetree that corresponds to the incoming faulty behaviour, we can eliminate unnecessary confirmations and we can precompute some the actual (possibly faulty) behaviours.There are four cases: i) Hypothesis is a top and a bottom subtreeIf Hypothesis is both a top and a bottom subtree than we precompute all actual behaviours and we can conclude that Hypothesis is testable. ii) Hypothesis is a top subtreeIf Hypothesis is a top subtree we can precompute the actual behaviour of LargerHypothesis and the faulty behaviour of Hypothesis and we can conclude thatHypothesis is not testable. iii) Hypothesis is a bottom subtreeIf Hypothesis is a bottom subtree we can precompute the faulty behaviour of Rest and we can conclude that Hypothesis is testable. iv) Hypothesis is an intermediate subtreeIf Hypothesis is an intermediate subtree we can precompute the faulty behaviour of Rest and we can conclude that Hypothesis is not testable. Technical Diagnosis of Telecommunication Equipment24 5 The implementation 25 5 The implementation 5.1 A survey of the build-up of the program The program consists of two parts: l The part that contains the domain knowledge of the HP device. l The part that implements the TDFL method. The underlying idea of our implementation is to keep these two parts totally separated. This isaccomplished by having no references what so ever to the HP device in the part that implements the TDFL method. This means that our program can be used to diagnose not only the HP devicebut any device, under the assumption that the domain knowledge of the device can be represented according to the definitions given in the following two subsections. The part of the program thatimplements the TDFL method is described in subsection 5.4. The build-up of the program is depicted in figure 5.1. Figure 5.1. The different parts of the program. 5.2 The notions of behaviour, fault and hypothesis The notions of behaviour, fault and hypothesis play an absolutely central role in the program. a) Behaviour A behaviour is a relation between a set of input-values and a set of output-values. These input- andoutput-values are pairs consisting of a reference to an existing physical line in the device, and a value on that line.For example, the behaviour of the part described in figure 5.2 has the behaviour: TDFL HP ? Technical Diagnosis of Telecommuncation Equipment26 {, , , , } n' {} Although this definition is not the one used in the program. There are three reasons for this: l We do not have enough domain knowledge to be able to represent the behaviour of a partby the definition above. What we do know is, if the part is given a correct (or expected) set of input-values, then we know the correct (expected) set of output-values. We do notknow the set of output-values that results, if the part is given a set of faulty input-values. l To be able to use the TDFL method we do not really need the set of input-values. This istrue because whenever we are about to test a part, SP say, we have already tested all parts that lay before it in the signal flow. If any of these parts should have been faulty then wewould not have reached the situation in which we are about to test SP. Thus, when we are about to test a part, we know that its set of input values are correct,and therefore we only need the set of output-values to be able to test it. This is of course only true under the assumption that we are interested in finding only one faulty part. l For simple usage we connect each behaviour with the name of the part corresponding tothat behaviour. For example the behaviour of figure 5.1 would be coded (assuming the name of the part to be abcdef): behaviour(abcdef,[`A',`1']) The first component of the second component of a behaviour, should be a reference to a physicalline in the device. Since these references are used for testing a part, they are called test-points. To test a part we have to measure at the test-point to which the particular part is attached, a task thatmust be performed by the user. To test a part then, corresponds to asking the user to make some measurements (for examplevoltage, signal level etc.) at a specific test-point. In the program we therefore let the references to physical lines consist of two parts; the name of the test-point and a pair consisting of the questionto ask the user at that specific test-point and the answer received. An example of a behaviour taken from the program is: 1 0 1 1 0 1 A B C D E F Figure 5.2 The behaviour of a part. 5 The implementation 27 behaviour(l(input_amp),[`[A3.TP6]: +2.3 V ac? `,`yes']) b) Fault A fault is a faulty behaviour. In every behaviour, for each possible set of correct input-values thereis a correct output-value, that is the output-value that will result if the part, corresponding to the behaviour, given this particular set of correct input-values functions correctly. A behaviour isfaulty if the output-value that results, if the corresponding part is given a correct set of input-values, is not the correct output-value. In the program, we sometimes just know that the behaviour is faulty, but we do not know the exactset of faulty output-values. Such a behaviour is coded by: behaviour(name_of_any_part,fault) Closely related to the notion of fault is the notion of norm. Norm is the normal behaviour of thepart corresponding to that behaviour. A behaviour is said to be normal if the output-value that results, if the corresponding part is given a correct set of input-values, is equal to the correct out-put-value. c) Hypothesis A hypothesis is a statement about a behaviour, which states that the actual behaviour of the part itrefers to is incorrect. More precisely, the statement is the negation of the statement that the part has a specific behaviour, which is the correct behaviour. This is called a negated behaviour.A hypothesis may also be a statement about a set of behaviours. In that case, the hypothesis is a statement, which states that the actual behaviours of the parts it refer to are incorrect. The negatedbehaviour then, is the negation of the statement that they all have a specific behaviour, which is their respective correct behaviour. In the program, a hypothesis is equal to a faulty behaviour (see definition above). If the hypothesisis a statement about a set of behaviours, it is coded as a list of faulty behaviours: [behaviour(Part1,fault), ..., behaviour(Partn,fault)] where Part1, ..., Partn are some parts. A hypothesis can be confirmed or refuted. A hypothesis about a single behaviour is confirmed ifthe actual behaviour of the part to which it refer differ from its norm. Otherwise it is refuted. A hypothesis about a set of behaviours is confirmed if any of the actual behaviours of the parts towhich it refer differ from their respective norm. Otherwise the hypothesis is refuted. 5.3 Representation of the domain knowledge The domain knowledge can naturally be divided into four parts: l The part containing the knowledge about the functional and physical structure of the HPdevice. Technical Diagnosis of Telecommuncation Equipment28 l The part containing the knowledge about the top-level functional structure of the HPdevice. l The part containing the knowledge about the norm of each functional and primitive partof the HP device. l The part containing the knowledge about the causal dependencies that exists among theparts of the HP device. The reason why we need a special part containing the knowledge about the top-level functionalstructure of the HP device will be explained below. The complete code implementing these four parts are found in appendix C. 5.3.1 Representing the functional and physical structure There are some properties that the choosen representation must have. It must allow us to: i) Represent the functional and physical structure of the HP device in a natural way. ii) Pick out any single part, or composite part, from a more complex (an outer-level) part. iii) For every part (single or composite), generate the set of all parts that "lay before" it in thesignal flow, that is that have at least one output signal in common with one of the input signals of this particular part. iv) For every part (single or composite), generate the set consisting of the set in iii plus thepart itself. v) For every part (single or composite), generate the set of all parts that "lay after andbeside" it in the signal flow, that is those that have at least one input signal in common with one of the output signals of this particular part or that have no output signal in com-mon with any of the input-signals of this particular part. vi) Remove any part (single or composite), or any of the sets described in iii, iv and v, froma more complex part. Since the functional and physical structure of the HP device is that of a tree, a tree representationis our obvious choice for representing the functional and physical structure. i is automatically accomplished by choosing a tree representation. ii corresponds to picking out a subtree from a tree. iii corresponds to generating all children to a specific part (single or composite). iv corresponds to generating the subtree the root of which is the particular part. v corresponds to the operation of removing the subtree the root of which is the particular part, fromthe initial tree, returning the result. vi corresponds to the operation of removing a subtree from an initial tree, returning the result. 5 The implementation 29 All these operations can be implemented by rather standard tree-traversal algorithms, which makethem efficient enough for our needs. For example, the part of figure 5.3 is coded by: tree(a,[l(b),tree(c,[l(d),l(e)]),tree(f,[tree(g,[l(h),l(i)]),l(j)])]) where l(b) should be read "b is a leaf". NoteThe notion " b is a leaf" does not necessarily means that b is a primitive part (that isa part which can not be decomposed any further), but rather that b is primitive in thesense of the outer-level part of which b is a subpart.This means that from the outer-level, b is seen as a single and atomic part. Noneof the subparts of b, if any, can be seen from this level. But, if b turns out to be thefaulty part, then b is "expanded" and the inner structure of b, if any, is revealed. There are two main reasons for this layered structure: l You may not want the diagnosing process to continue all the way down to the primitiveparts. There can be several reasons for this; it may not be possible to test or replace individual components and testing and replacing larger composite components may becheaper. l There would be several practical drawbacks with a large, single tree. First of all, the pos-sibility of making a fault while writing it down would be quit high. Secondly, the tree would be nearly impossible to understand.However, it would be more efficient to use one, single tree, instead of many small ones. There is nothing in the implementation that prevents you from coding the tree representation as alarge single tree, is just a matter of taste. In the program we use the function sub_parts to get the inner structure of part. Sub_part takes thename of a part and returns a tree, representing its internal structure. If the part is primitive b c d a e f g h i j Figure 5.3. The inner structure of a composite part. Technical Diagnosis of Telecommuncation Equipment30 sub_parts fails. 5.3.2 Representing the top-level functional structure Earlier, we said that the functional (and physical) structure of the HP device is that of a tree. Thisis true as long as we talk about the functional (and physical) structure of the device functions, but if look at the top-level functional structure of the HP device, that does not hold any longer.The HP device has four top-level functional parts, and the accurate way to represent them would be as a set, not as a tree.This asymmetric property of the HP device, brings with it a lot of unwanted complications through out the whole program. For instance, we can not represent the top-level functional partswith the tree representation described above. Instead we simply represent them as a list. But then, we can not use sub_parts to get the top-level functional parts of the HP device, but we have to useanother function called functional_parts. Functional_parts take a device, e.g. HP, as argument, and returns the list of its top-level functional parts. 5.3.3 Representing the norm As we have said before, the norm of a part (single or composite), is a behaviour, and it is repre-sented in the same way (see section 5.1, paragraph a). We also need a function to get the norm of a functional or primitive part. This function iscalled norm. Norm takes a functional or primitive part as argument, and returns the behaviour representing that parts normal behaviour, as result. 5.3.4 Representing causal dependencies When you have located a fault to a part, you know that at least one of its subparts (if it has any) isfaulty. The diagnosing process should now continue, by selecting one of these subparts (single or composite) and then test it, until a faulty subpart is found.Usually the selection is made in a more or less random way, you just pick out any subpart, since you have no reason to suspect that a particular subpart is more likely to be faulty than anyother. But sometimes you do have some information that may say: "If you know that part A, B andC's actual behaviours are A', B' and C' respectively, then this particular subpart is the most likely to be faulty". In the program, we record all the behaviours that we encounter during the diagnosing process.When we are about to select a subpart as the next hypothesis, we ask ourselves: "Do we have any information that indicates that this particular subpart is the most likely one to be faulty?" To beable to answer that question we have a function called possible_hyp, that given a part as argument, returns all the behaviours that must have been seen to be able to conclude that this part is the mostlikely one to be faulty. It should be noted that the knowledge representing the causal dependencies is optional in the sensethat the functionality of the program does not require this knowledge. If it is present it is used, if is not the choice of a hypothesis is arbitrary. 5 The implementation 31 5.4 Turning the TDFL method into a GCLA II program 5.4.1 The declarative part The trouble_shooting task is an almost direct interpretation of the corresponding task in the orig-inal TDFL method (chapter 3). We take one of the top-level functional parts and investigates the behaviour of that part. If the part is incorrect we start to diagnose it.One important issue introduced here is the fact that we save the faulty behaviour, that we recognize in confirm, on the left side (of the sequent). Later on, when we try to find hypotheses thatis more likely to be true than others, we make use of the causal dependencies of the device and in doing this we may need to know about other behaviours. We also need to save the behaviours inorder to avoid unnecessary observations, that is if we already have noticed a behaviour we do not want to do it again. Since trouble_shooting is evaluated on the right side we just use the arrow con-struct to put the behaviour on the left side. For example: ActualBehaviour -> diagnose(ActualBehaviour,FaultyBehaviour) will put ActualBehaviour on the left side of the sequent and we can continue with diagnose onthe right side. The diagnose task is quite different from the one in the original TDFL. In the first definition wehandle the case when we have reduced the faulty part to a leaf-part. The behaviour of this part is a solution to the diagnosis. This may be a part on an intermediate level in the decomposition model(i.e. it is a composite part), as well as a primitive part. In the second definition of diagnose we make the actual diagnosis. Most of the work is donein the decompose task; from the incoming faulty behaviour the task produces all the different hypotheses (Hypothesis, LargerHypothesis etc.), it decides whether Hypothesis is testable or not,if LargerHypothesis is already confirmed and precomputes, if possible the actual and possibly faulty behaviours of the parts corresponding to each hypothesis. In the original TDFL this work issplit into several tasks, decompose, testable, generateElimination etc. The reason why we make all the work in decompose is described in chapter 4.The rest of the task follows the one given in the original TDFL. If the hypothesis is testable and confirmed we diagnose it, if it is testable but not confirmed we try to confirm it and then diag-nose it etc. When we shall try to confirm the PreHypothesis we will get some trouble because it may con-sist of several hypotheses. To handle this we have introduced a second diagnose task, diagnose2, which take the hypotheses, or hypothesis, and tries to confirm one of them. If it succeeds we startto diagnose the one that was faulty, otherwise we diagnose the Hypothesis. We have combined the establish and consistent task into one confirm task. In establish we find outthe questions that we need to ask in order to establish the behaviour of the actual part and after that, in establish2, we ask them if that has not already been done. To check if the questions have beenasked we just put the behaviour on the right side, with the answer replaced by a variable, and if the behaviour has been recognized (i.e. the questions have been asked) it is on the left side of thesequent, the axiom-rule will succeed and the variable will be instantiated to the actual answer. Technical Diagnosis of Telecommuncation Equipment32 establish2(Q,Answer) <= behaviour(_,[Q,Answer]). establish2(Q,Answer) <= format(Q,[]), read(Answer). If the first clause does not succeed (i.e. the behaviour has not been recognized), we pose the ques-tion to the user. To do this we use the built-in Prolog-predicate for input/output: format and read. The decomposing task is divided into three different tasks: decompose, decompose2 anddecompose3. The first one simply finds the tree corresponding to the inner structure of the incoming part. If the incoming part is a single component we have to find the tree corresponding to itssubparts and this is done with the sub_parts task. If the incoming part is a composite part decompose does nothing.In decompose2 we find the part that we make our hypothesis about. This can be done in three different ways: if there is just one part to choose we do this and the rest- and preparts will be empty,if there is one part that is more likely to be faulty than others we choose this part and, finally, if none of these fits we simply pick one part at random (actually we pick the root of the tree corre-sponding to the inner structure of the composite part). To find parts that is more likely to be faulty we use the possible_hyp task, which tells us whatbehaviours of other parts that have to be true in order to make a particular part a possibly faulty part. By noticing if these behaviours are on the left side of the sequent (i.e. they have already beenestablished) we may choose a part that has the desired property. When we have find a part for our hypothesis we use find_hyp_pre_rest to get the pre- and restparts. Find_hyp_pre_rest traverses thetree corresponding to the inner structure of the composite part in a depth-first manner generating the subtrees or set of subtrees that correspond to each of the hypotheses; Hypothesis,LargerHypothesis, PreHypothesis and RestHypothesis. The decompose3 task makes hypotheses out of the parts that we have selected in decompose2.It also decides if Hypothesis is testable or not, if Largerhypothesis is already confirmed or not and it precomputes, if possible, the actual and possibly faulty behaviours of the parts corresponding toeach hypothesis. The program uses a number of small utility functions; strip_tree, append, member_of, tree_normetc. The most interesting of them is the if function. If is an if-then-else construct that takes three parameters; the first one is either of the two values true and false or a clause that functionally eval-uates to true or false. The second and third parameters are arbitrary conditions (see section 2.2.1.1). If the first parameter is equal to true the evaluation continues with the first condition. If the firstvalue is equal to false the evaluation continues with the second condition. If the first parameter is neither of true or false then this parameter is functionally evaluated to a boolean value and then ifcalls itself recursively with this value. if(true,then(Then),_) <= Then. if(false,_,else(Else)) <= Else. if(NotABoolean,Then,Else) #{NotABoolean \= true, NotABoolean \= false} <= (NotABoolean -> T), if(T,Then,Else). 5.4.2 The rule definition There have been several versions of the rule definition. It is probably that part of the program that 5 The implementation 33 has changed the most during our work. The very first version used almost only built-in rules andstrategies. The current version uses specialized rules and strategies for every clause in the definition. As a result of this, a query that we have used as a standard example during our work executesmore than 50 times faster with the current rules than with the first ones, although the current version of the program do a lot more than the first version. 5.4.2.1 The need for specialized strategies and rules There are three main reasons for using highly specialized rules and strategies: l We have already mentioned the first one; program speed. l The second one is perhaps less obvious. When using the built-in strategies and rules (orany other set of common rules and strategies), as the number of clauses in the program increases the harder it is to predict the consequences of changing a rule or a strategy. Fora specific clause you know that you have to change a particular rule in a certain way, but what consequences does this change bring on the evaluation of the other clauses using thesame rule? If you use specialized rules and strategies for every clause, you know that the changeof a rule or strategy only have consequences for the corresponding clause no other clauses are effected, that is the change is local. This can be seen as a form of information hiding;you group some data together with all the operations performed on it into one single object which communicates with other objects through a well defined interface.Of course, just as in any other language that support information hiding some data can be shared by several objects, which in this case corresponds to common strategies andrules. l The last but most important reason is necessity. The built-in strategies and rules may notbe sufficient for you to be able to evaluate a definition the way you want. If that is the case you have no choice but to write your own specialized rules or strategies. 5.4.2.2 A consistent method for strategy and rule specialization In our program we have consistently used a method for strategy and rule specialization. The rulesand strategies are specialized in a way so that for every definition of a clause only the appropriate strategies and rules are considered. This specialization has been accomplished by using either oftwo different methods: l When a call to a clause is made you can match out the head of the clause and the choiceof which strategy or rule to choose is then based on the instantiation of the variables in the head. l If several definitions of a clause have identical heads we make the call (i.e. d_right or d_left) and then we match out the body of the choosen definition. The choice of whichrule or strategy to choose is then based on the outlook of that body. An example of a rule of the first kind is the if rule and an example of a rule of the second kind isthe diagnose rule. Technical Diagnosis of Telecommuncation Equipment34 5.4.2.3 The strategies and rules We will now go through the rules and strategies found in appendix B. Not all of them are consid-ered, only those that may be interested in any way are mentioned. To avoid any confusion we will write names referring to clauses in the definition like this and names referring to rules and strate-gies in the rule definition like this. The top-level strategy is called gcla, and all it does is to call the d_right rule with the strategy trouble_shooting. The trouble_shooting task consists of four subtasks; member_of, functional_parts, confirm anddiagnose. The corresponding rule, also called trouble_shooting, uses the strategies functional_parts and confirm and the rules member_of and diagnose. Now you can use the v_right rule two times with the specific strategy (or rule) for each of the subtasks but since thissituation, with a task with several subtasks that should be evaluated one at time using a number of consecutive v_right rules, is very common we have introduced a new rule called v_rights whichimplements three up to five v_right rules in one single rule. The general form of v_rights is: v_rights(PT1, ... , PTn) <= ((PT1 -> (A \- C1)), (PT2 -> (A \- C2)), ..., (PTn -> (A \- Cn)) -> (A \- (C1,(C2, ( ... , Cn) ... )). We have said before that we record all behaviours that we encounter during the diagnosis on theleft side of the object level sequent. These behaviours are put on the left side of the sequent by using the arrow construct to the right, that is by using the a_right rule. But since we want to con-sider the left side as a set of behaviours and not as a list of behaviours, we cannot use the built-in a_right rule directly. Instead we have introduced a rule called new_a_right which first checksif the left side of the arrow construct is already on the left side of the sequent. If it is we simply do not put it there, if it is not we use the built-in a_right rule. Here is the new_a_right rule: new_a_right(_,T) <= member(A,As,T) -> (As \- (A -> C)). new_a_right(PT,true) <= (PT -> (As \- C)) -> (As \- (A -> C)). new_a_right(PT,false) <= (PT -> ([A|As] \- C)) -> (As \- (A -> C)). New_a_right uses the proviso member which is a deterministic version of the usual member-of-list function, that is member succeeds only once even if a member appears several times in the list: member(_,[],false). member(A,[B|_],true) :- equal(A,B). member(A,[B|R],T) :- not_equal(A,B), member(A,R,T). Since we are only interested in knowing whether a specific test-point already has been tested ornot, two behaviours are considered equal if their test-points are equal. The equality test is performed by the provisos equal and not_equal: 5 The implementation 35 not_equal(behaviour(_,[A,_]),behaviour(_,[B,_])) :- A\=B. equal(behaviour(_,[A,_]),behaviour(_,[B,_])) :- A=B. If we go back to the trouble_shooting task we see that the subtask member_of is evaluated func-tionally; it takes another clause, functional_parts, as parameter. The corresponding member_ofrule takes the strategy funtional_parts as a parameter: member_of(_,C) <= (_ \- C). member_of(_,true) <= true_right. member_of(PT,member_of(_,_,_,_)) <= d_right(_,member_of(PT,_)). member_of(PT,(_,_)) <= v_right(_,a_right(_,PT),d_right(_,member_of(PT,_))). functional_parts <= d_left(_,[],axiom(_,_,[])). More interesting are the rules and strategies that evaluates the confirm subtask. The correspondingstrategy is called confirm. Confirm consists of the two subtasks establish and consistent. Establishestablish the actual behaviour of a part and consistent then checks if this actual behaviour is consistent with the hypothesis.The establish task consists of two subtasks; tree_norm and establish2. The strategy corresponding to tree_norm is called tree_norm and the rule corresponding to establish2 is called establish. There are two ways we can establish the actual behaviour of a part; either the behav-iour is already known, that is it is already on the left side, or else the behaviour is not known so we have to ask the user. Of course, if the behaviour is known we should use that behaviour not tryingto ask the user for it. This means that we have to look on the left side to see if we can find the behaviour of the part, if we cannot we should ask the user. This is the same situation as in the new_a_right rule so we can use a similar technique using the member proviso: establish(T) <= member(behaviour(_,[Q,_]),As,T) -> (As \- establish2(Q,A)).establish(true) <= d_right(_,axiom(_,_,_)). establish(false) <= d_right(_,v_right(_,user_add_right(_,_),user_add_right(_,_))). If the behaviour is not already known we have to ask the user for it. Since GCLA does not containany IO routines of its own, we have to use the IO routines format and read of the underlying Prolog system. These routines are incorporated in the rule user_add_right: user_add_right(format(Term,Attr),PT) <= format(Term,Attr) -> (A \- format(Term,Attr)). user_add_right(read(Term),PT) <= read(Term) -> (A \- read(Term)) This results in format and read being transferred to the right side of the meta level sequent, thusbeing interpreted as ordinary Prolog calls. The rule corresponding to consistent is called consistent. Technical Diagnosis of Telecommuncation Equipment36 The last subtask in trouble_shooting is diagnose. The corresponding rule is also called diagnose. The diagnose task consists of the two subtasks decompose and if, with corresponding rules decompose and if.The decompose task consists of the subtasks sub_parts and decompose2. The strategy that corresponds to sub_parts is called sub_parts and the rule corresponding to decompose2 is called decompose2. The decompose2 task consists of the subtasks possible_hyp, find_pre_hyp_rest anddecompose3, with corresponding rules possible_hyp, find_hyp and decompose3.In every decompose step there may be some hypotheses that are more likely to be faulty than any other. A hypothesis is said to be a most possible hypothesis if some specified behavioursalready have been seen during the diagnosis. To see if a hypothesis is a most possible hypothesis or not is the task of the possible_hyp task. Since we record all the behaviours we already have seenon the left side, this task consists of checking if the specified set of behaviours is a subset of the set that consists of the behaviours on the left side. This could be done by using an explicit subset-of-set function but there is a more elegant solution. First we notice that if the left side really is a set of assumptions and not a list of assumptions then the built-in axiom rule can be seen as the usualmember-of-set function. By coding the set of specified behaviours not as a list but as a conjunction, and if we place this conjunction on the right side and then applying the v_right and axiom ruleon the obtained sequent, we will have the wanted subset-of-set function. This is performed by the possible_hyp rule: possible_hyp(T) <= (is_one(C,T)) -> (_ \- C). possible_hyp(true) <= axiom(_,_,_). possible_hyp(false) <= v_right(_,axiom(_,_,_),possible_hyp(_)). Possible_hyp uses the is_one proviso to see if the right side consists of a single behaviour or ifit consists of a conjunction of behaviours: is_one(behaviour(_,_),true). is_one(C,false) :- C \= behaviour(_,_). Many times we know that a call to a clause only results in that free variables in the head of theclause are bound, that is we use the d_right rule followed by the true_right rule. Since this isdone so often we have choosen to introduce the dt_right rule which performs exactly this in onesingle rule: dt_right <= (atom(C),clause(C,_)) -> (_ \- C). The Decompose3 task make extensive use of the infix = subtask. = consists of only a single defi-nition with no body, and its only purpose is to unify the two arguments with each other. This is an example when the dt_right is useful. The corresponding decompose3 strategy is also a perfectexample of how useful the v_rights rule is: 5 The implementation 37 decompose3 <= v_rights(dt_right,dt_right, if(v_rights(dt_right,dt_right,dt_right,dt_right,dt_right), if(v_rights(dt_right,dt_right,make_pre(_),dt_right), v_rights(dt_right,dt_right,dt_right,dt_right,make_pre(_)) ,_) ,_)). Let us return to the diagnose task. The second subtask in diagnose is the if subtask. The corre-sponding rule if takes two strategies as parameters. If the right side of the object level sequentconsist of an if clause which first parameter is bound to the value true then the evaluation continues with the first strategy. If the right side of the object level sequent consist of an if clause which firstparameter is bound to the value false then the evaluation continues with the second strategy: if(_,_,C) <= (_ \- C). if(PT1,_,if(true,_,_)) <= d_right(_,PT1). if(_,PT2,if(false,_,_)) <= d_right(_,PT2). 5.5 Diagnosing the HP device 5.5.1 The queries The program, in its present form, is only able to find one fault. The fault is refined during the diag-nosis, from the faulty functional part of the device to a primitive part. When the program has found a refined fault it halts (and answers with the refined fault) and you have to force the system to back-track in order to get a more refined fault. The queries that the user may pose to the system has two forms: "Find a faulty behaviour inHP 3552A" and "Given some behaviours, find a faulty behaviour in HP 3552A". The first one is written: \- trouble_shooting(hp_3552a, F). where F is the variable which will be instantiated to the faulty behaviour.If you already know a number of behaviours, or perhaps assume them, you may pose a query of the second form, and you write: behaviour(P1,O1), ..., behaviour(Pn,On) \- trouble_shooting(hp_3552a,F). Again, the behaviours are optional, but you should include the faulty behaviour, of the function,on the left side. Technical Diagnosis of Telecommuncation Equipment38 6 Conclusions and future work 39 6 Conclusions and future work In this section we will present some possible future extensions to our program. We will also sum-marize our experiences of GCLA II as an implementation language for knowledge based systems, and the GCLA II programming environment. 6.1 Diagnosing the HP device We have seen that with our program one can pose queries like: "Find a fault (if there exists one)in HP 3552A" and "If we know that subpart A is faulty and subpart B is correct, find a fault (if there exists one) in HP 3552A".But as we said in section 1, there are a number of other queries that a presumptive user may want to pose, for instance: "If we know that this particular part is faulty, what can we say aboutthe behaviours of the other parts (without having to ask the user)?" and "Find every fault in HP 3552A". In the following subsections we will discuss some of the difficulties in adapting our program to beable to pose queries like the ones above. We will also present some possible solutions. Due to lack of time these refinements are not included in our current implementation. 6.1.1 Finding more than one fault Theoretically the question of being able to find more than one fault at a time is a rather interestingone. In practice it may not be so though, since if the task of testing a part is very expensive it might be cheaper to locate just one fault, correct it, test the whole device again and if it still not function-ing correctly then you try to locate another fault. As we have pointed out before, there is no way we can know the behaviour of a part if the input ofthe part is known to be faulty. This means that its only meaningful to search for more faulty subparts in parallel parts. In the program the search for more solutions is accomplished by backtracking. When you havefound one faulty part you type `;' forcing the system to backtrack, searching for another solution. In our current program there are really only four choicepoints where backtracking can occur. Thefirst is in trouble_shooting, where there is a choice of which functional part to choose. The second is in diagnose, where there is a choice (if the part is a leaf-part) if the diagnosis should stop at thislevel or if the diagnosis should try to find a lower-level faulty part, the third is in the decompose step, where there is a choice of which hypotheses to generate. The last choice-point is indiagnose2, where there is a choice among the possible faulty subparts. Of these choice-points those in trouble_shooting, diagnose and diagnose2 cause no trouble, in factthey are absolutely necessary if we want to be able to find even a single fault, since they make a choice among parallel parts. The third choice-point causes trouble though. Assume that we have located the fault to the composite part in figure 6.1. The decompose step cangenerate any subpart as hypothesis, F say. Now assume that we have found every fault in F. Butthe user wants to find more faults so the program backtracks. Eventually we are back at the decom Technical Diagnosis of Telecommunication Equipment40 pose step where we started, but since we have lost all information about the previous faults in thebacktracking process, there is nothing that prevents decompose from generating E as the nexthypothesis. But this means that the faults in F will be found once again, and all the questions thatwere asked the last time will be asked once more. Actually a fault may be a solution as many times as the level in the tree on which the fault is positioned. The problem is that decompose can generate every subpart as a possible hypothesis, so we have torestrict decompose in some way. What if we restrict decompose so much that it becomes totally deterministic, that is in every decompose step we always generate the same subpart as hypothesis,say the first one (the root)? It is easy to see that we will find every possible faulty part in a composite part even if decompose is totally deterministic. Unfortunately, since it can happen that onehypothesis is more likely to be true than any other, we can not restrict decompose that much. But what we can do is to restrict decompose so that it still can generate the most possible hypothesis,but if there is no such hypothesis, the choice of hypothesis is totally deterministic. Of course there may be several "most possible" hypotheses, but since this only makes sense if they are in parallelsubparts that is not a problem. The fact that there may be a most possible hypothesis presents another problem though. If we lookat figure 6.1 again and assume that decompose generates J as the most possible hypothesis. Now,if J is faulty and there is another fault in I, this other fault will never be found. This is so becauseif J is faulty Rest1 (which contains I) is discarded, and since decompose is deterministic no morehypothesis will be generated. The only way the fault in I can be found is if I or H are also a "mostpossible" hypothesis. It seems that the only way to solve this problem is to keep track of all the parts "parallel" to thehypothesis and add these parts to the other set of hypotheses from which you choose the next hypothesis. In the original version of the TDFL method this "other" set is Rest2. Let us rewrite the decompose task.The new decompose task takes the incoming faulty behaviouras input as before, but in addition to Hypothesis, LargerHypothesis, PreHypothesis and RestHypothesis decompose now also generates a hypothesis called ParHypothesis. ParHypothesiscorresponds to all parts that are parallel to Hypothesis in the signal flow. So decompose must now be able to pick out all parts parallel to another part. It is easy to see that this can be done during thesame traversal of the tree as the one needed before to pick out the other hypotheses, which means little overhead. The new version of the diagnose task would look like: Figure 6.1 An example composite part. A B C D E F G H I J 6 Conclusions and future work 41 diagnose(behaviour(l(Comp),O),behaviour(Comp,O)). diagnose(Fault,RefinedFault) <= decompose(Fault,Hyp,LHyp,PHyp,RHyp,ParHyp,Testable,Confirmed), if(Testable, then((if(Confirmed, then((Hyp -> diagnose(Hyp,RefinedFault))), else((confirm(Hyp,ActualB,ConfirmedHyp), if(ConfirmedHyp, then(((ActualB -> diagnose(ActualB,RefinedFault)); diagnose2(ParHyp,empty_hyp,RefinedFault))), else((RHyp -> diagnose(RHyp,RefinedFault))) ))) ))), else((if(Confirmed, then((LHyp -> diagnose2(PHyp,Hyp,RefinedFault))), else((confirm(LHyp,LBehaviour,ConfirmedLHyp), if(ConfirmedLHyp, then(((LBehaviour -> diagnose2(PHyp,LBehaviour,RefinedFault)); diagnose2(ParHyp,empty_hyp,RefinedFault))), else((RHyp -> diagnose(RHyp,RefinedFault))) ))) ))) ). If Hypothesis is testable and LargerHypothesis is already confirmed then Hypothesis is both a bot-tom and a top subtree. This means that there are no parts parallel to Hypothesis, that is ParHypothesis is equal to the empty hypothesis, so we just diagnose Hypothesis as before.If Hypothesis is testable but LargerHypothesis is not already confirmed, that is Hypothesis is a bottom subtree, there may be parts parallel to Hypothesis, so if Hypothesis is confirmed we cannot just discard Rest1 as we did before. First we diagnose Hypothesis as before but if the user backtracks, searching for more faults, we call diagnose2 with ParHypothesis. If Hypothesis is not con-firmed we just continue to diagnose Rest1 as before. If Hypothesis is not testable but LargerHypothesis is already confirmed then Hypothesis is atop subtree. This means that Rest1 is empty which is equal to say that there are no parts parallel to Hypothesis, that is ParHypothesis is equal to the empty hypothesis, so we just call diagnose2 withPreHypotheis as before. If Hypothesis is not testable and LargerHypothesis is not already confirmed, that is Hypothe-sis is an intermediate subtree, there may be other parts parallel to Hypothesis, so if Hypothesis is confirmed we can not just discard Rest1 as we did before. First we call diagnose2 with PreHypoth-esis as before but if the user backtracks, searching for more faults, we call diagnose2 with ParHypothesis. If Hypothesis is not confirmed we just continue to diagnose Rest1 as before. We have used diagnose2 to diagnose ParHypothesis. The reason for this is that the task of diag-nosing the parts parallel to Hypothesis is similar to the task of diagnosing the parts that come before Hypothesis in the signal flow. In both cases you choose among a set of hypotheses by tryingto confirm each one of them, continuing the diagnosis with the first one confirmed. One important difference though, is the question of what to do if none of the hypotheses are confirmed. In thesecond case you should continue to diagnose Hypothesis, since if none of the prehypotheses are confirmed then Hypothesis is known to be faulty. But what should you do in the first case? If allof the parallel hypotheses are refuted you cannot continue the diagnosis with Rest1 since you Technical Diagnosis of Telecommunication Equipment42 already know that Hypothesis is faulty, and we cannot say anything about the behaviour of Rest1if Hypothesis is known to be faulty. The answer is then, that in the first case we should do nothing when all parallel hypotheses are refuted. This can be accomplished by calling diagnose2 with theempty hypothesis, since trying to diagnose the empty hypothesis will always fail. Of course you could introduce a new task in the first case if you want a nicer but less simplesolution. 6.1.2 Planning--turning the diagnosis backwards If we know the faulty behaviour of a particular part, what conclusions can we draw about thebehaviours of other parts? First of all, we notice that we can only draw conclusions of the behaviours of parts that depend on the faulty part, that is parts that come after the faulty part in the signalflow or composite parts which contain the faulty part as a subpart. But once again, since here is no way we can know the behaviour of a part if the input of the part is known to be faulty, we can notdraw any conclusions at all of the behaviours of the former of these parts, and the only conclusions we can draw of the behaviours of the latter of these parts are that their respective behaviours arefaulty. This lack of "backward information" also means that we can not simply start with the specifiedfaulty behaviour and then work our way up the tree until we reach the root, but instead we must start at the root diagnosing the device until we find a path that leads to the specified fault. If wecompare this situation with the disease example given in section 3, it is like knowing that a patient has a specific disease but not knowing the symptoms of that disease. The only way to find out isto start diagnosing the patient from the beginning. The problem is that when going backwards, we do not want to ask the user any questions, that isevery time we need to know the behaviour of a part we have to guess a behaviour and then continue our diagnosis with that behaviour. If we reach a dead-end we have to backtrack and guess a newbehaviour. Eventually we will find a path that leads to the specified fault, and this path of guessed behaviours is what we want to be the result of this backward diagnosis. In our program we record all the behaviours that we encounter during the diagnosing process onthe left side of the sequent. It is exactly these behaviours that we are looking for, so at the end we must have something like: behaviour1( ... ),behaviour2( ...), ...,behaviourn( ... ) \- X. so that the variable X can unify with each behaviour on the left side by the axiom rule. When we do the usual forward diagnosis we evaluate trouble_shooting, diagnose, if and diagnose2on the right side, and we use the arrow-right rule to transfer the found behaviours to the left side. But now when doing backward diagnosis we can not have both X and the functions above on thesame side, so we must evaluate trouble_shooting, diagnose, if and diagnose2 on the left side. But then we cannot use the arrow-construct since that would result in the newly encountered behav-iours being transferred to the right side, so we have to rewrite the definition to just "dump" the new behaviours on the left side. But since we do not want to write two different definitions we mustevaluate trouble_shooting, diagnose, if and diagnose2 on the left side even when we do normal forward diagnosis. This means that the queries should be written: 6 Conclusions and future work 43 behaviour1( ... ), ..., behaviourn( ... ), trouble_shooting( ... ) \- X. The new definitions of trouble_shooting, diagnose and diagnose2 (we do not have to change thedefinition of if) would look something like: trouble_shooting(Device,Fault) <= (member_of(functional_parts(Device),_,FuncPart,_), confirm(behaviour(FuncPart,fault),ActualB,true)) -> (ActualB, diagnose(_,ActualB,Fault)). diagnose(1,behaviour(l(Comp),IO),behaviour(l(Comp),IO)). diagnose(2,Fault,RefinedFault) <= decompose(Fault,Hyp,LHyp,PHyp,RHyp,ParHyp,Testable,Confirmed) -> if(Testable, then((if(Confirmed, then((Hyp, diagnose(_,Hyp,RefinedFault))), else((confirm(Hyp,ActualB,ConfirmedHyp) -> if(ConfirmedHyp, then(((ActualB, diagnose(_,ActualB,RefinedFault)), diagnose2(ParHyp,empty_hyp,RefinedFault))), else((RHyp, diagnose(_,RHyp,RefinedFault))) ))) ))), else((if(Confirmed, then((LHyp, diagnose2(PHyp,Hyp,RefinedFault))), else((confirm(LHyp,LBehaviour,ConfirmedLHyp) -> if(ConfirmedLHyp, then(((LBehaviour, diagnose2(PHyp,LBehaviour,RefinedFault)), diagnose2(ParHyp,empty_hyp,RefinedFault))), else((RHyp, diagnose(_,RHyp,RefinedFault))) ))) ))) ). diagnose2([],behaviour(l(N),O),RefinedFault) <= behaviour(l(N),O), diagnose(_,behaviour(l(N),O),RefinedFault). diagnose2([],behaviour(tree(N,_),O),RefinedFault) <= behaviour(l(N),O), diagnose(_,behaviour(l(N),O),RefinedFault). diagnose2([PreHyp|Rest],Hyp,RefinedFault) <= confirm(PreHyp,ActualB,Confirmed) -> if(Confirmed, then(((ActualB, diagnose(_,ActualB,RefinedFault)), diagnose2(Rest,empty_hyp,RefinedFault))), else(diagnose2(Rest,Hyp,RefinedFault)) ). By using the arrow-left rule we can evaluate decompose, confirm etc., on the right side, as we didbefore. The first parameter in diagnose is now needed since when evaluating diagnose on the left Technical Diagnosis of Telecommunication Equipment44 side the two definitions will be read conjunctively. We do not want to ask the user any questions so we have to rewrite the confirm task. It turns outthat it is enough to change the rule definition. When we guess the behaviour of a part shall we assume that the behaviour is faulty or that it iscorrect? The most natural seems to be to assume the behaviour to be faulty since there is a path to thespecified faulty part through this part if and only if the behaviour of this part is faulty. But this is not enough. If we look at figure 6.1 again. Assume that subpart A is the one known to be faulty. Ifwe always assume that the behaviours of the parts that we encounter during the diagnosis are faulty we will never reach A. This is so because if every part that comes before A in the signal flow isassumed to be faulty then Rest1 (which contains A) will always be discarded and no solution willever be found. Similarly, if we assume that every behaviour is correct and if the known faulty part is C we will never reach C, because if every part that comes after C in the signal flow is assumedto be correct then Rest2 (which contains C) will always be discarded a no solution will ever befound. Thus we have seen that every guessed behaviour must be able to be both faulty and correct, that isfor every hypotheses the confirm task must be able to return both the value true and the value false. Of course if we already know the behaviour of a part (if it was put on the left side of the sequentfrom the start) we do not have to guess the behaviour of that part. We also see that now we have to remove the possibility of finding more than one fault, introducedin the previous subsection. Assume that J is the part known to be faulty. When H is found to befaulty diagnose2 is called with the set of hypotheses corresponding to I and J. If I is first guessedto be faulty the diagnosis will continue with I and since this diagnosis will not lead to J the programbacktracks trying next to confirm one of the parts parallel to I. Since J is parallel to I this diagnosiswill succeed. But if the program backtracks once more I will be guessed to be correct and the diag-nose continues with the rest of the prehypotheses, that is J, and a another solution will be found.The same reasoning holds for the two places in the diagnose task where you also have the possibility of diagnosing the parallel parts to hypothesis.This restriction can be accomplished by just changing the rule definition. The confirm task consists of two tasks; establish and consistent. The second parameter ofconsistent is the actual behaviour of the part corresponding to the hypothesis. We see that if this parameter is not bound the consistent task is able to return both true and false for every hypothesis.Normally this second parameter is bound by the establish task. This is done either by asking the user or by "looking at the left side". Now, we still want the latter of these alternatives to be appli-cable but if we do not already know the actual behaviour we just let the second parameter of establish remain unbound. This can be accomplished by just changing the rules that handlesestablish. This way consistent should be able to return both the value true and the value false, for everyhypothesis of which we cannot say anything about its actual behaviour. For example. Let the composite part depicted in figure 6.1 be the top-level functional part F1, andlet us assume that subpart C is the one known to be faulty. If we pose the query: trouble_shooting(SomeDevice,behaviour(l(C),fault)) \- X. the evaluation would then proceed as follows: functional_parts in trouble_shooting will select F1 6 Conclusions and future work 45 as a possible faulty top-level function and then perhaps confirm will refute this hypothesis. Thediagnosis continues with the other top-level functional parts but this will not lead to any solution being found (assuming that C is not also a subpart in any of the other top-level functions). So,eventually the program backtracks and this time confirm will indeed confirm the hypothesis. The diagnose task is called with the actual behaviour of F1, which is not bound, and the known faultybehaviour of C. Say that the decompose task in diagnose generates the following set of hypotheses:Hypothesis={ A}, LargerHypothesis={A, B, C, D, E, F, G, H, I, J}, Rest1={} and Rest2={{B, C}, {D, E, F}, {G}, {H, I, J}}. Then diagnose2 is called with Rest2. If the confirm task in diagnose2 refutesevery hypothesis in Rest2, the diagnosis continues with Hypothesis and we will never reach C.Eventually the program backtracks and the confirm task in diagnose2 will this time confirm the hypothesis {B, C} and the diagnose task is then called with the actual behaviour of this hypothesis,which is unbound, and the known faulty behaviour of C. Assume that decompose now generatesthe following set of hypotheses: Hypothesis={ B}, LargerHypothesis={B, C}, Rest1={} andRest2={ C}. Diagnose2 is called with Rest2. If the confirm task in diagnose2 refutes every hypoth-eses in Rest2, the diagnosis continues with Hypothesis and we will never reach C. The programbacktracks and this time confirm will confirm the hypothesis { C} and the diagnose task is thencalled with the actual behaviour of this hypothesis, which is unbound, and the known faulty behaviour of C. This time the first definition of diagnose is applicable. On the left side of the sequent wenow have the actual behaviours of C, {B,C} and F1. Each of these behaviours can be bound to X bythe axiom rule. If we instead pose the query: behaviour(tree(B,[C]),correct), trouble_shooting(SomeDevice,behaviour(l(C),fault)) \- X. we will not (and shall not) reach any solution, since if C is known to be faulty the behaviour of tree(B,[C]) can not be correct. If the solution sketched above really turns out to be a possible solution to the problem of backwarddiagnosis there are a number of interesting queries that you can pose to the system. For example, the query: trouble_shooting(hp_3552a,X) \- X. would be the same as the usual forward diagnosis. The query: trouble_shooting(hp_3552a,X) \- Y. should be read: "Find a fault X in HP 3552A (if there is one) and let Y be the behaviours youencounter during this process". Suppose you want to find all those faults that makes a known behaviour true. You could then pose the query: trouble_shooting(hp_3552a,X) \- behaviour( ... ). which should be read: "Find a fault X in HP 3552A (if there is one) such that you encounter behaviour( ... ) during this process". If you want to do the diagnosis backwards, you pose the query: trouble_shooting(hp_3552a,behaviour(AnyPart, fault)) \- X. which should be read: "Let X be the conclusions we can draw from the fact that the part AnyPart Technical Diagnosis of Telecommunication Equipment46 is being faulty (without having to ask the user)". Another query is: trouble_shooting(hp_3552a,behaviour(AnyPart,fault)) \- behaviour( ... ). which should be read: "Is behaviour( ... ) one of the conclusions we can draw from the factthat the part AnyPart is being faulty (without having to ask the user)?" In everyone of the these queries you can assume behaviours from the start, just as before. The general form of a query is then: behaviourL1, ..., behaviourLn, trouble_shooting(SomeDevice, Fault) \- X, behaviourR1, ..., behaviourRm. which should be read: "If we know that behaviourL1, ..., behaviourLn are true let X be the faultsthat can be found in SomeDevice, under the constraint that behaviourR1, ..., behaviourRm alsoholds. Fault decides when the constraint is to be applicable. If Fault is a variable then the con-straint is always applicable, if Fault is bound to a faulty behaviour then the constraint is onlyapplicable when that faulty behaviour has been established (and as a side-effect the questions to the user are turned off).This means for example that: behaviourL1, ..., behaviourLn, trouble_shooting(SomeDevice, Fault) \- X, behaviourL1, ..., behaviourLn. is equal to: behaviourL1, ..., behaviourLn,trouble_shooting(SomeDevice, Fault) \- X. The practical use of backward diagnosis may be limited but, as the example queries above shouldhave demonstrated, backward diagnosis could at least serve as a method for testing the consistency of the domain knowledge. Perhaps you know that if a particular part is faulty than you should beable to conclude that this other part also is faulty. Using backward diagnosis you can test such dependencies without actually diagnosing the device. 6.2 GCLA II as an implementation language 6.2.1 GCLA II programming in general The theoretical properties of Prolog and logic programming were well known to us, but our prac-tical experience of logic (i.e. Prolog) programming were limited. In spite of this we found GCLA II easy to learn and to use. Of course, as in the experimental stage of any other project, there werebugs in the GCLA II system but only minor ones. Since the declarative semantics of GCLA II is very different from Prolog's, the lack of expe-rience of Prolog programming may not have been a disadvantage. It is usually said about the C++ language: the better you know C the worse C++ programmer you get. Perhaps you can say thesame thing about Prolog versus GCLA II programming. One way GCLA II programming differs from Prolog programming is that it can be errors at twolevels not just one. A GCLA II program consists of a declarative part and a procedural part. In 6 Conclusions and future work 47 Prolog there is just the declarative part. As a consequence, if you have a GCLA II program that isnot doing what it is supposed to do, it can be hard to say if it is the declarative part that is wrong (e.g. you have used the wrong algorithm or the wrong data representation) or if it is the proceduralpart that is wrong (e.g. the search order leads to the wrong solution, if any at all). It can happen that your declarative part is absolutely correct but the program is still not doing what it wasintended to do. As we have already pointed out in section 5, if you make the coupling between the clauses andthe rules and strategies handling them tighter by using highly specialized rules and strategies, it will be easier to prevent this kind of error to happen. 6.2.2 How we have used the specific properties of GCLA II Now, how have we used the specific properties of GCLA II in the program? Could we have accom-plished the same task using Prolog? Compared to Prolog, what has been added to GCLA is the possibility to assume conditions.This can be used in two different ways: in the clauses in the definition or in the queries. At a particular point in the program we choose among the two hypotheses; LargerHypothesisand RestHypothesis. If LargerHypothesis is confirmed we continue the diagnosis with LargerBehaviour, if it is refuted we continue the diagnosis with RestBehaviour. This could havebeen written: confirm(LargerHyp,ActualBehaviour),confirm(RestHyp,ActualBehaviour) -> diagnose(ActualBehaviour,RefinedFault) Unfortunately we cannot use this definition since this could result in the confirmation ofRestHypothesis being tried regardless of the outcome of the confirmation of LargerHypothesis, and we do not want that to happen.We see that what is really needed is an if-then-else construct at the meta-level. Time being there is no such construct (but work is currently done in that area) so we have to use another con-struct. This other construct is our if-then-else construct at the object-level. During the diagnosis process we record all behaviours that we encounter on the left side of thesequent. For example in the trouble_shooting task: ActualBehaviour -> diagnose(ActualBehaviour,FaultyBehaviour) This can be read as: "Diagnose ActualBehaviour returning the refined fault in FaultyBehaviour, while assuming ActualBehaviour". ActualBehaviour is not really anassumption since it is never evaluated, it is merely a fact that is always true. The second way you can use assumptions in GCLA II is in the queries. Using our programyou can assume behaviours in the queries, for example: behaviour(l(sine_shaper),[`[A3.TP5]: +2.3 V ac? ',`yes']) \- trouble_shooting(hp_3552a,F). which can be read: "Find a fault, F, in HP 3552A, while assuming behaviour(l(sine_shaper),[`[A3.TP5]: +2.3 V ac? ',`yes'])".Once again these behaviours are not really assumptions but true facts. If we should have used Prolog instead we would have to use a list of behaviours as an extra param-eter to trouble_shooting, diagnose, confirm etc. This would result in a more complex program, especially in the establish2 and possible_hyp tasks, where we could no longer use the rather ele Technical Diagnosis of Telecommunication Equipment48 gant solution of just "looking at the left side of the sequent", but instead we would have to intro-duce explicit tasks for going through the list of known behaviours. 6.2.3 Summary We think that the main reason for us not being able to use the specific properties of GCLA II togreater extent (e.g. using the left side of the sequent in a non-trivial manner and using different strategies and rules for different queries) is the TDFL method itself. The TDFL method is in mostparts very deterministic, in terms of what to do when a particular hypothesis has been confirmed or refuted etc. Since much of the strength of GCLA II comes from its ability of handling non-monotonic and hypothetical reasoning in a natural way, it should not come as a big surprise that it is hard to use the full strength of GCLA II in domains that by nature are in most parts deterministic.If the extensions to the program, as presented in earlier in this section, are feasible then the richness of the set of queries in GCLA II would be demonstrated. Even if our application not exemplifies all the advantages of using GCLA II as a programming lan-guage for KBSs, we think we have given at least a glimpse of the great potential of GCLA II as an implementation language for such systems. 6.3 The GCLA II programming environment We have used the GCLA debugger and the statistical package extensively during our work. Bothpackages have performed well. We have missed a couple of debugging facilities, though. First of all, assume that you have traced the execution of a program to a certain depth, n. Atthis level you find an error. Now, when you have corrected this error it would be convenient if you could just issue the command skip n, thus skipping the first n calls of the execution. Unfortu-nately, at present you cannot do that, so if you want to find the next error you have to follow the trace of the first n calls once again. This is very annoying, especially since n can be very large (sev-eral ten-thousands) in larger applications. Secondly, at present you can only place spy-points at strategies and rules. We have found verylittle use of this facility. We believe that in most cases you want to place spy-points at object level clauses, and since a strategy or meta level rule may be used in the evaluation of several object levelclauses, there is little use in placing spy-points at strategies or meta level rules in these cases. In fact the lack of the possibility of placing spy-points at object level clauses is another reason forusing highly specialized strategies and rules, in addition to the reasons given in section 5.4.2.1. 7 Acknowledgements 49 7 Acknowledgements The results presented in this paper is based on the work carried out at the KBS-lab at the SwedishInstitute of Computer Science (SICS) during the last summer. We would like to thank our supervisor at the University of Gothenburg Lars Hallna"s for introduc-ing us to GCLA thus showing us that logic programming is not just Prolog, Per Kreuger, our supervisor at SICS, for his interest and support and for pointing out errors in the draft version of thispaper, Martin Aronsson for helping us through the difficulties of the GCLA II compiler and debugger and Klas Orsva"rn for being an important discussion partner of the TDFL method and withoutwhose help the HP device still would be a great mystery. Thanks also to Lars-Henrik Eriksson and everybody else at the KBS-lab at SICS for makingour visit there a pleasant and valuable experience. Technical Diagnosis of Telecommunication Equipment50 References 51 References [Aro90] M.Aronsson, L-H. Eriksson, A. Ga"redal, L. Hallna"s, P. Olin, The ProgrammingLanguage GCLA: A Definitional Approach to Logic Programming, New Generation Computing 7(4), pp. 381-404, 1990. [Aro92] M. Aronsson, Methodology and Programming Techniques in GCLA II, ResearchReport SICS R9205, Swedish Institute of Computer Science, 1992. [Hal91] L. Hallna"s, Partial Inductive Definitions, Theoretical Computer Science vol. 87 pp.115-142, 1991. [Hp74] Operating and Service Manual Model 3552A, Transmission Test Set, -hp- Part No.03552-90002, Hewlett-Packard Company, 1974 Loveland, Colorado USA. [HS-H88] L. Hallna"s, P. Schroeder-Heister, A Proof-Theoretic Approach to LogicProgramming, published in two parts in the Journal of Logic and Computation, part I: Clauses as Rules, vol. 1(2), pp. 261-283, 1990, part II: Programs as Definitions,vol. 1(5), pp. 635-660, 1991. [Kre92] P. Kreuger, GCLA II, A Definitional Approach to Control, Extensions of LogicProgramming: Proceedings of a workshop held at SICS, February 1991, Springer Lecture Notes in Artificial Intelligence. [Ors92] Klas Orsva"rn, Adaptation of a task specific problem solving method to the featuresof an application, Paper submitted to the 7th Banff KAW 1992, Swedish Institute of Computer Science, 1992. Technical Diagnosis of Telecommunication Equipment52 A 53 Appendix A :- include_def('hp.def'). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Given a reference to an device, trouble_shooting succeeds % % if and only if there is a faulty component in the device, % % and in that case trouble_shooting returns the behaviour % % of that component. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% trouble_shooting(Device,FaultyBehaviour) <= member_of(functional_parts(Device),_,FunctionalPart,_),% Select a function. confirm(behaviour(FunctionalPart,fault),ActualBehaviour,true),% Is it faulty? (ActualBehaviour -> diagnose(ActualBehaviour,FaultyBehaviour)).% Yes - diagnose the fault. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Given a faulty behaviour, diagnose tries to refine it, % % i.e. to find a lower-level faulty behaviour. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diagnose(behaviour(l(Comp),O),behaviour(Comp,O)). diagnose(FaultyBehaviour,RefinedFaultyBehaviour) <= % Generate a hypothesis, a prehypothesis, a larger hypothesis and a rest hypothesis. decompose(FaultyBehaviour,Hypothesis,LargerHypothesis,PreHypothesis,RestHypothesis,Testable,Confirmed), if(Testable,% Is the hypothesis directly testable? then((if(Confirmed,% Yes, is it already confirmed? then((Hypothesis -> diagnose(Hypothesis,RefinedFaultyBehaviour))),% Yes, diagnose hypothesis. else((confirm(Hypothesis,ActualBehaviour,ConfirmedHyp),% No, confirm hypothesis. (ActualBehaviour -> if(ConfirmedHyp,% Is the hypothesis confirmed? then(diagnose(ActualBehaviour,RefinedFaultyBehaviour)),% Yes, diagnose hypothesis. else((RestHypothesis -> diagnose(RestHypothesis,RefinedFaultyBehaviour)))% No, diagnose rest hypothesis. )))) ))), else((if(Confirmed,% No, not testable, but is it already confirmed? then((LargerHypothesis -> diagnose2(PreHypothesis,Hypothesis,RefinedFaultyBehaviour))),% Yes, diagnose prehypothesis or hypothesis. else((confirm(LargerHypothesis,LargerBehaviour,ConfirmedLHyp),% No, confirm larger hypothesis. (LargerBehaviour -> if(ConfirmedLHyp,% Is larger hypothesis confirmed? then(diagnose2(PreHypothesis,LargerBehaviour,RefinedFaultyBehaviour)),% Yes, diagnose prehypothesis or hypothesis. else((RestHypothesis -> diagnose(RestHypothesis,RefinedFaultyBehaviour)))% No, diagnose rest hypothesis. )))) ))) ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Given a set of prehypothesis and a hypothesis, diagnose2 tries to % % confirm (at least) one of the prehypothesis. If it succeeds the next % % behaviour to diagnose, is the actual behaviour of the component corre- % % sponding to the confirmed hypothesis. If none of the prehypothesis are % % confirmed, then the next behaviour to diagnose is the given hypothesis. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diagnose2([],behaviour(l(N),O),RefinedFault) <= diagnose(behaviour(l(N),O),RefinedFault).% None of the prehypothesis have been confirmed. Continue with hypothesis. diagnose2([],behaviour(tree(N,_),O),RefinedFault) <= diagnose(behaviour(l(N),O),RefinedFault).% None of the prehypothesis have been confirmed. Continue with hypothesis. diagnose2([PreHyp|Rest],Hyp,RefinedFault) <= confirm(PreHyp,ActualBehaviour,Confirmed),% Is the first prehypothesis confirmed? if(Confirmed, then((ActualBehaviour -> diagnose(ActualBehaviour,RefinedFault))),% Yes, continue with the actual behaviour. else((ActualBehaviour -> diagnose2(Rest,Hyp,RefinedFault)))% No, continue with hypothesis. ). Technical Diagnosis of Telecommunication Equipment54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Given a hypothesis (the faulty behaviour of a part), confirm finds % % out if the hypothesis is consistent with the actual behaviour (of % % the part corresponding to the hypothesis) or not. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% confirm(Hypothesis,ActualBehaviour,Flag) <= establish(Hypothesis,ActualBehaviour),% What is the actual behaviour of the component corresponding to hypothesis. consistent(Hypothesis,ActualBehaviour,Flag).% Is the hypothesis consistent with the actual behaviour or not. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Given a hypothesis, establish returns the actual behaviour of the % % component corresponding to the hypothesis. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% establish(behaviour(P,_),behaviour(P,[Q,Answer])) <= (tree_norm(P) -> behaviour(_,[Q,_])),% Find the norm of the component. establish2(Q,Answer).% Find out the actual behaviour of the component. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Given a question, establish2 returns the answer to that question. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% establish2(Q,Answer) <= behaviour(_,[Q,Answer]). % Have we already asked the question? establish2(Q,Answer) <= format(Q,[]), % No, ask it and read(Answer). % get the answer. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Given two behaviours consistent finds out if they are consistent % % with each other. Two behaviours are consistent if they are equal, % % or if one of them is faulty and the other one differ from the norm % % of the component corresponding to that behaviour. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% consistent(behaviour(P,O),behaviour(P2,O),true) #{O \= fault}. consistent(behaviour(P,O),behaviour(P2,O2),false) #{O \= fault, eq(O,O2) \= eq(A,A)}. consistent(behaviour(P,fault),B2,true) <= (tree_norm(P) -> behaviour(_,[Q,A])),% Find the norm of the component. consistent(B2,behaviour(P,[Q,A]),false). consistent(behaviour(P,fault),B2,false) <= (tree_norm(P) -> behaviour(_,[Q,A])),% Find the norm of the component. consistent(B2,behaviour(P,[Q,A]),true). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Given a behaviour, decompose divides this behaviour into a hypothesis, % % a larger hypothesis, a prehypothesis and a rest hypothesis. A hypo- % % thesis is a faulty behaviour of a single component. A larger hypothe- % % sis is a faulty behaviour of all the components that come before the % % hypothesis component in the signal flow plus the hypothesis component. % % Prehypothesis is a faulty behaviour of all the components that come % % before the hypothesis component in the signal flow. Larger hypothesis % % is a faulty behaviour of all the components that are not included in % % any of hypothesis, prehypothesis or larger hypothesis. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% decompose(behaviour(l(P),O),Hyp,LHyp,PHyp,RHyp,Testable,Confirmed) <= (sub_parts(P) -> Tree),% Single component - find its subparts. decompose2(behaviour(Tree,O),Hyp,LHyp,PHyp,RHyp,Testable,Confirmed). decompose(behaviour(tree(N,C),O),Hyp,LHyp,PHyp,RHyp,Testable,Confirmed) <= decompose2(behaviour(tree(N,C),O),Hyp,LHyp,PHyp,RHyp,Testable,Confirmed). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % See if any hypothesis is more likely to be true than any other % % hypothesis. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% decompose2(behaviour(l(P),O),behaviour(l(P),O),behaviour(l(P),O),empty_hyp,empty_hyp,true,true). decompose2(behaviour(tree(N,C),O),Hyp,LHyp,PHyp,RHyp,Testable,Confirmed) <= possible_hyp(l(Hyp2)),% Are there any facts that say that this hypothesis is more likely to find_hyp_pre_rest(tree(N,C),Hyp2,Pre,Rest),% be true than any other? decompose3(O,Hyp2,Pre,Rest,Hyp,LHyp,PHyp,RHyp,Testable,Confirmed). % Yes, proceed. decompose2(behaviour(tree(N,C),O),Hyp,LHyp,PHyp,RHyp,Testable,Confirmed) <= find_hyp_pre_rest(tree(N,C),Hyp2,Pre,Rest), % No, just pick out any hypothesis. decompose3(O,Hyp2,Pre,Rest,Hyp,LHyp,PHyp,RHyp,Testable,Confirmed). A 55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % The actual decompose task. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% decompose3(O,Hyp2,Pre,Rest,Hyp,LHyp,PHyp,RHyp,Testable,Confirmed) <= empty_list(Pre,Testable),% If Pre is "empty" then the hypothesis is testable. empty_list(Rest,Confirmed),% If Rest is "empty" then hypothesis and larger hypothesis are already confirmed. if(Testable, then(([Rest2]=Rest, RHyp=behaviour(Rest2,O), Hyp=behaviour(l(Hyp2),fault),% Don't know the exact faulty behaviour of hypothesis LHyp=behaviour(l(Hyp2),fault),% and larger hypothesis. PHyp=empty_hyp)), else((if(Confirmed, then((Hyp=behaviour(l(Hyp2),O),% The faulty behaviour of hypothesis is known. LHyp=behaviour(tree(Hyp2,Pre),O),% The faulty behaviour of hypothesis is known. make_pre_hyp(Pre,PHyp), RHyp=empty_hyp)), else(([Rest2]=Rest, RHyp=behaviour(Rest2,O), Hyp=behaviour(l(Hyp2),fault),% Don't know the exact faulty behaviour of hypothesis LHyp=behaviour(tree(Hyp2,Pre),fault),% and larger hypothesis. make_pre_hyp(Pre,PHyp))) ))) ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Given the tree representation of the subparts of a component % % find_hyp_pre_rest finds a possible faulty component, all the components % % "above" it (that is all components whose output signal doesn't contri- % % bute to an input signal of this component) and all components "below" it % % (that is all components whose output signals contribute to the input % % signals of this component. It generate these subtrees in a depth-first, % % left-to-right order. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% find_hyp_pre_rest(l(P),P,[],[]). find_hyp_pre_rest(tree(N,C),N,C,[]). find_hyp_pre_rest(tree(N,C),Hyp,Pre,[Rest]) <= member_of(C,Prefix,Elem,Postfix),% Pick out the first child. find_hyp_pre_rest(Elem,Hyp,Pre,Rest2),% Call the procedure recursively. append(Prefix,Rest2,Rest3),% Construct the rest. append(Rest3,Postfix,Rest4), strip_tree(tree(N,Rest4),Rest).% A subtree may end up with no children -> reduce it to a node. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Given a set of trees, make_pre_hyp returns a set of hypothesis. Each of % % these hypothesis consists of the faulty behaviour of one of the trees in % % the given set. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% make_pre_hyp([],[]). make_pre_hyp([P|Rest],[behaviour(P,fault)|PreHyp]) <= make_pre_hyp(Rest,PreHyp). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Given a tree, strip_tree strip away redundant parts, i.e. a tree with no % % children is equal to a node. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% strip_tree(tree(N,[]),N). strip_tree(tree(N,[H|T]),tree(N,[H|T])). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Given a tree representation of a component, tree_norm returns the norm % % (the correct behaviour) of that component. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% tree_norm(l(P)) <= norm(l(P)).% Return the norm of the component. tree_norm(tree(N,_)) <= norm(l(N)).% The norm of a tree is equal to the norm of its node. %%%%%%%%%%%%%%% Utility procedures %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Technical Diagnosis of Telecommunication Equipment56 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Given a boolean, B, or a term that evaluates to a boolean, and two other % % terms, Term1 and Term2, then if B=true the evaluation continues with Term1, % % if B=false then the evaluation continues with Term2. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if(true,then(Then),_) <= Then. if(false,_,else(Else)) <= Else. if(NotABoolean,Then,Else) #{NotABoolean \= true, NotABoolean \= false} <= (NotABoolean -> T),% Evaluate to a boolean. if(T,Then,Else). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Given a list, L, or a term that evaluates to a list, member_of takes out a % % prefix, Pre, an element, Elem, and a postfix, Post, that satisfies: % % Pre@[E|Post] = L. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% member_of([Elem|Rest],[],Elem,Rest). member_of([E|Rest],[E|Pre],Elem,Post) <= member_of(Rest,Pre,Elem,Post). member_of(NotAList,Pre,Elem,Post) #{NotAList \= [_|_],NotAList \= []} <= (NotAList -> List),% Evaluate to a list. member_of(List,Pre,Elem,Post). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Given two lists, L1 and L2, append returns the list resulting when appending % % L1 to the front of L2. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% append([],L2,L2). append([H1|T1],L2,[H1|T3]) <= append(T1,L2,T3). append(NotAList,L2,L3) #{NotAList \= [_|_], NotAList \= []} <= (NotAList -> List),% Evaluate to a list. append(List,L2,L3). append(L1,NotAList,L3) #{NotAList \= [_|_], NotAList \= []} <= (NotAList -> List),% Evaluate to a list. append(L1,List,L3). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Given a list empty_list, returns true if the list is empty, otherwise % % empty_list returns false. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% empty_list([],true). empty_list([_|_],false). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Given two terms, = succeeds iff the two terms unify with % % each other. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% A=A. B 57 Appendix B %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Right-side rules, provisos and % % strategies. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%% Rules %%%%%%%%%% diagnose(C) <= (_ \- C). diagnose(true) <= true_right. diagnose((decompose(_,_,_,_,_,_,_),if(_,_,_))) <= v_right(_,decompose(_),if(if(new_a_right(d_right(_,diagnose(_)),_), v_right(_,d_right(_,confirm), new_a_right(if(d_right(_,diagnose(_)), new_a_right(d_right(_,diagnose(_)),_) ,_) ,_)), _), if(new_a_right(diagnose2(_),_), v_right(_,d_right(_,confirm), new_a_right(if(diagnose2(_), new_a_right(d_right(_,diagnose(_)),_) ,_) ,_)) ,_) ,_)). diagnose2(C) <= (_ \- C). diagnose2(diagnose2([],_,_)) <= d_right(_,d_right(_,diagnose(_))). diagnose2(diagnose2([_|_],_,_)) <= d_right(_,v_right(_,d_right(_,confirm), if(new_a_right(d_right(_,diagnose(_)),_), new_a_right(diagnose2(_),_) ,_))). decompose(C) <= (_ \- C). decompose(decompose(behaviour(l(_),_),_,_,_,_,_,_)) <= d_right(_,v_right(_,a_right(_,sub_parts),d_right(_,decompose2(_)))). decompose(decompose(behaviour(tree(_,_),_),_,_,_,_,_,_)) <= d_right(_,d_right(_,decompose2(_))). decompose2(C) <= (_ \- C). decompose2(true) <= true_right. decompose2((possible_hyp(_),find_hyp_pre_rest(_,_,_,_),decompose3(_,_,_,_,_,_,_,_,_,_))) <= v_rights(d_right(_,possible_hyp(_)),d_right(_,find_hyp(_)),d_right(_,decompose3)). decompose2((find_hyp_pre_rest(_,_,_,_),decompose3(_,_,_,_,_,_,_,_,_,_))) <= v_right(_,d_right(_,find_hyp(_)),d_right(_,decompose3)). find_hyp(C) <= (_ \- C). find_hyp(true) <= true_right. find_hyp((member_of(_,_,_,_),find_hyp_pre_rest(_,_,_,_),append(_,_,_),append(_,_,_),strip_tree(_,_))) <= v_rights(d_right(_,member_of(_,_)),d_right(_,find_hyp(_)),d_right(_,append(_)), d_right(_,append(_)),dt_right). possible_hyp(T) <= (is_one(C,T)) -> (_ \- C). possible_hyp(true) <= axiom(_,_,_). possible_hyp(false) <= v_right(_,axiom(_,_,_),possible_hyp(_)). Technical Diagnosis of Telecommunication Equipment58 make_pre(C) <= (_ \- C). make_pre(make_pre_hyp([],_)) <= dt_right. make_pre(make_pre_hyp([_|_],_)) <= d_right(_,make_pre(_)). establish(T) <= member(behaviour(_,[Q,_]),As,T) -> (As \- establish2(Q,A)). establish(true) <= d_right(_,axiom(_,_,_)). establish(false) <= d_right(_,v_right(_,user_add_right(_,_),user_add_right(_,_))). consistent(C) <= (_ \- C). consistent(consistent(behaviour(_,[_|_]),_,_)) <= d_right(_,true_right). consistent(consistent(behaviour(_,fault),_,_)) <= d_right(_,v_right(_,a_right(_,tree_norm),consistent(_))). if(_,_,C) <= (_ \- C). if(PT1,_,if(true,_,_)) <= d_right(_,PT1). if(_,PT2,if(false,_,_)) <= d_right(_,PT2). member_of(_,C) <= (_ \- C). member_of(_,true) <= true_right. member_of(PT,member_of(_,_,_,_)) <= d_right(_,member_of(PT,_)). member_of(PT,(_,_)) <= v_right(_,a_right(_,PT),d_right(_,member_of(PT,_))). append(C) <= (_ \- C). append(true) <= true_right. append(append(_,_,_)) <= d_right(_,append(_)). new_a_right(_,T) <= member(A,As,T) -> (As \- (A -> C)). new_a_right(PT,true) <= (PT -> (As \- C)) -> (As \- (A -> C)). new_a_right(PT,false) <= (PT -> ([A|As] \- C)) -> (As \- (A -> C)). user_add_right(format(Term,Attr),PT) <= format(Term,Attr) -> (A \- format(Term,Attr)). user_add_right(read(Term),PT) <= read(Term) -> (A \- read(Term)). dt_right <= (atom(C),clause(C,_)) -> (_ \- C). v_rights(PT1,PT2,PT3) <= ((PT1 -> (A \- C1)), (PT2 -> (A \- C2)), (PT3 -> (A \- C3))) -> (A \- (C1,(C2,C3))). v_rights(PT1,PT2,PT3,PT4) <= ((PT1 -> (A \- C1)), (PT2 -> (A \- C2)), (PT3 -> (A \- C3)), (PT4 -> (A \- C4))) -> (A \- (C1,(C2,(C3,C4)))). v_rights(PT1,PT2,PT3,PT4,PT5) <= ((PT1 -> (A \- C1)), (PT2 -> (A \- C2)), (PT3 -> (A \- C3)), (PT4 -> (A \- C4)), (PT5 -> (A \- C5))) -> (A \- (C1,(C2,(C3,(C4,C5))))). B 59 %%%%%%%%%% Provisos %%%%%%%%%% not_equal(behaviour(_,[A,_]),behaviour(_,[B,_])) :- A\=B. equal(behaviour(_,[A,_]),behaviour(_,[B,_])) :- A=B. member(_,[],false). member(A,[B|_],true) :- equal(A,B). member(A,[B|R],T) :- not_equal(A,B), member(A,R,T). is_one(behaviour(_,_),true). is_one(C,false) :- C \= behaviour(_,_). %%%%%%%%%% Strategies %%%%%%%%%% trouble_shooting <= v_rights(d_right(_,member_of(functional_parts,_)),d_right(_,confirm),new_a_right(d_right(_,diagnose(_)),_)). confirm <= v_right(_,d_right(_,v_right(_,a_right(_,tree_norm),establish(_))),consistent(_)). decompose3 <= v_rights(dt_right,dt_right, if(v_rights(dt_right,dt_right,dt_right,dt_right,dt_right), if(v_rights(dt_right,dt_right,make_pre(_),dt_right), v_rights(dt_right,dt_right,dt_right,dt_right,make_pre(_)) ,_) ,_)). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Left-side rules, provisos and % % strategies. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%% Strategies %%%%%%%%%% tree_norm <= d_left(_,[],d_left(_,[],axiom(_,_,[]))). functional_parts <= d_left(_,[],axiom(_,_,[])). sub_parts <= d_left(_,[],axiom(_,_,[])). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Top-level strategy; gcla % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% gcla <= d_right(_,trouble_shooting). Technical Diagnosis of Telecommunication Equipment60 C 61 Appendix C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% FunctionalParts returns the top level %%% %%% functional parts of the HP 3552A %%% %%% device. %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% HP 3552A %%% functional_parts(hp_3552a) <= [l(sender_level),l(sender_frequency),l(receiver_level),l(receiver_frequency)]. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Given a component subparts returns %%% %%% the internal structure of the com- %%% %%% ponent. %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Sender function - level %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Sender %%% sub_parts(sender_level) <= tree(send_osc_level_vernier,[tree(measuring_circuit_level,[tree(input_amp,[l(power_supply)])]), tree(send_osc_level,[l(power_supply)])]). %%% Send oscillator %%% sub_parts(send_osc_level) <= tree(level_range,[tree(sine_shaper,[l(integrator_and_buffer)])]). %%% Level range %%% sub_parts(level_range) <= tree(output_amp_u208,[tree(q213,[l(q214)]),l(r286),l(r287),l(r288),l(r289),l(r290),l(r291),l(r292)]). %%% Integrator & buffer %%% sub_parts(integrator_and_buffer) <= l(u204). %%% Measuring circuit %%% sub_parts(measuring_circuit_level) <= tree(logger2,[tree(logger1,[tree(summer,[l(u501),l(u502d),l(cr501),l(cr502)])]), l(controller_measuring_circuit)]). %%% Logger %%% sub_parts(logger1) <= tree(q508,[tree(q511,[tree(q513,[l(q512)])])]). sub_parts(logger2) <= tree(u505,[l(cr507)]). %%% Summer %%% sub_parts(summer) <= tree(u504,[l(cr506)]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Sender function - frequency %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Sender %%% sub_parts(sender_frequency) <= tree(measuring_circuit_frequency,[tree(comparator,[tree(u206_4,[l(power_supply)]), tree(u206_12,[l(power_supply)])]),tree(input_amp,[l(power_supply)]),tree(c207,[l(power_supply)]), tree(c208,[l(power_supply)]),tree(c209,[l(power_supply)]),tree(s3a_r,[l(power_supply)]), tree(controller,[l(power_supply)])]). %%% Measuring circuit %%% sub_parts(measuring_circuit_frequency) <= tree(pll,[tree(sine_wave_to_square_wave_converter,[l(u501),l(u502d)])]). %%% PLL %%% sub_parts(pll) <= tree(vco_comparator_u507,[tree(u508,[tree(u509,[l(u510)])])]). Technical Diagnosis of Telecommunication Equipment62 %%% Sine wave to square wave converter %%% sub_parts(sine_wave_to_square_wave_converter) <= tree(q514,[l(cr509),l(u506)]). %%% U206, pin 12 %%% sub_parts(u206_12) <= tree(u206a,[tree(q217,[l(r200)])]). %%% U206, pin 4 %%% sub_parts(u206_4) <= tree(u206b,[tree(q217,[l(r200)])]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Receiver function - level %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Receiver %%% sub_parts(receiver_level) <= tree(auto_amp_ranging,[tree(controller,[l(power_supply)]),tree(function_select,[l(power_supply)])]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Receiver function - frequency %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Receiver %%% sub_parts(receiver_frequency) <= tree(measuring_circuit_frequency,[tree(controller,[l(power_supply)])]). %%%%%%%%%%%%%%%%%%%% %%% Power supply %%% %%%%%%%%%%%%%%%%%%%% %%% Power supply %%% sub_parts(power_supply) <= tree(c810_8,[tree(c805_7,[l(u801_5)])]). %%% C810, pin 8 %%% sub_parts(c810_8) <= tree(c810,[tree(u803,[tree(c806,[l(cr807),l(cr805)])])]). %%% C805, pin 7 %%% sub_parts(c805_7) <= tree(c805,[tree(u802,[tree(c804,[tree(cr808,[l(cr807)]),tree(cr806,[l(cr805)])])])]). %%% U801, pin 5 %%% sub_parts(u801_5) <= tree(u801,[tree(c802,[tree(c801,[tree(cr804,[l(cr803)]),tree(cr802,[l(cr801)])])])]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Given a component norm returns the norm, %%% %%% i.e. the correct behaviour of that com- %%% %%% ponent. The behaviour consists of the %%% %%% question you must ask to be able to es- %%% %%% tablish the norm and its corresponding %%% %%% answer. %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Sender function - level %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Sender %%% norm(l(sender_level)) <= behaviour(sender_level,['[LEVEL RANGE/VERNIER]: All ranges (-60 to -50,-50 to -40,...,0 to 10) alright?~nLevel vernier > 10dBm? ','yes, yes']). %%% Send oscillator level vernier %%% norm(l(send_osc_level_vernier)) <= behaviour(l(send_osc_level_vernier),['[SEND OSCILLATOR LEVEL VERNIER]: Does the component function correctly? ','yes']). %%% Send oscillator level %%% norm(l(send_osc_level)) <= behaviour(send_osc_level,['[A3.TP6]: Do the measured values agree with the values in the table? ','yes']). %%% Measuring circuit %%% norm(l(measuring_circuit_level)) <= behaviour(measuring_circuit_level,['[A1.TP16]: Puls similar? ','yes']). C 63 %%% Input amplifier %%% norm(l(input_amp)) <= behaviour(l(input_amp),['[A3.TP14]: Puls similar? ','yes']). %%% Level range %%% norm(l(level_range)) <= behaviour(level_range,['[A3.TP6]: Do the measured values agree with the values in the table? ','yes']). %%% Sine shaper %%% norm(l(sine_shaper)) <= behaviour(l(sine_shaper),['[A3.TP5]: +2.3 V ac? ','yes']). %%% Integrator & buffer %%% norm(l(integrator_and_buffer)) <= behaviour(integrator_and_buffer,['[A3.TP4]: Puls similar? ','yes']). %%% Level range components %%% norm(l(output_amp_u208)) <= behaviour(l(output_amp_u208),['[A3.TP6]: Do the measured values agree with the values in the table? ','yes']). norm(l(q214)) <= behaviour(l(q214),['[A3.Q214]: Does the component function correctly? ','yes']). norm(l(q213)) <= behaviour(l(q213),['[A3.Q213]: Does the component function correctly? ','yes']). norm(l(r286)) <= behaviour(l(r286),['[A3.R286]: Does the component function correctly? ','yes']). norm(l(r287)) <= behaviour(l(r287),['[A3.R287]: Does the component function correctly? ','yes']). norm(l(r288)) <= behaviour(l(r288),['[A3.R288]: Does the component function correctly? ','yes']). norm(l(r289)) <= behaviour(l(r289),['[A3.R289]: Does the component function correctly? ','yes']). norm(l(r290)) <= behaviour(l(r290),['[A3.R290]: Does the component function correctly? ','yes']). norm(l(r291)) <= behaviour(l(r291),['[A3.R291]: Does the component function correctly? ','yes']). norm(l(r292)) <= behaviour(l(r292),['[A3.R292]: Does the component function correctly? ','yes']). %%% Integrator & buffer components %%% norm(l(u204)) <= behaviour(l(u204),['[A3.TP4]: Puls similar? ','yes']). %%% Logger 2 %%% norm(l(logger2)) <= behaviour(logger2,['[A1.TP16]: Puls similar? ','yes']). %%% Logger 1 %%% norm(l(logger1)) <= behaviour(logger1,['[A1.TP17]: 12.7 V? ','no']). %%% Summer %%% norm(l(summer)) <= behaviour(summer,['[A1.W10]: 1.3 V dc? ','yes']). /* %%% Averaging detector %%% norm(l(averaging_detector_level)) <= behaviour(averaging_detector_level,['[A1.TP19]: 1.3 V & -55 dBm? ','yes']). */ %%% Controller - measuring circuit %%% norm(l(controller_measuring_circuit)) <= behaviour(l(controller_measuring_circuit),['[A1.TP15]: Puls similar? ','yes']). %%% Logger 2 components %%% norm(l(q508)) <= behaviour(l(q508),['[A1.TP17]: 12.7 V? ','no']). norm(l(q511)) <= behaviour(l(q511),['[A1.Q511]: Does the component function correctly? ','yes']). norm(l(q513)) <= behaviour(l(q513),['[A1.Q513]: Does the component function correctly? ','yes']). norm(l(q512)) <= behaviour(l(q512),['[A1.Q512]: Does the component function correctly? ','yes']). Technical Diagnosis of Telecommunication Equipment64 %%% Logger 1 components %%% norm(l(u505)) <= behaviour(l(u505),['[A1.TP16]: Puls similar? ','yes']). norm(l(cr507)) <= behaviour(l(cr507),['[A1.CR507]: Does the component function correctly? ','yes']). %%% Summer components %%% norm(l(u504)) <= behaviour(l(u504),['[A1.W10]: 1.3 V dc? ','yes']). norm(l(cr506)) <= behaviour(l(cr506),['[A1.CR506]: Does the component function correctly? ','yes']). %%% Averaging detector components %%% norm(l(u501)) <= behaviour(l(u501),['[A1.U501]: Does the component function correctly? ','yes']). norm(l(u502d)) <= behaviour(l(u502d),['[A1.U502d]: Does the component function correctly? ','yes']). norm(l(cr501)) <= behaviour(l(cr501),['[A1.CR501]: Does the component function correctly? ','yes']). norm(l(cr502)) <= behaviour(l(cr502),['[A1.CR502]: Does the component function correctly? ','yes']). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Sender function - frequency %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Sender %%% norm(l(sender_frequency)) <= behaviour(sender_frequency,['[FREQUENCY RANGE]: Which range position is wrong? ','all ok']). %%% Measuring circuit %%% norm(l(measuring_circuit_frequency)) <= behaviour(measuring_circuit_frequency,['[A1.TP10]: Puls similar?~nIf not specify kind of fault (no puls/short puls/level fault) ','yes']). %%% Comparator %%% norm(l(comparator)) <= behaviour(l(comparator),['[COMPARATOR]: Does the component function correctly? ','yes']). %%% U206, pin 12 %%% norm(l(u206_12)) <= behaviour(u206_12,['[A3.U206, pin 12]: Do the measured voltage values agree with the values in the table? ','yes']). %%% U206, pin 4 %%% norm(l(u206_4)) <= behaviour(u206_4,['[A3.U206, pin 4]: Do the measured voltage values agree with the values in the table? ','yes']). %%% Sender components %%% norm(l(c207)) <= behaviour(l(c207),['[A3.C207]: Does the component function correctly? ','yes']). norm(l(c208)) <= behaviour(l(c208),['[A3.C208]: Does the component function correctly? ','yes']). norm(l(c209)) <= behaviour(l(c209),['[A3.C209]: Does the component function correctly? ','yes']). norm(l(s3a_r)) <= behaviour(l(s3a_r),['[A3.S3A(R)]: Does the component function correctly? ','yes']). %%% Controller %%% norm(l(controller)) <= behaviour(l(controller),['[CONTROLLER]: Does the component function correctly? ','yes']). %%% Input amplifier already implemented %%% PLL %%% norm(l(pll)) <= behaviour(pll,['[A1.TP10]: Puls similar? ','yes']). %%% Sine wave to square wave converter %%% norm(l(sine_wave_to_square_wave_converter)) <= behaviour(sine_wave_to_square_wave_converter,['[A3.TP12]: Puls similar? ','yes']). /* %%% Averaging detector %%% norm(l(averaging_detector_frequency)) <= behaviour(averaging_detector_frequency,['[A1.TP13]: Puls similar? ','yes']). */ C 65 %%% PLL components %%% norm(l(vco_comparator_u507)) <= behaviour(l(vco_comparator_u507),['[A1.TP10]: Puls similar? ','yes']). norm(l(u508)) <= behaviour(l(u508),['[A1.H10]: Do the measured values agree with the values in the table? ','yes']). norm(l(u509)) <= behaviour(l(u509),['[A1.U509]: Does the component function correctly? ','yes']). norm(l(u510)) <= behaviour(l(u510),['[A1.U510]: Does the component function correctly? ','yes']). %%% Sine wave to square wave converter components %%% norm(l(q514)) <= behaviour(l(q514),['[A3.TP12]: Puls similar? ','yes']). norm(l(u506)) <= behaviour(l(u506),['[A1.U506]: Does the component function correctly? ','yes']). norm(l(cr509)) <= behaviour(l(cr509),['[A1.CR509]: Does the component function correctly? ','yes']). /* %%% Averaging detector components %%% %%% U501 already implemented. %%% U502d already implemented. */ %%% U206, pin 12 components %%% norm(l(u206a)) <= behaviour(l(u206a),['[A3.U206, pin 12]: Do the measured voltage values agree with the values in the table? ','yes']). norm(l(q217)) <= behaviour(l(q217),['[A3.Q217]: Does the component function correctly? ','yes']). norm(l(r200)) <= behaviour(l(r200),['[A3.R200]: Does the component function correctly? ','yes']). %%% U206, pin 4 components %%% norm(l(u206b)) <= behaviour(l(u206b),['[A3.U206, pin 4]: Do the measured voltage values agree with the values in the table? ','yes']). %%% Q217 already implemented. %%% R200 already implemented. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Receiver function - level %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Receiver %%% norm(l(receiver_level)) <= behaviour(receiver_level,['[LEVEL CHECK]: Level? ','+7dBm']). %%% Receiver components %%% norm(l(auto_amp_ranging)) <= behaviour(l(auto_amp_ranging),['[A5.AUTOMATIC AMPLITUDE RANGING]: Does the component function correctly? ','yes']). norm(l(function_select)) <= behaviour(l(function_select),['[A5.FUNCTION SELECT]: Does the component function correctly? ','yes']). %%% Controller already implemented. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Receiver function - frequency %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Receiver %%% norm(l(receiver_frequency)) <= behaviour(receiver_frequency,['[FREQUENCY CHECK]: Frequency = 2000 Hz? ','yes']). %%% Receiver components %%% %%% Measuring circuit frequency already implemented %%% Controller already implemented. %%%%%%%%%%%%%%%%%%%% %%% Power supply %%% %%%%%%%%%%%%%%%%%%%% %%% Power supply %%% norm(l(power_supply)) <= behaviour(power_supply,['[A5.TP6]: -12.5V & no ripple? ','yes']). Technical Diagnosis of Telecommunication Equipment66 %%% Power supply components %%% norm(l(c810_8)) <= behaviour(c810_8,['[A5.TP6]: -12.5V & no ripple? ','yes']). norm(l(c805_7)) <= behaviour(c805_7,['[A5.TP5]: +12V & no ripple? ','yes']). norm(l(u801_5)) <= behaviour(u801_5,['[A5.TP4]: +5 V & no ripple? ','yes']). %%% U801, pin 5 components %%% norm(l(u801)) <= behaviour(l(u801),['[A5.TP4]: +5 V & no ripple? ','yes']). norm(l(c802)) <= behaviour(l(c802),['[A5.TP4a]: +8.5 V & no ripple? ','yes']). norm(l(c801)) <= behaviour(l(c801),['[A5.C801]: Does the component function correctly? ','yes']). norm(l(cr802)) <= behaviour(l(cr802),['[A5.CR802]: Does the component function correctly? ','yes']). norm(l(cr801)) <= behaviour(l(cr801),['[A5.CR801]: Does the component function correctly? ','yes']). norm(l(cr803)) <= behaviour(l(cr803),['[A5.CR803]: Does the component function correctly? ','yes']). norm(l(cr804)) <= behaviour(l(cr804),['[A5.CR804]: Does the component function correctly? ','yes']). %%% C805, pin 7 components %%% norm(l(c805)) <= behaviour(l(c805),['[A5.TP5]: +12V & no ripple? ','yes']). norm(l(u802)) <= behaviour(l(u802),['[A5.U802]: Does the component function correctly? ','yes']). norm(l(c804)) <= behaviour(l(c804),['[A5.C804]: Does the component function correctly? ','yes']). norm(l(cr805)) <= behaviour(l(cr805),['[A5.CR805]: Does the component function correctly? ','yes']). norm(l(cr806)) <= behaviour(l(cr806),['[A5.CR806]: Does the component function correctly? ','yes']). norm(l(cr807)) <= behaviour(l(cr807),['[A5.CR807]: Does the component function correctly? ','yes']). norm(l(cr808)) <= behaviour(l(cr808),['[A5.CR808]: Does the component function correctly? ','yes']). %%% C810, pin 8 components %%% norm(l(c810)) <= behaviour(l(c810),['[A5.TP6]: -12.5V & no ripple? ','yes']). norm(l(u803)) <= behaviour(l(u803),['[A5.U803]: Does the component function correctly? ','yes']). norm(l(c806)) <= behaviour(l(c806),['[A5.C806]: Does the component function correctly? ','yes']). %%% CR805 already implemented. %%% CR807 already implemented. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% The relation between a faulty behaviour %%% %%% of a component and the corresponding %%% %%% behaviour of its 'supercomponent' that %%% %%% results from this faulty behaviour. %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Receiver - level %%% possibleHyp(l(function_select)) <= (behaviour(receiver_level,['[LEVEL CHECK]: Level? ','+1dBm'])). possibleHyp(l(auto_amp_ranging)) <= (behaviour(receiver_level,['[LEVEL CHECK]: Level? ','-7-(n*10)dBm'])). possibleHyp(l(controller)) <= (behaviour(receiver_level,['[LEVEL CHECK]: Level? ','other fault'])). %%% Sender - level %%% possibleHyp(l(send_osc_level_vernier)) <= (behaviour(sender_level,['[LEVEL RANGE/VERNIER]: All ranges (-60 to -50,-50 to -40,...,0 to 10) alright?~nLevel vernier > 10dBm? ','yes, no'])). %%% Sender - frequency %%% possibleHyp(l(u206_12)) <= (behaviour(sender_frequency,['[FREQUENCY RANGE]: Which range position is wrong? ','all wrong'])). possibleHyp(l(u206_4)) <= (behaviour(sender_frequency,['[FREQUENCY RANGE]: Which range position is wrong? ','all wrong'])). possibleHyp(l(c207)) <= (behaviour(sender_frequency,['[FREQUENCY RANGE]: Which range position is wrong? ','40Hz-600Hz'])). possibleHyp(l(c208)) <= C 67 (behaviour(sender_frequency,['[FREQUENCY RANGE]: Which range position is wrong? ','200Hz-2kHz'])). possibleHyp(l(c209)) <= (behaviour(sender_frequency,['[FREQUENCY RANGE]: Which range position is wrong? ','2kHz-60kHz'])). possibleHyp(l(s3a_r)) <= (behaviour(sender_frequency,['[FREQUENCY RANGE]: Which range position is wrong? ','Hold tone'])). possibleHyp(l(measuring_circuit_frequency)) <= (behaviour(sender_frequency,['[FREQUENCY RANGE]: Which range position is wrong? ','60kHz-77kHz'])). %%% R200 %%% possibleHyp(l(r200)) <= (behaviour(u206_12,['[A3.U206, pin 12]: Do the measured voltage values agree with the values in the table? ','no, pin 12 wrong']), behaviour(u206_4,['[A3.U206, pin 4]: Do the measured voltage values agree with the values in the table? ','no, pin 4 wrong'])). possibleHyp(l(r200)) <= (behaviour(u206_4,['[A3.U206, pin 4]: Do the measured voltage values agree with the values in the table? ','no, pin 4 wrong']), behaviour(u206_12,['[A3.U206, pin 12]: Do the measured voltage values agree with the values in the table? ','no, pin 12 wrong'])). %%% Q217 %%% possibleHyp(l(q217)) <= (behaviour(u206_12,['[A3.U206, pin 12]: Do the measured voltage values agree with the values in the table? ','no, pin 12 wrong']), behaviour(u206_4,['[A3.U206, pin 4]: Do the measured voltage values agree with the values in the table? ','no, pin 4 wrong'])). possibleHyp(l(q217)) <= (behaviour(u206_4,['[A3.U206, pin 4]: Do the measured voltage values agree with the values in the table? ','no, pin 4 wrong']), behaviour(u206_12,['[A3.U206, pin 12]: Do the measured voltage values agree with the values in the table? ','no, pin 12 wrong'])). %%% Measuring circuit - frequency %%% possibleHyp(l(vco_comparator_u507)) <= (behaviour(measuring_circuit_frequency,['[A1.TP10]: Puls similar?~nIf not specify kind of fault (no puls/short puls/level fault) ','no, no puls']), behaviour(sine_wave_to_square_wave_converter,['[A3.TP12]: Puls similar? ','yes'])). possibleHyp(l(vco_comparator_u507)) <= (behaviour(measuring_circuit_frequency,['[A1.TP10]: Puls similar?~nIf not specify kind of fault (no puls/short puls/level fault) ','no, level fault']), behaviour(sine_wave_to_square_wave_converter,['[A3.TP12]: Puls similar? ','yes'])). possibleHyp(l(pll)) <= (behaviour(measuring_circuit_frequency,['[A1.TP10]: Puls similar?~nIf not specify kind of fault (no puls/short puls/level fault) ','no, short puls']), behaviour(sine_wave_to_square_wave_converter,['[A3.TP12]: Puls similar? ','yes'])). Technical Diagnosis of Telecommunication Equipment68 D 69 Appendix D In the figures that follows devices, functions and composite parts are written like: HP 3552A, sub-parts are written like: input_amp and test-points are written like: A3.TP14. The signal flow is frombottom of page to top of page. level range/level vernier sender_level frequency range sender_frequency level check receiver_level receiver_frequency frequency check HP 3552A send_osc_level_vernier measuring_circuit_level input_amp power_supply send_osc_level power_supply A1.TP16 A3.TP14 A5.TP6 A3.TP6 A5.TP6 send oscillator level vernier Sender level Technical Diagnosis of Telecommunication Equipment70 Send osc level level_range sine_shaper integrator_and_buffer A3.TP6 A3.TP5 A3.TP4 Level range output_amp_u208 q213 q214 r286 r287 r288 r289 r290 r291 r292 A3.TP6 A3.Q213 A3.Q214 A3.R286 A3.R287 A3.R288 A3.R289 A3.R290 A3.R291 A3.R292 D 71 Integrator and buffer u204 A3.TP4 u501 u502d cr501 cr502 summer logger1 logger2 controller_measuring_circuit A1.TP16 A1.TP17 A1.TP15 A1.CR502A1.CR501A1.U502dA1.U501 A1.W10 Measuring circuit level Logger 2 u505 cr507 A1.TP16 A1.CR507 Logger 1 q508 q511 q513 q512 A1.TP17 A1.Q511 A1.Q513 A1.Q512 Summer u504 cr506 A1.W10 A1.CR506 Technical Diagnosis of Telecommunication Equipment72 Sender frequency measuring_circuit_frequency comparator input_amp controller u206_12 c209c208c207 s3a(r) power_supply power_supply power_supply power_supplypower_supply power_supply power_supply u206_4 comparator A3.TP14 A3.U206, pin 4 A3.U206, pin 12 A5.TP6 A5.TP6 A5.TP6 A5.TP6 A5.TP6 A5.TP6 A3.C207 A3.C208 A3.C209 A3.S3A(R) A5.TP6 controller A1.TP10 power_supply A5.TP6 sine_wave_to_square_wave_converter Measuring circuit frequency pll u501 u502d A1.TP10 A3.TP12 A1.U501 A1.U502d PLL vco_comparator_u507 u508 u509 u510 A1.TP10 A1.H10 A1.U509 A1.U510 D 73 Sine wave to square wave converter q514 cr509 u506 A3.TP12 A1.CR509 A1.U506 U206, pin 12 u206a q217 r200 A3.U206, pin 12 A3.Q217 A3.R200 U206, pin 4 u206b q217 r200 A3.U206, pin 4 A3.Q217 A3.R200 Receiver level auto_amp_ranging controller function_select power_supply power_supply automatic amplitude ranging controller A5.function select A5.TP6 A5.TP6 Technical Diagnosis of Telecommunication Equipment74 Receiver frequency measuring_circuit_frequency controller power_supply A1.TP10 controller A5.TP6 Power supply c810_8 c805_7 u801_5 A5.TP4 A5.TP5 A5.TP6 D 75 C810, pin 8 c810 c803 u806 A5.C806 A5.U803 A5.TP6 cr807 cr805 A5.CR805A5.CR807 C805, pin 7 c805 u802 c804 cr808 cr806 cr807 cr805 A5.TP5 A5.U802 A5.C804 A5.CR808 A5.CR806 A5.CR807 A5.CR805 U801, pin 5 u801 c802 c801 cr804 cr802 cr803 cr801 A5.TP4 A5.TP4a A5.C801 A5.CR804 A5.CR802 A5.CR803 A5.CR801