About ICaRuS
ICaRuS (Interactive ChemicAl RUle System) is a demo for learning chemical concepts as logic rules. You give it example molecules that belong to a concept (positives) and molecules that do not (negatives). ICaRuS then learns a rule, written in Prolog, that separates the two groups. You can inspect the rule, edit it by hand, and refine it over several rounds. The tutorial walks through one complete session.
The source code of ICaRuS is available on GitHub. If something does not work as expected, please report an issue.
From molecules to logic
Every molecule is translated into first-order logic facts that describe its atoms and elements, charges, bonds, rings, aromaticity and similar properties. This translation comes from chebILP and python-chebi-utils, the same atom-level representation that chebILP uses for ChEBI classes. Because all molecules share this vocabulary, a learned rule can be checked against any molecule.
Where the examples come from
You can pick a class from ChEBI (Chemical Entities of Biological Interest) to fill the example boxes automatically. The positives are the smallest molecules below that class in the ChEBI hierarchy, which gives the minimal core of the class. The negatives are molecules that sit close to the class in the hierarchy but are not part of it. Generic class structures with wildcard atoms are left out. You can also paste your own SMILES or InChI strings.
To suggest more molecules, ICaRuS ranks candidates by their similarity to your positives, using Morgan fingerprints (ECFP4) and the Tanimoto coefficient. It then picks a diverse set with Maximal Marginal Relevance, so you see different scaffolds instead of near-duplicates. Suggestions appear one at a time, and you label each as positive or negative.
Three learning methods
- Popper is an inductive logic programming (ILP) system. ICaRuS uses Popper 5.0.1 in noisy mode with an MDL cost function, so it returns the best rule it finds even when no rule separates the examples perfectly.
- Aleph is another ILP system, running under SWI-Prolog. It runs in non-noisy mode and looks for a rule that cleanly separates the examples.
- LLM uses chebILP's rule-generation pipeline. The model receives the concept name, its definition (which you can edit) and sibling classes. It writes auxiliary predicates and a candidate rule. The predicates are validated, and the candidate is scored on the examples, with one feedback round if the score is weak. The model can reuse predicates from a fixed rule library, built in advance for ChEBI classes. If the library already holds a rule for the selected ChEBI class, that cached rule is shown first, and the Prompt the LLM button asks the model for a fresh one. The model in use is named in the interface. On the public demo, the number of model prompts per session is limited.
Popper and Aleph can also draw on relevant predicates from this library as extra background knowledge.
Evaluation and explanation
Rules are evaluated with clingo, an answer set programming solver. ICaRuS shows a confusion matrix and lists the molecules the rule misclassifies. Each rule is also explained with a picture of the pattern it looks for and a short sentence, and the rule editor shows it with its auxiliary predicates unfolded. For every molecule, the "?" button explains why the rule accepts it (the matching atoms highlighted) or rejects it (the closest match and where it fails). The explanations are built with chebILP's explainability pipeline. The rule history keeps earlier rules so you can compare them.