iCLIPS Documentation

Date:Oct 12, 2019

iCLIPS provides an interactive shell for the ‘C’ Language Integrated Production System (CLIPS).



  • A Jupyter kernel to work with CLIPS code in Jupyter notebooks and other interactive frontends.
  • Input history.
  • Tab completion.
  • Syntax highlighting via Pygments.
  • Parenthesis matching.
  • Possibility to integrate Python code bringing into CLIPS the Python libraries and eco-system via CLIPSPy.


  • CLIPS 6.30
  • Python 3
  • Jupyter Console


Debian and derivatives

Install CLIPS libraries and headers.

$ sudo apt install libclips libclips-dev

Install Python 3, Pip and the CFFI libraries.

$ sudo apt install python3 python3-pip python3-cffi

Install iCLIPS

$ sudo pip3 install iclips


CLIPS is statically compiled within the CLIPSPy module. Therefore, it should be enough to install Python 3 and iCLIPS via Pip.

Embedding Python code

Via the %% define-python-function magic command it is possible to integrate Python code within the CLIPS environment.

In [1]: %% define-python-function
DefPyFunction mode: return twice to define the inserted function within CLIPS.

In [2]: import re
      : import requests
      : def active_content(url):
      :     """Return TRUE if the website at the given URL contains active content."""
      :     try:
      :         response = requests.get(url)
      :         response.raise_for_status()
      :     except Exception:
      :         return clips.Symbol('ERROR')
      :     if re.search(r'</script>', response.content.decode()):
      :         return True
      :     else:
      :         return False

In [3]: (active_content "http://www.example.com")
In [4]: (active_content "http://www.clipsrules.net")

The define-python-function defines the first top level function found within the entered code. For more complex definitions see the python magic command.

Executing Python code

The %% python magic command allows to execute Python code within the console. The code will be executed after two consecutive new lines.

The CLIPSPy Environment used within the console is accessible via the CLIPS global variable.

In the following example, the conflict resolution strategy of the inference engine is changed via the programmatic API.

In [1]: %% python
Python mode: return twice to execute the inserted code.

In [2]: CLIPS.strategy = clips.Strategy.COMPLEXITY

In [3]: (get-strategy)

An object method is defined within the CLIPSPy Environment.

In [1]: %% python
Python mode: return twice to execute the inserted code.

In [2]: class Foo:
      :     bar = 0
      :     def baz(self, value):
      :         self.bar += value
      :         return self.bar
      : foo = Foo()
      : CLIPS.define_function(foo.baz)

In [3]: (baz 1)
In [4]: (baz 1)
In [5]: (baz 1)

Indices and tables