Tutorial on User-Friendly KR: Exercises

This document contains the information for the exercises part of the KR2025 tutorial on User-friendly KR.

Download the tutorial slides.

1. Formalisms

1.1 DMN

1.1.1 Handyman

We use the BPMN.io DMN modeller to represent the following decision procedure:

Start by opening the editor in a new tab. The editor will automatically open an empty table. Note that this editor does not color the inputs or outputs, but uses a “When-then” labeling. Now create a table that defines “hole” in terms of “wall” (we will do this together).

To add a new table, click on the “View DRD” button in the top-left. This drops you in the Decision Requirements Diagram – a visual overview of the decision tables and how they are connected. Next, click on the rectangle in the toolbar on the left, and place a new rectangle anywhere in the canvas. Lastly, click on the wrench, followed by “Decision Table” to turn it into a decision table. (We will also do this together)

Now try to create a table which defines “method” in terms of “hole” and “weight”. :-)

(Possible Solution)

1.1.2 Running it using IDP-Z3

Unfortunately, BPMN.io cannot run our models for us. In this tutorial, we will instead rely on the IDP-Z3 reasoning engine. However, this currently does not support uploading .dmn files.

You have two options:

  1. Use this direct link to IDP-Z3 WebIDE with solution pre-loaded. This solution might differ from yours, though.
  2. Install the cdmn-solver tool using pip, and convert the .dmn into .json.

1.1.3 Extending the model

Our handyman has recently upgraded their toolkit with a diamond drill bit, which allows them to safely drill through tile to make a hole. Can you update the model to reflect this? Try to work in IDP-Z3’s online IDE directly.

Important: take care to update the glossary tables as well – diamond drillbit should be added to the boolean table.

(Solution with drillbit)

1.2 Feature Modeling

1.2.1 Sandwich example

As part of the next exercise, model the following knowledge as a feature model:

In the same IDP-Z3 webIDE as before, click on the tab “Feature Model” to go to the editor. Next, you can click anywhere on the canvas to introduce a new feature. When a feature has been selected, a toolbar will appear allowing you to change its name, child relations, and parent relation. (We will start together initially)

1.2.2 Running it using IDP-Z3

To generate solutions for the feature model, click “Run” at the top of the screen.

Alternatively, click “Interactive Consultant” to try some specific things.

(Solution in webIDE)

1.3 cDMN

1.3.1 Army exercise

In the BPMN.io editor (or on a piece of paper), try to express the following knowledge:

1.3.2 Handyman rewrite

Starting from our previous Handyman solution, replace the “How to hang” table by tables representing:

(Solution)

1.3.3 Optional advanced exercise: map coloring

cDMN also supports types, higher-ary symbols, and quantification. For instance, this model represents a partial solution to the well-known Map Coloring problem, in which we want to ensure that no neighbouring countries share the same color. In more detail, the model contains:

Now, try to modify this last table to express that “For every country c1,c2 must hold that if they border, they may not have the same color”. Tips:

2. Validation

In the Interactive Consultant, each symbol of the model is represented by a symbol tile through which values can be assigned:

Importantly, each time you set a value, the system derives the consequences (if any) and shows them as grey values. Clicking on such a system-derived value will show an explanation for why the value was derived.

2.1 Exercise

In this cDMN model, we model the advice given by Belgium regarding quarantines/PCRtests after a “high risk” contact with someone who tested positive for covid. This advice was as follows:

The linked cDMN model was built by someone with little modeling expertise, so it’s possible that some errors slipped in. Can you find any by testing out things in the Interactive Consultant? To help you on your way, you can check the things listed below. If you encounter any errors, try to update the cDMN model accordingly.

  1. Is a fever correctly categorized for adults? What about children?
  2. A person with fever and sneezes after a risky contact should quarantine.
  3. Regardless of your number of symptoms, you should always PCRtest after a risky contact.
  4. If you have no symptoms, quarantine is never necessary.
  5. If you are only coughing after a risky contact, a quarantine should also not be necessary.

Useful links