Advanced Expressions – isSubset


The isSubset expression is used to compare two sets of concept instances and verify that the first is a subset of the second. This can be used to determine if a set of requirements have been met for particular outcomes.

In the example below Rainbird will use the isSubset expression to determine which recipes are viable based on whether a user has the specific ingredients. In essence, the isSubset expression will determine whether the list of ingredients in a recipe is present in the list of ingredients that a user may have in the pantry.

isSubset(%O, requires ingredients, *, %S , has ingredients in pantry, * )

Rainbird will determine which desserts a user can make by:

  • Asking the user what ingredients they have in the pantry.
  • Determine whether the list of ingredients for specific recipes are present in the pantry.

Rainbird will then give the user a list of recipes that are possible to make.


Tom (a user) has the recipes for three simple desserts:

  1. A meringue which requires Eggs and Sugar
  2. A Victoria sponge cake which requires Eggs, Flour, Sugar, Butter and Jam
  3. A Chocolate cake which requires Eggs, Flour, Sugar, Butter and Cocoa Powder

Example 1:

Tom has all of the ingredients listed above, therefore he is able to make all of the possible desserts he has the recipes for.

Example 2

If Tom only has Eggs, Sugar and Butter, he cannot make the Victoria sponge or the chocolate cake. However because the recipe for the meringue is a subset of the 3 ingredients present, Tom is able to make the meringue.

First, create the following concepts:


Person – a string concept with no instances created (Rainbird will ask the user for a name at the start of the query, which will create a concept instance under the ‘Person’ concept)

Ingredients – a sting concept that has six instances: Butter, Cocoa Powder, Eggs, Flour, Jam and Sugar

Dessert – a string concept that has three instances: Chocolate Cake, Meringue and Victoria sponge

Next, link the concepts together with relationships, as shown in Figure 1:


Person -> has ingredients in pantry -> Ingredients (set to plural)

Dessert -> requires ingredients -> Ingredients (set to plural, Question wording: Off)

Person -> can make dessert -> Dessert (set to plural)


Figure 1: Concepts and Relationships


Create the Concept instances, as shown in figure 2, for the Ingredients concept.

Figure 2: Ingredients concept instances

Then create the Concept instances, as shown in figure 3, for the Dessert concept.

Figure 3: Dessert concept instances

Each of these concept instances have facts associated to them. These facts are what ingredients make up this recipe.

For a Meringue – requires ingredients – Eggs, Flour.

Figure 4: Dessert facts for Meringue

For a Chocolate Cake – requires ingredients – Eggs, Flour, Butter, Sugar, Cocoa Powder

Figure 5: Dessert facts for Chocolate Cake

For a Victoria Sponge – requires ingredients – Eggs, Flour, Butter, Sugar, Jam

Figure 5: Dessert facts for Victoria Sponge

The subset expression will be used in a rule built upon the Person -> can make dessert relationship -> Dessert relationship.

This rule will ask the user which of the listed ingredients are present in the pantry, as there are facts stored in the knowledge map it will not need to ask what ingredients make up the desserts.

It will then use the subset expression to determine what desserts can be made.

Figure 6: Main rule: A person can make desserts

Now, the query is ready to be run.

Let’s say we wanted to run a query on the “can make dessert” relationship to find out if we have all the ingredients to make a meringue.

First, we would tell Rainbird what ingredients we have in our pantry:

Person -> has ingredients in pantry -> Eggs, Flour, Sugar

Next, Rainbird would check whether the ingredient list for a meringue (eggs, sugar) is a subset of the list of ingredients we have in our pantry  (Eggs, Flour, Sugar).

Rainbird will then repeat the check for the remaining dessert instances that are in the map, the chocolate cake and the Victoria sponge.

However since the required ingredients for both the Victoria sponge (Eggs, Flour, Butter, Sugar, Jam) and the chocolate cake (Eggs, Flour, Butter, Sugar, Cocoa Powder) are not all present in the pantry then these are not given as outcomes to the query.

Figure 7: Outcome of query with sugar, egg, and flour selected as pantry ingredients

Click on the ‘Export.rbird’ button to download the ‘isSubset’ map used in this example. The knowledge map can then be imported into your Rainbird Studio.

Query and Results

The main query is built on the rule ‘can make dessert’. The outcome of the query will confirm which desserts can be created with the available ingredients.

Article Feedback form
Did you find this article useful?

Version 1.03 – Last Update: 21/04/2021