Hire the author: Abhinish S

For an Artificial Intelligence to work elegantly, it needs to tackle complex problems without any hiccups. It is accomplished using large and hefty procedural codes. Only if we had a simpler way of doing this, then it won’t be such a chore to do. As it turns out, there is way to do this in a much more sleeker manner and that’s where an Expert System comes into play.

What is an Expert System?

An Expert System is designed to solve complex problems through knowledge based rules instead of using long procedural codes. The expert system is a part of Artificial Intelligence. The first Expert System, developed in the year 1970 was the first successful approach of artificial intelligence. It works by applying defined rules to the knowledge base of the system via an inference engine. Sounds too complicated ? Let me explain

Basic layout of an Expert System as an artificial intelligence
How Expert Systems work as an artificial intelligent entity

Firstly an expert creates a knowledge base which are basically a bunch of facts pertaining to specific domains. Then a set of rules are designed based on this knowledge base and different queries that the user is going to answer. Finally, an inference engine binds the knowledge base and the set of rules for the user to interact with, via a neat user interface.

Using CLIPS to build an Expert System

One of the most popular tools for implementing an expert system is CLIPS. It provides a complete environment for the construction of rule and/or object based expert systems. Its inference engine internally uses the Rete Algorithm for pattern-matching : Find fitting rules and facts.

Begin with basics-

First download CLIPS IDE from the following link – http://clipsrules.sourceforge.net/

Then open CLIPS IDE from the installed directory folder

A basic CLIPS program has an extension of .clp and it looks something like the image below-

Seems intimidating? Don’t worry, we will cover everything that a newbie needs to learn for creating expert system.

CLIPS commands

Basic commands (1)
Basic commands (2)

Defining different elements in CLIPS

Defining Facts to create an artificially intelligent expert system

These facts are basically the knowledge base of the expert system.

Defining Rules to create an artificially intelligent expert system

Every defined rule can have a set of conditions based on the knowledge base of the expert system. If they are satisfied upon a query answered by the user, then the specific actions can take place.

Using Templates to create an artificially intelligent expert system

Templates basically act as classes do in C++. They have elements, which can have multiple instances.

Basic Example of an actual code

Example of the expert system (artificial intelligence) code

The rule list-animals defined here in this expert system code does not have a condition. This implies that this rule is instantly fired as soon as the program is executed.

Besides this, assertion of facts also takes place through user input. Below is an example that clarifies this perfectly-

(printout t crlf “What is the crop? (C: corn, S: soybean) “)

(assert (crop =(read))) ;this line reads what the user types

(printout t crlf “What is the weed problem? (B: broadleaf, G: grass) “)

(assert (weed =(read)))

(printout t crlf “What is the percentage of organic matter content?(1: <2%, 2: 2-4%, 3: > 4%) “)

(assert (organic-matter =(read)))(printout t crlf “RECOMMENDATIONS:” crlf))

Inputs are read from the user upon answering these queries. Then these inputs are being asserted as facts to expand the knowledge base of the expert system for further use.

Here are some snippets of the facts and rules that I implemented in CLIPS for building an online Food suggestion Expert System.

Here is what my working code translates to-

Based on the different choices picked by the user, it will suggest food items based on their preferences.

Thus, eliminating the requirement of a waiter and having to decide from the menu.

Learning Strategy

CLIPS is a fairly easy language to understand that works on basic principles and yet manages to create deep complex systems. Basic syntax and a good understanding of rules and facts is good enough to start creating basic artificially intelligent expert systems of your own.

Besides this, if you want to go deeper and get a sense of everything that it has to offer, then I would recommend starting with the official documentation given in the following links- http://clipsrules.sourceforge.net/documentation/v640/ug.pdf



After this, if you are still craving for more then I recommend going through this book – Expert Systems: Principles and Programming, Fourth Edition

Reflective Analysis

Artificial Intelligence seems daunting to many people and they it is tedious task to learn it. But that’s far from the truth because there exists easy and powerful tools that alleviate the frustration of learning it the first time. In my own experience, I found CLIPS really easy to learn, even easier the traditional programming. It got me really hooked to explore deeper into the uncharted territory.

If you want to get an idea of an actual working expert system, then head on over to – https://github.com/learningdollars/abhinish-CLIPS-django.


There are a plethora of different things and design elements that can be used in CLIPS. It can build robust expert systems that can emulate decision making of a user based on his/her preferences. In this way CLIPS becomes a far more viable option to create expert systems rather than using large procedural codes.

Of course there is more to learn and do in CLIPS than introduced in this article. For example, CLIPS can also integrated with android to create expert system apps. Expert Systems can also be used in websites to give desired results based on user preferences. It is an artificially intelligent Expert System that suggests food items based user preference of different tastes.

This wraps up our basic introduction on building expert systems with CLIPS. I hope that you have learned something new and if you found this useful, kindly share it to help others as well.

Hire the author: Abhinish S