The Proof is in the Pudding: Using Automated Theorem Proving to Generate Cooking Recipes (2023)

Abstract: This paper presents FASTFOOD, a rule-based natural language generation (NLG) program for cooking recipes. We consider the representation of cooking recipes as discourse representation, because the meaning of each sentence needs to consider the context of the others. Our discourse representation system is based on states of affairs and transtions between states of affairs, and does not use discourse referents. Recipes are generated by using an automated theorem-proving procedure to select the ingredients and instructions, with ingredients corresponding to axioms and instructions to implications. FASTFOOD also contains a temporal optimization module which can rearrange the recipe to make it more time efficient for the user, e.g. the recipe specifies to chop the vegetables while the rice is boiling. The system is described in detail, including the decision to forgo discourse referents and how plausible representations of nouns and verbs emerge purely as a by-product of the practical requirements of efficiently representing recipe content. A comparison is then made with existing recipe generation systems, NLG systems more generally, and automated theorem provers.

## introduction in recent decades, cooking recipes have received a degree of attention in the field of rule-based natural language processing. they are highly uniform in their general structure, with an ingredients list followed by a series of instructions, and can be easily accessed in large numbers on cooking websites and recipe search engines. however, the majority of work has focused either on searching and annotating large databases of online recipes, or on methods for processing and representing individual recipes, in either case, the approach has been one of natural language understanding. the present system, named fastfood, instead approaches cooking recipes from the direction of natural language generation (nlg): rather than trying to extract a representation of the discourse of a recipe from a natural language description, it first derives the discourse representation, and then realizes this representation in natural language. we consider cooking recipes as a discourse, because their constituent sentences contribute to a shared meaning, and should not be analyzed independently. recall that the discourse representation theory (drt) literature in particular (see @xcite ) emerged as a framework that captured conditions on the accessibility of discourse referents to anaphora and cataphora within sentences and in sequences of jlcl 2023 -band 36 (2) -29-85 sentences as uttered by individual speakers, even outside dialogue contexts. drt also attended to questions of fiction (see @xcite ). fundamental questions are about the nature of the objects that serve as antecedents to pronouns. we feel that recipes are merely another variety of discourse in this same spirit, and an interesting one because of the nature of change to the starting point objects. while it is certainly interesting to dwell on the inaccessibility of "a bicycle" as an antecedent to "it" in "leslie does not own a bicycle. it is red" as has been addressed within drt, it is also interesting to see that "leslie pureed a potato. it is large" is an incoherent discourse because of the change that the underlying referent undergoes. the purpose of drt is to specify what referents are named in discourse, what expressions co-refer to those same entities (e.g. pronouns pointing to objects introduced via indefinite descriptions), and what relations hold true among those entities. our system uses a related but alternative approach to representing discourse, in which the first-class citizens are the processes that change the relevant entities-some to the extent that the entities are obliterated, some merely changing the state, other entities brought into existence-rather than the entities themselves (see section 3). the task of nlg has been analysed in numerous ways. some early examples (k. r. @xcite ) make a binary distinction between a strategic component that decides what to say, and a tactical component that decides how to say it. following work has continued the idea of a spectrum from strategic to tactical but increased the number of levels to 3 @xcite or even 6 @xcite . the most fruitful framework in which to view the present work is that of @xcite , which uses 4: content production, content selection, content organization, and content realization. using this framework, the operation of fastfood can be summarized as follows. ## related work the majority of recent computational approaches to cooking recipes have focussed either on searching and annotating large online databases, or on deriving a graphical depiction of a given recipe in terms of a workflow. these are efforts of natural language understanding (nlu), which is a fundamentally different approach to the recipe generation attempted by fastfood. on the side of generation, there exists an early and detailed system which also takes the generative approach in dale's epicure (1992) (2.1). more recently, there has been some work applying neural language models and rule-based systems to the problem of recipe generation, discussed in section 2.3 and 2.2, respectively. input: vegetable dahl output: time: 53mins ingredients: coconut milk lentils olive oil raw peppers raw broccoli instructions: 0mins: while placing water in pot and heating on cooker; chop the peppers, chop the broccoli 5mins: while adding the lentils to the boiling water and cooking for 45mins, stirring occasionally; heat olive oil in pan and add chopped vegetables, fry until soft 50mins: strain the lentils 51mins: add the sauteed vegetables and coconut milk to the lentils and stir passive: from 4mins30secs to 5mins while while placing water in pot and heating on cooker; choping the peppers, choping the broccoli from 7mins30secs to 50mins while while adding the lentils to the boiling water and cooking for 45mins, stir ring occasionally; heating olive oil in pan and adding chopped vegetables, frying until soft figure 2 : an example of an input-output pair, the user inputs the title of a dish and receives a recipe for that dish along with the total cooking time and the passive intervals that occur during the recipe. ## representation system this section describes the format in which discourse content is represented in fast-food. section 3.1 discusses problems arising from the use of discourse referents in the domain of cooking recipes, and explains why they are not used here. this discussion is included because discourse referents are a common modelling framework for discourse, and so our choice not to use them here may be thought to require some justification. section 3.2 exposits the structures termed descriptive strings and processes, which together form the representation structure. section 3.3 sketches a brief connection between this representation choice and a long-standing debate in philosophy on the nature of names, objects and descriptions. this section is not needed to understand the behaviour of our system itself, but may be of interest to one concerned with the general philosophical issue of reference vs description. ## content production the algorithm of this section determines the set of all possible descriptive strings, termed can_make, and the set of all processes that the cook can perform, termed skills. these sets are then used by the content selection and organization modules (section 5 and 6, respectively). in order to efficiently generate the sets can_make and skills, we can exploit the similarity in the input-output structure of many different elements. for example, one process would take "(there is) raw broccoli" as input and return "(there is) chopped broccoli", another would take "(there is) raw carrot" as input and return "(there is) chopped carrot". to this end, we use two intermediary structures, cooking actions and food classes, which intuitively correspond to verbs and nouns, respectively. cooking actions (verbs) generalize the change between input and output across a set of processes, food classes (nouns) generalize the similarity between input and output across a set of processes. the current version of fastfood contains 8 cooking actions, including chop, boil, mash and soak; and a number 5 of food classes including broccoli, coconut milk, potato and pasta. the formation of skills requires a specification of how these interact to obtain meaningful processes. the term 'meaningful' is used to describe a process that it is pertinent for fastfood to consider; this excludes those that may be called physically impossible, such as chopping coconut milk along with those that may be possible but are highly impractical, such as soaking pasta. the complete action of the content production module is given in algorithm 2. ## content selection the content selection algorithm in this section requires the following for operation: the algorithm can then select which elements of can_make are required as ingredients, and which elements of skills are required to transform the ingredients into the desired dish. if the ingredients are not all in supplies, then the program terminates with output 'insufficient ingredients, you need: a1, a2, ..., an' where {a1, a2, ..., an} = ingred_list \ supplies. section 5.1 describes the algorithm for selecting both the subset of supplies that will form the ingredients list, and the subset of skills that will collectively transform the ingredients list into the desired dish. section 5.2 relates this algorithm to parsing and, in more detail, to well established work in the field of automated theorem proving. ## content organization the algorithm in the previous section selects the required ingredients and cooking instructions, respectively ingredlist and actionlist, to produce the user-specified input dish. the next phase is to organize this content. ## conclusion this paper introduced fastfood, an nlg system that uses a backwards-chaining automated theorem prover (atp) to select the correct steps and ingredients required to make a given dish, and then modifies the recipe to optimize time efficiency in the generated recipes. we now conclude and summarize by considering the theoretical and practical value of our work.