<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta>
      <journal-title-group>
        <journal-title>W. T. Adrian);</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>Reasoning about Ingredient Substitutions with Ontologies and Rules</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Weronika T.Adrian</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Maciej Kutyła</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Jędrzej Potoniec</string-name>
          <email>jedrzej.potoniec@cs.put.poznan.pl</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Agnieszka Ławrynowicz</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Poznan University of Technology</institution>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>RR'23: 17th International Rule Challenge and 7th Doctoral Consortium</institution>
        </aff>
      </contrib-group>
      <pub-date>
        <year>1860</year>
      </pub-date>
      <volume>000</volume>
      <fpage>0</fpage>
      <lpage>0002</lpage>
      <abstract>
        <p>Preparing healthy and delicious meals requires knowledge about the process, nutritional properties of the ingredients, and their combinations. When we face the need for substitution in a dish, e.g., for allergic or dietary reasons, we should know how removing one element and adding another influences the resulting experience. The paper proposes an ontology-based model for reasoning about ingredient substitution in food recipes, enhanced with a logic programming component for constraint satisfaction and optimization. This opens up possibilities for computer-aided decision support in the area of substitute recommendation.</p>
      </abstract>
      <kwd-group>
        <kwd>edge representation</kwd>
        <kwd>ontologies</kwd>
        <kwd>logic programming</kwd>
        <kwd>answer set programming</kwd>
        <kwd>Internet of Food</kwd>
        <kwd>computational food</kwd>
        <kwd>knowl-</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        will it influence the resulting dish? These are just some of the questions that require the
knowledge of a dietician, or a food technologist (and sometimes: both). While solutions based
on computing co-occurrence scores between ingredient2s][or other black-box solutions3[]
may produce proposals of ingredients that should be replaced, it is not always understandable,
if (and why) certain ingredients are appropriate or not, and what are the properties of the
proposed substitutes that satisfy the person’s goals. Therefore, logic-based and hybrid solutions,
such as employing similarities and reasoning in one system 4[
        <xref ref-type="bibr" rid="ref5">, 5</xref>
        ], may be developed to provide
transparent and explainable answers to the questions outlined above.
      </p>
      <p>Within TAISTI research projec1t, an interdisciplinary team, composed of dieticians, food
technologists, and computer scientists has been working on modeling solutions for proper and
healthy substitutions of recipe ingredients. In particular, we analyzed the existing ontologies
and thesauri, in order to design a knowledge base and develop a logic-based method that would
point out ingredients of a given recipe that do not satisfy the constraints defined by a user,
and propose a method availing of logical reasoning to select candidate substitutes based on
constraints. Such methods inherently can be a base for explainable substitute recommendations.</p>
      <p>In this paper, we show how substitution can be modeled and reasoned about with ontologies
and rules. We discuss the elements of knowledge useful for the substitution and propose a
general reasoning framework for identifying unacceptable ingredients and pruning wrong
substitute recommendations. The paper is organized as follows: in Sectio2n, we introduce
selected problems that motivated our work; Section3 introduces our knowledge-based approach
to ingredient substitution. In Section4 we show the general reasoning framework, and in
Section 5, we instantiate it for particular cases. The paper is concluded in Sectio6n.</p>
    </sec>
    <sec id="sec-2">
      <title>2. Motivating example cases</title>
      <p>There are various reasons for substitution in recipes: allergies, diets, cultural requirements or
constraints, etc. In this section, we focus on some of them. More scenarios can be found i6n][.</p>
      <sec id="sec-2-1">
        <title>2.1. Recognizing ingredients with gluten</title>
        <p>
          Following [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ], we assume that gluten is one of the proteins of wheat, barley, rye, and oats
(and their hybrid) and thus to recognize that an ingredient contains gluten, it is suficient to
check whether it is a derivative of any of these four cereals, or any of its ingredient is such a
derivative. Moreover, we consider idealized ingredients in that we do not take into account
gluten impurities from the manufacturing process.
        </p>
        <p>
          Assuming that recipe ingredients are represented as classes in a knowledge graph build upon
the FoodOn ontology [
          <xref ref-type="bibr" rid="ref8">8</xref>
          ], in a complete knowledge graph it would be suficient to check whether
a class representing an ingredient is a subclass of ’derives fromso’ me (’wheat plant’ or ’oat
plant’ or ’barley plant’or ’triticale plant’or ’rye plant’) (see FoodOn Ontology 8[]).
        </p>
        <p>For example, consider the recipeAir fried sunfish , with its list of ingredients, and their possible
mappings to FoodOn reported in Tab.1. Observe, that it immediately questions the assumption
about the completeness of the knowledge graph. While no mapping is incorrect, some of them</p>
        <sec id="sec-2-1-1">
          <title>1See http://taisti.eu</title>
          <p>are imprecise, in particular, fillets of a concrete fish and a concrete type of breadcrumbs were
mapped to respective generic classes. Apart from that, the problem is relatively simple in this
case: the only gluten-containing ingredient is panko breadcrumbs, and ’wheat bread crumbs’ are
a subclass of the class expression specified above. For the remaining ingredients, a close-world
assumption must be made: since it does not follow from the ontology that they contain gluten,
it must be assumed that they do not. We remark that it would be useful should the knowledge
graph contain the necessary axioms to avoid making close world assumptions “on the fly”.</p>
          <p>The situation gets more complicated withHealthy sesame chicken. The ingredients and their
manual mappings are presented in Table2. Apart from the soy sauce, it is straightforward and
ingredient FoodOn class
boneless skinless chicken breasts FOODON:00003364
light soy sauce FOODON:03301115
all-purpose flour FOODON:03304534
sesame seeds FOODON:03310306
black pepper FOODON:03306739
dry chili flakes
FoodOn label
’chicken breast (skinless, boneless)’
’soy sauce’
’wheat flour (all purpose)’
’sesame seed (whole)’
’black pepper (ground)’
can be treated similarly to the previous case. Soy sauce, on the other hand, is an interesting
problem: traditionally, it is the product of fermentation of soy and wheat, and thus contains
gluten. There are, however, variants of soy sauce that are produced without sources of gluten,
such as tamari sauce, or some industrially-produced replacements of soy sauce. The knowledge
graph should thus not assert that the soy sauce contains gluten, as only some variants d2oT.his,
in turn, indicates that the user should be informed that they must choose a gluten-free variety
of the sauce. This poses an interesting modelling challenge. One must also note that there may
be two variants of gluten-free diet: one followed by people for whom even the traces of gluten
cause health problems, and another followed by people who limit the intake of gluten, but
the results of ingesting a small amount are insignificant to them. In the description above we
2For example, Kikkoman, one of the leading manufacturers of soy sauce, states in the FAQhttps://web.archive.org/
web/20220904110036/https://www.kikkoman.eu/faq/: The gluten in Kikkoman Naturally Brewed Soy Sauce is below
the detection limit of 10 ppm (according to tests by independent institutes). We recommend Tamari Gluten-free Soy
Sauce for people with gluten intolerance.
concentrate on the first variant, where the aim is to eliminate all the gluten sources. The second
variant is far more subtle, as it requires finding a balance between the amount of gluten in the
recipe, and the added cost of the modified recipe, due to, e.g., harder-to-obtain ingredients. For
example, the recipe forEasy Coconut Macaroons3 yields 14 servings and uses only 2 tablespoons
of wheat flour. For some people, this amount may be acceptable and the recipe may be left as-is.
For others, it requires adjustments.</p>
        </sec>
      </sec>
      <sec id="sec-2-2">
        <title>2.2. Allergies and diets</title>
        <p>A gluten-free diet is but one example of a wider family: allergies. While there are oficially
recognized lists of allergens, they vary from state to state in their comprehensiveness. For
example, currently, the EU recognizes 14 major allergens, among others lupin and mustar4d;at
the same time in the US, only 9 allergens are recognized. However, it must be underlined that
neither is nor aims to be comprehensive: their aim is to inform the majority of consumers with
allergies, not all of them. This strongly hints that a system aiming at allergies should either
allow the user to specify an arbitrary list of ingredients as a list of allergens or should follow
specific regulations and target major allergies according to the law in selected countries.</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>3. Knowledge-based substitution in food recipes</title>
      <p>
        Substitution per se has been mostly studied in recommender systems [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], mostly availing of the
appearance of ingredients in similar contexts.
      </p>
      <p>Conceptualizing the substitution, we have identified three aspects of it:
1. Goals – in fact, any substitution is motivated by the stating some objectives;
2. Constraints – a valid substitution is usually subject to meeting certain requirements;
3. Similarity – to avoid substitutinganything with anything, there should be some similarity
measure between the original and the resulting dish.</p>
      <p>The similarity is an interesting challenge here. On the one hand, we do not want to change
the original recipecompletely, so we want the substitute to be somehow similar to the original
ingredient, in terms of taste, crispiness, etc. On the other hand, the ingredient to be substituted
has some features thatdo not meet the user’s requirements or goals, so the new substitute
must significantly difer from the original one. In our approach in TAISTI, we have solved
this challenge by applying a two-phase process: first, we identify candidate substitutes with
machine learning models, based on the similarity of their contexts (recipes in which they appear),
and then we prune the substitutes with logic. The machine learning-based recommendation
algorithms are beyond the scope of this paper; here we focus on the knowledge-based model
for reasoning about the original recipes and the proposed substitutes.</p>
      <sec id="sec-3-1">
        <title>3See https://www.yummly.com/recipe/Easy-Coconut-Macaroons-484241 4See https://eur-lex.europa.eu/legal-content/EN/TXT/PDF/?uri=CELEX:32011R1169&amp;from=EN</title>
        <sec id="sec-3-1-1">
          <title>3.1. Knowledge model</title>
          <p>Using the ontology design pattern for ingredient substitution proposed i6n],[and after
researching available ontologies and data sources, we have designed a knowledge model we describe
next. Our proposed knowledge base consists of integrated parts of selected ontologies and is
populated with instances that describe particular recipes (in particular, the required ingredient
sets of the recipes). Based on this model, we implemented a (minimal viable) knowledge graph5
on which we can demonstrate the reasoning about ingredients and substitutes that are not
appropriate in a given context.</p>
          <p>The knowledge we need for reasoning about substitution falls into the following three groups:
1. Constraint-related knowledge, in particular the knowledge about diets (from Ontology of</p>
          <p>
            Nutritional Studies (ONS) [9]) and allergies (based on EU regulations),
2. Food-related knowledge, mostly based on FoodOn8[],
3. Recipe-related knowledge, based on the ontologies proposed in10[] and [
            <xref ref-type="bibr" rid="ref6">6</xref>
            ].
To identify the “forbidden” ingredients in a considered recipe or to “prune” the list of proposed
ingredient substitutes (which may be pre-computed with other methods, e.g. based on machine
learning), one can check the inconsistency between theuser recipe and the user constraints, both
described formally, with the use of ontological reasoning or logical rules (in particular hard
or weak constraints). A general sketch of knowledge portions used in the reasoning process
and how they influence each other is depicted in Figure 1. For clarity, this picture omits the
Knowledge
model
FoonOn classes
ONS classes
          </p>
          <p>User Recipe
Integrated fragments of
selected ontologies (ONS,
FoodOn, allergy ontology)</p>
          <p>+
instances: the recipes</p>
          <p>User
constraints</p>
          <p>ASP program
Recipe datasets</p>
          <p>ML models</p>
          <p>Possible
substitutes</p>
          <p>Rule base
unacceptable ingredients</p>
          <p>identification
substitution proposals
interconnections between food products, recipes, and constraint ontologies (the “integrated
fragments of selected ontologies”) that we discuss next.</p>
        </sec>
      </sec>
      <sec id="sec-3-2">
        <title>5See https://github.com/taisti/SubstitutionRules</title>
        <sec id="sec-3-2-1">
          <title>3.2. Main classes and properties in the integrated ontology model</title>
          <p>Following good practices in ontology engineering, we have reused existing knowledge for the
following subclass hierarchies:
• diets – diet classes have been imported from the Ontology of Nutritional Studies
• food products – wherever possible, food product classes have been imported from FoodOn
• recipe – following the recently added ’recipe’ class from FoodOn, we imported the class
and its related classes, such as ingredient set, etc.</p>
          <p>For allergies, we defined a set of classes, based on the EU regulations, and re-use the property
’has allergic trigger’ (RO:0001022) from the OBO Relations Ontology.</p>
        </sec>
        <sec id="sec-3-2-2">
          <title>3.3. Modeling the recipes</title>
          <p>For modeling the recipes, we have adopted the pattern and the class ’food recipe’ first proposed
in [10]. In this pattern, the ’food recipe’ class is linked to the class ’ingredient set’ through the
’has component’ relation. The ’ingredient set’ class is linked to the ’ingredient specification’ class
via ’has member’ relation. An inverse relationship is ’is member of.’ All classes of ingredients
are linked to their corresponding classes in FoodOn (which are subclasses of the ’food product’
class hierarchy) through the ’is about’ relation. Each instance of the ’ingredient set’ class is
created using the schema: recipe name + ’ingredient set’. A similar naming convention is used
for instances of ’ingredient specification’, where the first part is the ingredient name.</p>
        </sec>
        <sec id="sec-3-2-3">
          <title>3.4. Linking food to diets and allergies</title>
          <p>The main classes that take part in reasoning are: ’recipe’, ’food product’, ’diet’, and ’allergy’.
Relations that we added to the above-mentioned ontologies are: ’acceptableIn’ and ’unacceptableIn’
(linking recipes with diets), and ’isNeededFor’ (linking food products with recipes).</p>
          <p>There are numerous diets that can be followed for a variety of reasons, including health and
ideological ones. ONS includes a model that categorizes diets based on several characteristics,
such as ’diet by nutritional composition’. The subclasses ’diet by kind of food’ (ONS:1000003),
’diet by food organism’ (ONS:1000019) were given special attention in this work. It comprises
the classes ’vegetarian diet’ (ONS:1000020) and ’vegan diet’ (ONS:1000021). In addition, for
the purposes of the model, the class ’meat diet’ has been introduced. These straightforward
examples will be used to demonstrate inference about whether a certain recipe is suitable for a
specific diet. There are two relations linking a specific cuisine to diets:
• ’acceptable in’ - connects instances from the food recipe class to diets;
• ’unacceptable in’ - same domain and range as the ’acceptable in’ property.</p>
          <p>These relations are disjoint, i.e., we cannot connect a pair of instances using both of them. For
example, ’chicken curry’ cannot be both a meat and a non-meat dish. On the other hand, one
dish can be linked several times to diferent diets, e.g., a vegan dish can also be explicitly linked
to a vegan diet.</p>
        </sec>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>4. General reasoning framework</title>
      <p>As outlined in Figure1, the ontological knowledge model is a part of a broader reasoning
framework. In this section, we present its elements, first discussing some ontological reasoning
(see Section4.1), and then the logic programming component (the ASP model, c.f., Section4.2)
whose primary responsibility is to identify the unacceptable ingredients in a recipe and prune
inappropriate substitute recommendations.</p>
      <sec id="sec-4-1">
        <title>4.1. Ontological queries and reasoning</title>
        <p>In order to identify ingredients that do not meet constraints defined by the user, we can pose
DL queries, within the ontology editor or via an API, or use ASP rules and constraints that
can be interpreted by a logic programming engine. Given a recipe with its set of ingredients
recipe:Recipe and constraints that can model a diet or an allergy etc., the following queries
will identify the ingredienta that violates the required constraints:</p>
        <sec id="sec-4-1-1">
          <title>1. For an instanceMY_DIET of a class: diet:</title>
          <p>foodProduct(A) AND recipe(RECIPE) AND diet(MY_DIET)</p>
          <p>AND memberOf(A, RECIPE) AND unacceptableIn(A, MY_DIET)
2. For an instanceMY_ALLERGY of a class allergy:
foodProduct(A) AND recipe(RECIPE) AND allergy(MY_ALLERGY)</p>
          <p>AND memberOf(A, RECIPE) AND hasAllergicTrigger(MY_ALLERGY, A)
These high-level queries are based on the classification of the classes present in the ontology.
New cases for allergies or diet-based restrictions can be added by providing appropriate logical
rules or ontological axioms. For instance, one can express the diet constraints for a specific diet
as follows:
unacceptableIn(A, vegan_diet) IF isSubclassOf(A, meat)
unacceptableIn(A, glutenfree_diet) IF derivesFrom(A, wheat)
...
and define specific food products to be allergy triggers:
hasAllergicTrigger(seafood_allergy, A) IF isSubclassOf(A, seafood)
hasAllergicTrigger(sesame_allergy, sesame)
...</p>
          <p>They can be added to the ontology, as subclass axioms, or extend the logic programming rule
base that we discuss in the next section.</p>
        </sec>
      </sec>
      <sec id="sec-4-2">
        <title>4.2. Reasoning with logical rules and constraints</title>
        <p>
          In this section, we provide a logic programming model that allows us to reason about substitution
in a given context. The model is written in Answer Set Programming1[
          <xref ref-type="bibr" rid="ref1">1</xref>
          ], a declarative paradigm
for expressive knowledge representation and reasoning based on stable model semantics. Given
a recipe (a unary predicaterecipe/1) with a set of ingredients linked to the recipe with
isNeededFor/2 relation (binary predicate), and using the requirements given by a user (in
terms of stating theirdiet/1 orallergy/1), the model identifies which ingredient in the given
recipe/1 must or should be replaced, and provides a (set of) suggestions for substitution:
%%%% Rules for processing user information and suggesting substitutes
% R1: Identifying original ingredients that are wrong
must_replace(X) :- recipe(Recipe), allergy(Allergy), isNeededFor(X, Recipe),
hasAllergicTrigger(Allergy, X).
% R2: Identifying original ingredients that are wrong
should_replace(X) :- recipe(Recipe), diet(Diet), isNeededFor(X, Recipe),
unacceptableIn(X, Diet).
% R3, R4: Projection rules for cleaner output
suggestion(I,S):- must_replace(I), goodSubstitute(I,S).
suggestion(I,S):- should_replace(I), goodSubstitute(I,S).
        </p>
        <p>Let us now discuss how the conclusions (suggestion/2 predicates) are reached. As
introduced in the previous section, user-defined constraints can be easily defined as rules that
conclude that some ingredients are unacceptable in a diet or can trigger an allergy:
%% Rules for diets and allergies - an extendable rule base
% D1: vegan diet
unacceptableIn(X, vegan_diet) :- isSubclassOf(X, meat).
% D2: gluten-free diet
unacceptableIn(X, glutenfree_diet) :- derivesFrom(X,wheat).
%...
% A1: seafood allergy
hasAllergicTrigger(seafood_allergy, X) :- isSubclassOf(X, seafood).
% A2: sesame allergy
hasAllergicTrigger(sesame_allergy, sesame_seeds).
%...</p>
        <p>To define candidate substitutes, we use a predicate isSubstituteFor/2. This information can
be stated explicitly, as a fact, or inferred from the function a food product plays in a recipe:
% S1: inferring substitutes from functions
isSubstituteFor(A,B) :- foodProduct(A), foodProduct(B), hasFunction(A,F),
hasFunction(B,F).</p>
        <p>Moreover, the substitute proposals can be obtained from the machine learning models (suggested
as ”candidate substitutes” with a certain level of similarity that we can asses):
% S2: inferring substitutes from ML-based recommendations
isSubstituteFor(A,B) :- foodProduct(A), foodProduct(B), ml_similar(A,B,S),
threshold(T), S&gt;T.</p>
        <p>To express that a certain ingredient (or a proposed substitute) must absolutenlyot
appear in the recipe one can usehard constraints (or integrity constraints) expressed as:
:- conjunction of logical terms. If an ingredient or a proposed substituteshould not
be allowed in the recipe, but in some cases can be accepted, one can define a weak constraint
expressed in ASP as::~ logical terms. (see [11]).</p>
        <p>
          In the model, we follow theGuess-Check-Optimize methodology for ASP programming: We
ifrst state that a candidate substitute can be good or bad in the given context (to allow the
reasoner to search for possible models), and then prune the bad substitute recommendations
saying it is not a goodSubstitute/2 if it violates the hard constraints of an allergy, and ask to
minimize the badSubstitute/2 proposals (suggest its avoidance because of dietary patterns):
%%%% Model to reason about substitution
%% I: Guess - In the given context, a substitute can be either good or bad
goodSubstitute(A,S) | badSubstitute(A,S) :- isSubstituteFor(A,S).
%% II: Check ( Constraints)
% C1: exclude substitutes that are allergic triggers
:- goodSubstitute(X,S), hasAllergicTrigger(Allergy, S).
%% III: Optimize (Weak constraints)
% W1: if possible, exclude substitutes unacceptable in the given diet(s)
:~ badSubstitute(X,S), unacceptableIn(S, Diet). [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ]
Weak constraints can also be used to ensure minimizing or maximizing the intake of selected
nutritional substances, e.g., in a low-fat or high-protein diet. This requires extending the
ontology with data properties and working with numerical constraints which is currently our
work-in-progress and is beyond the scope of this paper.
        </p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>5. Use case examples</title>
      <p>Let us consider selected possible questions we can pose to our model.</p>
      <p>Case 1: A not vegan dish with gluten Assume we are looking for a dish with at least a
single ingredient that contains gluten (implicitly - it is derived from wheat) and is not suitable
for a vegan diet. This is possible with the following DL query:
'food recipe' and 'has component' some ('ingredient set' and 'has member'
some ('food product' and 'derives from' some 'wheat plant' )) and
'unacceptable in' some 'vegan diet'.</p>
      <p>This query employs the ontology’s recipe scheme: we check to see if there is any product in
the ’ingredient set’ that is linked to the ’wheat plant’ class via the ’derives from’ relationship.
Finally, a second criterion is introduced that excludes all the recipes that are not vegan-friendly.
As a result, we get the ’air fried sunfish recipe’ and ’healthy sesame chicken recipe’.
Case 2: A meat dish with sesame allergen In this scenario, we seek a dish that has a
sesame allergen and is part of a meat-based diet. This is achievable with the following DL query:
'food recipe' and 'acceptable in' some 'meat diet' and 'has allergic trigger'
some 'sesame allergy'.</p>
      <p>This query is simpler - we have two restrictions that directly filter our collection of recipes.
Only one recipe from our model meets these requirements: ’healthy sesame chicken recipe’.
Case 3: Searching for a gluten-containing product in specific recipe In the next example,
we want to discover a gluten-containing product. Assume we know a recipe contains gluten
(we can confirm this using the hasAllergicTrigger relation on the recipe), but we do not know
which item contains it. We can verify this by running the following query:
'food product' and 'is about' some('ingredient specification'
and ('member of' value 'air fried sunfish ingredient set'
and 'has allergic trigger' some 'gluten allergy'))
We find the ’air fried sunfish recipe’ ingredients. Then, using the relation ’is about’, we determine
which food product the ingredient is associated with. ’wheat bread crumbs’ is the result of this
query and the problematic ingredient.</p>
      <p>Case 4: Applying dietary and allergy-related constraints Let us now consider a more
complicated case. A vegetarian person who allows some seafood occasionally but prefers not
to eat it if possible and who is allergic to soy and sesame would like to prepare the ’Healthy
sesame chicken’ recipe from Case 2.
recipe(healthy_sesame_chicken). diet(avoid_seafood). diet(vegetarian_diet).
allergy(soy_allergy). allergy(sesame_allergy). diet(avoid_nuts).
foodProduct(chicken). isNeededFor(chicken, healthy_sesame_chicken).
foodProduct(soy_sauce). isNeededFor(soy_sauce, healthy_sesame_chicken).
foodProduct(flour). isNeededFor(flour, healthy_sesame_chicken).
foodProduct(sesame_seeds). isNeededFor(sesame_seeds, healthy_sesame_chicken).
foodProduct(black_pepper). isNeededFor(black_pepper, healthy_sesame_chicken).
foodProduct(chili_flakes). isNeededFor(chili_flakes, healthy_sesame_chicken).
isSubclassOf(chicken, meat). contains_soybeans(tofu). foodProduct(salmon).
isSubclassOf(salmon, seafood). isSubclassOf(squid, seafood).</p>
      <sec id="sec-5-1">
        <title>Possible substitutes are listed below:</title>
        <p>isSubstituteFor(chicken, seitan). isSubstituteFor(chicken, tofu).
isSubstituteFor(chicken, oyster_mushroom). isSubstituteFor(chicken, salmon).
isSubstituteFor(chicken, squid). isSubstituteFor(soy_sauce, coconut_aminos).
isSubstituteFor(sesame_seeds, panko_breadcrumbs).
isSubstituteFor(sesame_seeds,almonds). isSubstituteFor(sesame_seeds,corn_flakes).
If we extend the model to know that
% A3: soy allergy
hasAllergicTrigger(soy_allergy, soy_sauce).
hasAllergicTrigger(soy_allergy, X):- contains_soybeans(X).
% D3: avoid seafood diet (if possible)
unacceptableIn(X,avoid_seafood) :- isSubclassOf(X, seafood).
% D4: vegetarian_diet
unacceptableIn(X, vegetarian_diet) :- isSubclassOf(X, meat).
the model immediately gives us:
must_replace(soy_sauce).
must_replace(sesame_seeds).
should_replace(chicken).</p>
        <p>Hard constraints filter out tofu (contains soybeans), while soft constraints filter out salmon, and
squid, leaving them with oyster mushrooms and seitan:
suggestion(chicken,seitan). suggestion(chicken,oyster_mushroom).
suggestion(soy_sauce,coconut_aminos). suggestion(sesame_seeds,corn_flakes).
suggestion(sesame_seeds,panko_breadcrumbs). suggestion(sesame_seeds,almonds).
Since they are allergic to sesame, they sometimes react to other nuts as well (due to the
allergens cross-reactivity6) and thus prefer to avoid them altogether if possible. To take it into
consideration, one must add the following constraint:
% D5: avoid nuts
unacceptableIn(X, avoid_nuts) :- isSubclassOf(X, nuts).
and thus the model will filter out almonds preferring panko breadcrumbs or cornflakes.</p>
      </sec>
    </sec>
    <sec id="sec-6">
      <title>6. Conclusion</title>
      <p>In this paper, we have presented an approach to knowledge-based substitution of recipe
ingredients that uses ontological modeling and logic programming. We have designed and implemented
an ontology that integrates parts of existing knowledge bases to support the logic-based
substitution of ingredients. We populated the model with several recipes. We have also designed a logic
6See, e.g., https://www.allergopharma.com/fileadmin/user_upload/allergopharma-com/Patients_information_
download_Cross_reaktive_USA.pd.f
program in ASP that allows to reason about recipes and substitutions based on user-defined
constraints regarding allergies and diets. Using description logic reasoners (e.g. Her7m),iTwe
can reason about the classification of recipe ingredients, and thanks to an ASP engine we can
identify wrong ingredients with hard and weak constraints, and reason about possible and
appropriate substitutes.</p>
      <p>
        In the future, we will consider more variants, and possibilities when it comes to ingredient
substitution. From the user perspective, we will analyze a broader spectrum of cases and
motivations for substitution. From the technical one, we plan to include constraints and optimization
based on numerical values (e.g., to minimize or maximize intake of specific substances in the
given diet). Finally, it is interesting to research how the tripartite flavor model1[
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] can be
applied to look for substitutes similar to the original ingredients present in the recipe.
      </p>
    </sec>
    <sec id="sec-7">
      <title>Acknowledgments References</title>
      <p>Research funded by the Applied Research Programme under the EEA and Norway Grants
2014-2021. Project registration number: NOR/SGS/TAISTI/0323/2020.
global food traceability, quality control and data integration, npj Science of Food 2 (2018)
1–10.
[9] F. Vitali, R. Lombardo, D. Rivero, F. Mattivi, P. Franceschi, A. Bordoni, A. Trimigno,
F. Capozzi, G. Felici, F. Taglino, et al., ONS: an ontology for a standardized description of
interventions and observational studies in nutrition, Genes &amp; nutrition 13 (2018) 1–9.
[10] D. Dooley, M. Weber, L. Ibanescu, M. Lange, L. Chan, L. Soldatova, C. Yang, R. Warren,
C. Shimizu, H. K. McGinty, et al., Food process ontology requirements, in: IFOW 2021
integrated food ontology workshop, September 15-18, Bolzano Italy, 2021.
[11] T. Eiter, G. Ianni, T. Krennwallner, Answer set programming: A primer, Springer, 2009.
[12] T. Naravane, M. Lange, Tripartite flavour model: Food phenotype, sensory and
interpretative matrices., in: ISWC (P&amp;D/Industry/BlueSky), 2018.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>A.</given-names>
            <surname>Lawrynowicz</surname>
          </string-name>
          ,
          <article-title>A knowledge engineering primer</article-title>
          ,
          <source>CoRR abs/2305</source>
          .17196 (
          <year>2023</year>
          ). URL: https://doi.org/10.48550/arXiv.2305.17196.doi:
          <volume>10</volume>
          .48550/arXiv.2305.17196. arXiv:
          <volume>2305</volume>
          .
          <fpage>17196</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>D.</given-names>
            <surname>Lawo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Böhm</surname>
          </string-name>
          , G. Stevens, Veganaizer:
          <article-title>AI-assisted Ingredient Substitution (</article-title>
          <year>2020</year>
          ). URL: http://rgdoi.
          <source>net/10.13140/RG.2.2.18736.17922. doi:10.13140/RG.2.2.18736.17922.</source>
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>S.</given-names>
            <surname>Li</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Li</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Ni</surname>
          </string-name>
          ,
          <string-name>
            <surname>J. J. McAuley</surname>
          </string-name>
          ,
          <article-title>SHARE: a system for hierarchical assistive recipe editing</article-title>
          , in: Y.
          <string-name>
            <surname>Goldberg</surname>
            ,
            <given-names>Z.</given-names>
          </string-name>
          <string-name>
            <surname>Kozareva</surname>
          </string-name>
          , Y. Zhang (Eds.),
          <source>Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, EMNLP</source>
          <year>2022</year>
          ,
          <string-name>
            <given-names>Abu</given-names>
            <surname>Dhabi</surname>
          </string-name>
          ,
          <source>United Arab Emirates, December</source>
          <volume>7</volume>
          -
          <issue>11</issue>
          ,
          <year>2022</year>
          , Association for Computational Linguistics,
          <year>2022</year>
          , pp.
          <fpage>11077</fpage>
          -
          <lpage>11090</lpage>
          . URL: https://aclanthology.org/
          <year>2022</year>
          .emnlp-main.
          <volume>761</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>K.</given-names>
            <surname>Skjold</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Øynes</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Bach</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Aamodt</surname>
          </string-name>
          , IntelliMeal
          <article-title>- Enhancing Creativity by Reusing Domain Knowledge in the Adaptation Process</article-title>
          , in: ICCBR,
          <year>2017</year>
          . URL:https://folk.idi.ntnu. no/kerstinb/paper/2017-ICCBR-Skjold-etal.pd.f
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>S. S.</given-names>
            <surname>Shirai</surname>
          </string-name>
          ,
          <string-name>
            <given-names>O.</given-names>
            <surname>Seneviratne</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. E.</given-names>
            <surname>Gordon</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.-H.</given-names>
            <surname>Chen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D. L.</given-names>
            <surname>McGuinness</surname>
          </string-name>
          ,
          <article-title>Identifying Ingredient Substitutions Using a Knowledge Graph of Food</article-title>
          ,
          <source>Frontiers in Artificial Intelligence</source>
          <volume>3</volume>
          (
          <year>2021</year>
          )
          <article-title>111</article-title>
          . URL: https://www.frontiersin.org/article/10.3389/frai.
          <year>2020</year>
          .
          <volume>6217</volume>
          .66 doi:10.3389/frai.
          <year>2020</year>
          .
          <volume>621766</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>A.</given-names>
            <surname>Ławrynowicz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Wróblewska</surname>
          </string-name>
          ,
          <string-name>
            <given-names>W. T.</given-names>
            <surname>Adrian</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Kulczyński</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Gramza-Michałowska</surname>
          </string-name>
          ,
          <article-title>Food recipe ingredient substitution ontology design pattern</article-title>
          ,
          <source>Sensors</source>
          <volume>22</volume>
          (
          <year>2022</year>
          )
          <fpage>1095</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>J. R.</given-names>
            <surname>Biesiekierski</surname>
          </string-name>
          , What is gluten?,
          <source>Journal of Gastroenterology and Hepatology</source>
          <volume>32</volume>
          (
          <year>2017</year>
          )
          <fpage>78</fpage>
          -
          <lpage>81</lpage>
          . URL: https://doi.org/10.1111/jgh.13703. doi:
          <volume>10</volume>
          .1111/jgh.13703.
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>D. M.</given-names>
            <surname>Dooley</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E. J.</given-names>
            <surname>Grifiths</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G. S.</given-names>
            <surname>Gosal</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P. L.</given-names>
            <surname>Buttigieg</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Hoehndorf</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. C.</given-names>
            <surname>Lange</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L. M.</given-names>
            <surname>Schriml</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F. S.</given-names>
            <surname>Brinkman</surname>
          </string-name>
          , W. W. Hsiao,
          <article-title>FoodOn: a harmonized food ontology to increase</article-title>
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>