Technical Failure Management and Root Cause Prediction with an Expert System

I stumbled across PROLOG by chance when I was looking for literature on expert systems in our campus library: there were still a few ‘old’ books in the basement of the library, including Bratko and Hans Kleine Bünning. As a PROLOG novice, I started with those…

We operate a whole range of different accelerators on our campus. Technical failures must be rectified quickly so that researchers can work on the accelerators with as little interruption as possible. There is hardly any time to analyze the cause of a fault in detail and see if there are already solutions available. My idea: An “expert system” (ES) could take over this research and immediately determine and suggest possible causes (including their frequencies and effective countermeasures) from the knowledge database. To do this, I would like to use methods such as “fault tree analysis,” “failure mode and effect analysis,” “8D,” and similar tools. I have not yet found a comparable current and ongoing ES to use as a model.

I have already set up the knowledge database as a relational DB. The ES could access it for these analyses. Available programming languages would then be PL/SQL, Python, Java, and perhaps Rust in the future. PROLOG (still?) not. How is it that PROLOG or Lisp are so far in the background? Or is that misleading?

I have now ordered more books from antiquarian bookshops: I. Bratko: “PROLOG Programming for Artificial Intelligence,” Kluzniak and Szpakowciz: “Prolog for Programmers (Apic Studies in data processing No. 24),” Russel and Norvig: “Artificial Intelligence: A modern approach,” W. F. Clocksin: “Clause and Effect…” and D. Merritt: “Building Expert Systems in Prolog.” The only new literature I have found is (almost) exclusively Wolfgang Ertel: “Grundkurs Künstliche Intelligenz” (Basic Course in Artificial Intelligence).

Together with my books and the incredible amount of resources here in this SWI forum, I now want to start learning PROLOG and planning my 1st prototype. To ensure a minimum level of acceptance on campus, this also includes answering my personel questions such as:

  • “Can I learn PROLOG quickly and well enough?” (I hope so…)

Or those of my younger colleagues:

  • “Is there a library for Python?”

    “Hey, chatbots/LLMs are the hot stuff today, not an old language from the 80s!”

    “Can I connect this to an LLM instead of learning the PROLOG language?”

I would like to be able to present at least one prototype by summer 2026.

Viele Grüße / Best rgards
Siegfried

2 Likes

I am primarily a software engineer, so few considerations mainly from that point of view:

  • The level of standardization of Prolog is not ideal, so you’d rather have to stick to a specific system: and, IMO, SWI-Prolog would be a great candidate in many ways, surely among the open and free systems, with the level of functionality it offers and the various extensibility points.

  • Learning Prolog IMO is not easy. For some reference, I’d say it takes from few days to few weeks to an experienced programmer to learn to some decent level any programming language, but Prolog is very different, so make that few weeks to few months, to even few years when it comes to all the levels of meta-programming…

  • OTOH, Prolog, which means anyway a full-fledge programming language, I’d say is an ideal (as in most natural and most expressive) language for some scenarios, not for all…

Let me indeed ask you a question there: “expert system” in the good old days had nothing to do with learning systems. If I am not asking too much, do you have anything specific in mind as to how/where you would use Prolog?

Because most programmers are not really that good at programming, and procedural languages hold their hands the best.

Currently at TIOBE Index - TIOBE , Lisp is at 23 and Prolog is at 26. Note that Prolog is an extremely rare type of programming language - logical rather than functional.

That’s not the real question. The real question is not whether you can learn Prolog or Python or Java etc. quickly. The real question is whether you can solve this particular problem, using the language and its available libraries/helpers, in time. Of the 8,000+ programming languages out there :grinning_face:

A library might be useful, but you’ll have to learn how to use it :wink:

Yes - SWI-Prolog -- Calling Prolog from Python

Prolog is from 1972 and still going, with no successor taking its crown as the general-purpose logical programming language.

When an LLM produces wrong answers: who gets the blame, who notices the mistake, and who fixes the “code”?

Not with much success, I expect - LLMs are not intelligent, and can spew out buggy code. If people are relying on LLMs rather than their own brains, then who is going to be competent to fix the code?

...do you have anything specific in mind as to how/where you would use Prolog?

My conceptual idea is not yet fully developed—in my opinion, the quality of the data is also not yet satisfactory, but that doesn’t matter. My main concern is roughly as follows:

Some of the error messages are reported automatically and entered into the knowledge database, while others are entered manually by the operations crew. The error analysis is then documented in the knowledge database by the analysis teams. This means that metadata is added to the error message, causes are determined and entered. Countermeasures are then developed, implemented, tested for effectiveness, and also entered. In this way, knowledge grows in the form of facts that the ES can access. At Merrit, this corresponds to “working storage” (Merrit1998, p.2, fig.1.1).

As a domain and knowledge engineer, I enter the rules in the “Knowledge Base”: “If power glitch then beam loss.” If error messages are causally related (beam loss due to power supply failure due to voltage fluctuations, etc.), I link these errors in the database to form a causal chain. This also expands the Knowledge Base.

Further information is taken into account: What was the status of the accelerator during the error? Were the users performing a specific procedure at the time, etc.?

I understand each error message as a series of queries to PROLOG:

  1. Are there a) other identical or b) similar errors related to this vacuum pump failure?
  2. What known possible and actual causes have already been identified and how often?
  3. Which measures were effective and which were not?
  4. Based on 1, 2, and 3: Which cause(s) are most likely and which measures can be recommended as effective?

The information is given to the analysis team to speed up their work—and later ends up back in the database, of course to make the Expert a little smarter next time. Of course, this is not yet learning like ML, but perhaps something like “learning from observations,” as described by Russel and Norvig, could be implemented at a later date. At the moment, however, this is as far beyond my capabilities as the moon is from the earth…

Well, as you can see, my specification is still not complete and I should start with a stupid expert first.:thinking:

Viele Grüße | Best regards

Siegfried

Jepp. In fact, we are already conducting such experiments. We feed the basic specifications, e.g., of magnets and current operating data, into an LLM and then ask it how the accelerator can be better adjusted. This works in principle (apparently, I’m no expert on this). But what if a hallucinating LLM causes a billion-euro research machine to break down… That’s why I like experts that run locally, are rule-based, and generate transparent decisions…

Viele Grüße | Best Regards

Siegfried

Well, sounds like expert systems by the book, which even requires some level of meta-analysis (e.g., not knowing anything else, “error” vs “incident” I would question). ML is especially good for “learning the parameters”, i.e. the parameters of the/a model: but whether there is room for learning any parameters very much depends on the specific problem domain, and in fact on the specific model, here of expert knowledge, the meta-analysis comes up with.

Usually these domains are relatively neat and simple, such that fixed rules work, maybe with some confidence level attached: anyway, except for no-risk actions, which can be fully automated, the final decision remains by the human operator. And I see no room for ML there. On the other hand of that spectrum, deciding the next move in chess is just not a job for exhaustive search or modelling: whence ML to learn approximations / clustering / distance metrics, and similar.

Anyway, thanks for the follow-up: interesting project…

Also see:

Useful Prolog references

Hello. If understand correctly, your goal is to learn enough Prolog to be able to code an Expert System (ES) to analyse technical failures in accelerators used at your university, by your students?

If so, I would ask: have you considered doing the same thing but using another language that you already know well? Most of the enterprise software I’ve worked with was an ad-hoc ES, written in a combination of standard industry languages, usually Java or C# for the front-end and SQL for the back-end. For example, I worked in a company that wrote software for debit card transactions under the EMV standard, implemented as a very complex and detailed rule-based system in Java. In another example I worked on a debt recovery and management system that implemented a byzantine set of debt-related rules in C#, and connected to a SQL database. In yet another example I did a stint in a Cobol shop that managed a tiny part of a vast system that managed millions of financial transactions for a card payment network running on IBM mainframes (in 2014!).

All those systems, and more, were/are Expert Systems in practice, even though the term “Expert System” is not known to the people who coded them, and maintained them (I know because I checked). The fact that the people who create those systems don’t know they are creating expert systems means they have to re-invent the wheel and rediscover all the mistakes and tricks that they could have found in the Expert Systems literature of old, if they knew it exists.

I digress. You can probably implement the functionality you want in another language. As @brebs says, Prolog is not an easy language to use. It’s also worth considering Peter Norvig’s advice about learning a programming language quickly; to summarise, don’t:

So the question to ask is: why use Prolog? Why not another language you already know well?

This is an opportunity to experiment and compare two approaches, that I think your students would enjoy. I sure would have enjoyed it when I was a student. My suggestion would be to assign two tasks to two groups in the class: one group would use an LLM instead of learning Prolog, the other would learn Prolog. The two groups can swap in the middle of the term. The experience of the students with each approach can then be recorded and discussed in the class.

Of course the tricky bit would be to ensure that the group that’s supposed to learn Prolog, actually learns Prolog. This is the world we’re in now.

There is a field at the intersection of Machine Learning and Logic Programming, called Inductive Logic Programming (ILP). Perhaps, if you decide to stick with Prolog for the long term, you might eventually be interested to look into ILP.

Best of luck with your endeavour!

Not sure if I said that somewhere… my point would be that Prolog is worth learning and using, for the folks that can.

Rather than plain Java/Python, it would be a combination of another language, plus library/helper modules such as https://www.optaplanner.org/ - which would need learning, and could have their own limitations/bugs.

Personally, I would choose Prolog, to have flexibility and control.

Prolog also has helpers, e.g. clpfd and GitHub - ridgeworks/clpBNR: CLP(BNR) module for SWI-Prolog

That’s partly true: for me, learning PROLOG means first understanding and being able to use the language, but also the underlying concepts (logical reasoning, etc.). However, I’m not doing this for the students; the ES is intended to support the accelerator operators in operational management (especially during failure states) and to support the analysis teams in error management.

The backend exists already in the form of an SQL database that we have developed and set up ourselves. And we have considered Python+Django (which we use) or Java+JDDD for the operators backend. The spin to PROLOG came about, among other things

  • from the desire to avoid the disadvantages of LLMs (hallucinations, lack of transparency, etc.),
  • from the desire to derive instructions for action from mistakes made and their correction,

It may be possible to implement the ES in Python+SQL (probable not an issue) and would fit into our IT world. The concepts of PROLOG are at least worth learning (otherwise I would not be able to transfer it to any other language). So I am in a situation where I know what I want to build (roughly), but I haven’t quite decided how I’m going to build it with.

But I already know what I don’t want:

"… re-invent the wheel and rediscover all the mistakes and tricks that they could have found in the Expert Systems literature of old, …“

That’s why some of these ”old" books are now in my office (including Norvig) :slightly_smiling_face: .

We have an accompanying project in which a local LLM has to read all the log entries of the accelerators in order to answer then corresponding questions. However, specific knowledge is not guaranteed to be taken into account there. My ES could therefore return such information (including falsified and verified rules) to the LMM (another possible use case).

So I’m still in the process of formulating my thoughts on this .
Viele Grüße | Best regards

Siegfried

1 Like

Sounds great - could you show e.g. the structure?

Why not put these as Prolog facts and get playing with it? Probably don’t need a SQL database (and its awkwardness with SQL as a separate language) when you’ve got SWI-Prolog -- Just-in-time clause indexing and SWI-Prolog -- Tabled execution (SLG resolution) and can then enjoy treating facts as just another constraint, in harmony with the language.

Prolog has SQL-like expressions, such as group_by/4 and order_by/2 and distinct/2.

Use LLMs to create your Prolog? Absolutely you can. I used Claude code to help me create a Prolog program of a little expert system to manage a kitchen that needed to produce different dishes with different appliances and to be able to maximize revenue. Basically an ILP ( Integer Linear Program) solver. I then used Claude code to create a Python app that leverages tool calling in several LLM‘s that then can invoke my Prolog expert system from my app. That allowed me to use natural language to talk to the Prolog system. There are libraries out there that connect Python to SWI Prolog (pyswi?) and they work quite well. Or you could go all in on Rust and use Scryer Prolog.

1 Like

It would be terribly interesting to see a bit more detailed write-up of what you described above.

(@bauhaus911 sorry about the previous wording, I had not had coffee which is a dumb excuse)

You are mistaken. What really happened is that I saw a reply to the topic, and re-read my own comment, and disliked my own tone. It had nothing to do with the content of your post, at least not consciously.

While the tone is different, the intent is very much the same: I would like to see a more detailed case study of a project that sounds, on the surface, as a great success; I would like to be able to reproduce that success, if the author would provide enough information.

Here is what I mean:

Version A:

I need to see a proper case study to believe your claims.

Version B:

It would be terribly interesting to see a bit more detailed write-up of what you described above.

and now we also have Version C:

I would like to see a more detailed case study of a project that sounds, on the surface, as a great success; I would like to be able to reproduce that success, if the author would provide enough information.

I don’t want to do a semiotic analysis of the three versions, because I don’t know what “semiotic” means.

The whole process, as described above by @bauhaus911 :

I used Claude code to help me create a Prolog program of a little expert system to manage a kitchen that needed to produce different dishes with different appliances and to be able to maximize revenue. Basically an ILP ( Integer Linear Program) solver. I then used Claude code to create a Python app that leverages tool calling in several LLM‘s that then can invoke my Prolog expert system from my app. That allowed me to use natural language to talk to the Prolog system.

Surely using an LLM it should be possible to generate a reproducible report with reasonable effort. I am aware that while I can ask kindly I cannot demand it.

I might be missing something, I did read this post of yours: Technical Failure Management and Root Cause Prediction with an Expert System - #15

It only provides publicly available information on the topics it discusses; I did not find any attempt at describing the following (emphasis mine):

I used Claude code to help me create a Prolog program of a little expert system to manage a kitchen that needed to produce different dishes with different appliances and to be able to maximize revenue. Basically an ILP ( Integer Linear Program) solver.

What were the prompts? What were the answers like? What does the result look like? and so on. Like, a report, a case study, whatever you want to call it.

PS: I apologize to @bauhaus911 for being an unwilling participant in this.

@Boris @anon95304481 @siegfried I wanted to see if there were good synergies between the “old” AI (expert systems using Prolog) and the “new” AI (LLMs). The goal was to use a consumer grade GPU, locally, to try to get close to the capability of using just a frontier LLM from the big providers (OpenAI, Anthropic, etc.). Another goal was to see how easy or hard it would be to do that with two languages that I’m not proficient in AT ALL (Python / Prolog). I was happy enough with the result that I posted my experience on LinkedIn ( Boosting performance of local AI models ). I have more details there. If you want I can post my GitHub url for you all to download and play with. Let me know. After that post, I had a couple of updates you might find interesting. Boosting performance of local AI models | Bart Jenkins which describes some tweaks I made (different model, getting the same correct optimization result from just the local reasoning model without the use of the Prolog knowledge base–but at the expense of time) and then getting Gpt-5 to generate me a spreadsheet model to accomplish the same: Testing OpenAI Agent's Spreadsheet Capabilities | Bart Jenkins posted on the topic | LinkedIn All fun!

1 Like

I’ll try to answer the question without going beyond the scope of this thread (perhaps an extra thread would be useful?).

Our back-end is structured in the form of an Oracle SQL database because everyone can access it. Either via the Oracle APEX GUI or directly, e.g., via a GRANT on any tables.

Failure messages are entered manually by the operator, retrieved from other databases, or entered automatically. The failure messages are linked to components (parts), accelerators, and technical systems. The failure tracking (analysis of the error) is carried out using the 8D method, and the activities and measures are linked to the error message. Additional key information such as (repeat failures, criticality, contact person, effectiveness of measures, etc.) is also linked. The cause of the error can be specified by indicating a previous error (which already exists in the database).

Using appropriately clever evaluations, I can now determine the potential causes of an error pattern, identify appropriate and effective measures, including contact persons, and pass this information on to the user. Or I can list for the developer of, for example, network devices, which causes most frequently lead to the failure of their devices. Or I can give the operator advice on which actions should be avoided as far as possible during operation.

This takes too much time for me - it can be better processed by an expert system…

Does that answer the question, or is it still too vague?

Can use ODBC to get a useful subset of the data into Prolog as facts, in some convenient relational form:

Then, can use Prolog code to query the Prolog facts using e.g. SWI-Prolog -- library(aggregate): Aggregation operators on backtrackable predicates , rather than mixing SQL with Prolog in many places in the code.

1 Like

Oooh. An LLM would be PERFECT to put in front of your reliability system so that you could ask the question in natural language like you show in section 3.1 of your diagram rather than having to know how to do it in SQL (or Prolog queries) like you show in the orange bubble # 1 in section 3. You might be able to get some good results by sticking an LLM with an MCP plugin for SQL in front of your system but it might grind away and spend lots of tokens to figure things out. Putting a Prolog expert system in between the LLM and your existing SQL database would allow you to query your system in natural language (German, English, whatever!) and have that figure out the correct consults (queries) of the Prolog layer to quickly get answers.