Keywords

1 Introduction

The research works of the World Health Organization (WHO) [90] concludes that stress is the world mental health disease of the 21st century and may be the trigger for depression and even suicide if it is not treated correctly. WHO estimates that, in the world, suicide is the second cause of death in the group of 15 to 29 years of age and that more than 800,000 people die due to suicide every year.

Also stress illnesses generate high economic losses since sick people and those who care for them reduce their productivity both at home and at work. According to data from the WHO, 450 million people in the world, suffer from at least one mental disorder.

Well-being (meaning the absence of anxiety, depression and stress) and physical health have been studied by many Scientists. Elizabeth H. Blackburn, Carol W. Greider and Jack W. Szostak were awarded with the Nobel Prize in Physiology - Medicine 2009. They show that Telomerase activity is a predictor of long-term cellular viability, which decreases with chronic psychological distress [35]. E. H. Blackburn et al. proved that mindfulness may exert effects on telomerase activity through variables involved in the stress appraisal process [14]. According to the work of Okoshi Tadashi et al. [59] Technologies of Inclusive Well-being is a field of study that assumes positive technology has the capacity of increasing emotional, psychological, and social well-being and that investigates how information and communication technologies(ICT) empower and enhance the quality of personal experience in these areas. Economists and governments are starting to focus on well-being and “Gross National Happiness” as a new metric for measuring the statuses of the nations.

We have proposed Cecilia an architecture of a digital companion artificial intelligence agent system composer of dialogue scripts for Well-being and Mental Health. The core part of our proposal in the design of Cecilia as inclusive technology, is the use of Artificial Intelligence (AI) logical declarative languages used as a reasoning-planning systems that allow to implement the system responsible to define and specify the behaviour of Cecilia with the user. Cecilia should run on a smartphone and students can interact through questions and answers, while Cecilia “learns” from the user it also allows the user to learn from herself. Once the student discovers elements that were unnoticed by her, she can find a better way to improve her own well-being when discovering her points of improvement. Cecilia has been conceived as virtual digital companion assisting the student while She can improve her own skills and She freely wants to get help from the system, once the student acquires full sovereignty of herself by mastering the skills proposed by Cecilia there is no need to continue interacting with Cecilia. Therefore Cecilia is not conceived as a system generating dependency with the student, but on the contrary the aim is to help the student to achieve a mature and healthy interdependence with Herself, Relatives, Friends, Society and Nature by helping the student to acquire full sovereignty of herself by compassionate skills [16].

Cecilia is thought to be an intelligent agent system that supports all individuals with emphasis on university students and young people.

Over the years, science has shown that the brain and the mind work synergistically, that is why the brain can be reorganized, re-educated and regenerated by forming new nerve connections or paths when learning to control the mind through therapies. There are different successful techniques to support a student in overcoming their psychological difficulties such as referred in [61,62,63]: Mindfulness [9, 38, 78] and Cognitive Therapy [4, 24, 41] where both can be combined [46, 83].

Mindfulness [9, 38, 78] It is a way of becoming aware of our reality, giving us the opportunity to work consciously with our stress, pain, illness, loss or in general the problems of our life. Over the past 20 years studies of mindfulness meditation are promising [15, 78], and offer insight into specific cognitive processes on how it may serve as an antidote to cognitive stress states and benefit physical and psychological processes. Mindfulness minded to compassion and altruistic behaviour has been considered an important research scientific field of study [16]. For instance it has been founded the Center for Compassion and Altruism Research and Education (CCARE) [85] by Stanford University School of Medicine since 2008.

Cognitive Behaviour Therapy (CBT) [4, 24, 41] was initially developed by J. Beck [4] as a treatment for distorted thinking and brief depression by evaluation of negative thoughts influencing the behaviours. CBT is a psychotherapy that proposes modification of the thought to produce effective health improvement as has been shown in over 2,000 research studies [24]. Including tools such as techniques referred in [61, 63] for finding the Element [76], reaching Flow states [55], Silence in Therapy [42] and Poetry Therapy [52] provide value added to our proposal particularly for college students. Mindfulness and Flow States are independent different behaviors however they can be alternated [34].

Cecilia also has the capacity to answer questions of university matters and try to create a link with the student because it considers her pleasures and hobbies. Enriching talks (“mild Therapies”) proposed to be used by Cecilia are mainly based on mindfulness + cognitive therapy and advice in the professional career preferences, which are focused particularly on preventing and managing mild symptoms of stress, anxiety and depression to reduce the risk of failure in the university life due problems in learning, also to optimize mental health, well-being and behaviour of the students when they face the university challenges as it is justified in the work of Ribeiro Icaro et al. [75]. Thus, during sessions with Cecilia, it is intended that the students understand, accept and “become a friend of” their minds and emotions obtaining a better performance both in school and in their personal life. As described in the work of Luksha Pavel et al. [45] these existential skills include an ability to set and achieve goals (willpower), self-awareness/self-reflection ability (mindfulness), an ability to learn/unlearn/relearn (self-development) relevant skills (e.g. skill-formation ability), and more. Based on research of Richard Davison referred in [16] well-being is a skill to be learned. Well being has four constituents where each have received serious scientific attention: 1. Resilience, 2. Outlook, 3. Attention and 4. Generosity. Each of these four is rooted in neural circuits, and each of these neural circuits exhibits plasticity. So if any person exercise these circuits, they will be strengthen.

The core type of dialogue for every dialogue session of Cecilia is Maieutics described by Scraper Randy et al. in [84]. However each single agent task micro-dialogue as secondary type of dialogue can be one of the following according the categories stated by Douglas Walton enumerated and specified in [88]: Persuasion. Inquiry, Discovery, Information-Seeking, Casual chat, Negotiation, Deliberation and Eristic.

The Cecilia architecture has been designed to include a Theory of Mind [80] extended with emotions [60, 81] of the User Agent (the student) as a Logic Programming (LP) Theory in the User Model. It is by LP Knowledge Representation that is possible to reason and plan a Dialogue Composition (DC) to help the user human development considering her beliefs, intentions, desires and emotions.

The main purpose of Cecilia is to develop Compassionate skills of the user. One property to express true creativity is to guarantee the common good of humanity, in our case we are proposing Cecilia architecture and the solution of the CCP ordering the technology for the benefit of human being, the opposite would not be creativity. In [48,49,50] are enumerated several results where science has shown how kindness and pro-social behaviors have a biological imperative. the creation of neural stem cells governing short term memory and the expression of genes regulating the stress response are positively affected by motherly affect, positive cognitive state influences positive immune response and vice versa, etc. As Cindy Mason [48,49,50] has pointed out the repeated interactions with the artifacts we create rub off on us. They are shaping and affecting us continually. Social and emotional relations influence our brain, our genes, our stress reaction and immune system and even wound healing. These findings are significant not just for AI design but to user interfaces, healthcare, education, and design intention in other fields, therefore creating and designing artifacts that support positive emotion such as kindness and compassion are essential to the goal of human-level AI. There is a strong relation between Compassion and Motherly love [48, 50]. The psychophysiophilosophy related to motherly love has been a topic of research in scientific field and there are recent discoveries in neurosciences [48, 50] that give hints on ways to increase motherly love in each of us, where they can be applied to Haptic Medicine into student daily lives through self-help. Cindy Mason has been a pioneer in defining Intelligence in terms of Compassion applied to the design of Artificial Intelligence artifacts. We have designed Cecilia in this line where AI is founded in a definition of Intelligence based in Compassion.

A Knowledge Graph (KG) [22, 56] mainly describes real world entities and their interrelations, organized in a graph, defines possible classes and relations of entities in a schema, allows for potentially interrelating arbitrary entities with each other and covers various topical domains. KG are networks of entities, their semantic types, properties, and relationships between entities. KG are networks of all kind entities which are relevant to a specific domain or to an organization. They are not limited to abstract concepts and relations but can also contain instances of things like documents and datasets. Can be associated to Knowledge Representation in Logic such as RDF, Ontologies or Argumentation.

Contribution of this work is to define the Creative Composition Problem (CCP) for Human Well-being Optimization by Construction of Knowledge Graph using Knowledge Representation and logic-based Artificial Intelligence reasoning-planning where the computation of the Optimal Solution is achieved by Dynamic Programming or Logic Programming. The Creative Composition Problem is embedded within Cecilia: an architecture of a digital companion artificial intelligence agent system composer of dialogue scripts for Well-being and Mental Health. Where Cecilia Framework is instantiated in the Well-being and Mental Health domain for optimal well-being development of first year university students. CCP is instantiated in this applied domain for the composition of dialogues optimizing the Mental Health and Well-being of the student. We define the The Problem of Creating a Dialogue Composition (PCDC) and we propose a feasible and optimal solution of it. CCP as PCDC is applied to optimize maximizing the mental health of the student, but also maximizing the smoothness, coherence, enjoyment and engagement each time a dialogue session is composed. Feasibility of our Cecilia design follows a Proof of Concept strategy [40]. The objectives of Cecilia are presented in [61,62,63].

Our paper is structured as follows: In Sect. 2 we discuss chat-bots applied for mental health well-being. In Sect. 3 it is presented how the Creative Composition Problem (CPP) is embedded within Cecilia: an architecture of a digital companion artificial intelligence agent system composer of dialogue scripts for Well-being and Mental Health. CCP is instantiated in this applied domain for The Problem of Creating a Dialogue Composition (PCDC) optimizing the Mental Health and Well-being of the student. In Sect. 4 it is presented the definition, model and computation of the ‘Creative Composition Problem (CCP)’ using Graph Theory and Algorithms. In Sect. 5 it is described the Master-Agent Artificial Intelligent Composer (MAIC) as a Creative Reasoning-Planning Component formed by two modules. The first module of Diagnosis by reasoning based in a complex theory in a LP KB that will compose an instance of the CCP (which defines and construct the Graph input of the CCP as PCDC problem). And the second module which Prescribes an optimal solution for the CCP as PCDC instance to optimize well-being of the student. In Sect. 6 is presented the evaluation of Cecilia and in Sect. 7 a it is exposed a discussion of Technologies suitable to solve CCP and design of Cecilia Architecture. Finally in Sect. 8 we present our conclusions.

2 Related Work

2.1 Applied Chat-Bots for Mental Health Well-Being

Benefits of chat-bots in Health Care Well-being domain are described in [71]. In details it is delineated how chat-bots in health care may have the potential to provide patients with access to immediate medical information, recommend diagnoses at the first sign of illness, or connect patients with suitable health care providers (HCPs) across their community. Theoretically, in some instances, chat-bots may be better suited to help patient needs than a human physician because they have no biological gender, age, or race and elicit no bias toward patient demographics. Chat-bots do not get tired, fatigued, or sick, and they do not need to sleep; they are cost-effective to operate and can run 24 h a day, which is especially useful for patients who may have medical concerns outside of their doctor’s operating hours. Chat-bots can also communicate in multiple different languages to better suit the needs of individual patients.

Early research in [71] has demonstrated the benefits of using health care chat-bots in many aspects, with accuracy comparable to that of human physicians. Patients may also feel that chat-bots are safer interaction partners than human physicians and are willing to disclose more medical information and report more symptoms to chat-bots. Psychological Internet interventions have frequently been evaluated and are viewed as a medium independent of time and place. They might be able to help reduce treatment barriers and expand the availability of care. Numerous studies [6] have shown that these interventions, often using cognitive-behavioral techniques, are comparable in their effectiveness to classical face-to-face psychotherapy. Psychological problems such as anxiety and depression are already being effectively addressed in this way.

As referred in [5] the work of Samuel Bell et al. introduces Woebot, a template-based chat-bot delivering basic CBT, has demonstrated limited but positive clinical outcomes in students suffering from symptoms of depression.

The work of Eileen Bendig et al. referred in [6] presents promising areas for the use of chat-bots in the psychotherapeutic context could be support for the prevention, treatment, and follow-up/relapse prevention of psychological problems and mental disorders. Also they could be used preventively in the future, for example for suicide prevention. According to the work of Samuel Bell et al. [5] in order to provide scalable treatment, several promising studies have demonstrated clinical efficacy of internet-based Cognitive Based Therapy, whereby the need for a face-to-face presence is negated.

In [89] it is reported a survey of technologies for mental Well-being. In the work of Diano Federico et al. referred in [18] it is presented an state of the art in mindfulness-based mobile applications and the design of a mindfulness mobile application to help emotional self-regulation in people suffering stressful situations. We invite the reader to check the work of Baskar Jayalakshmi et al. referred in [2] where it is reported a comparison of Applied Agents implemented for improving mental health and well-being.

In the work of Jingar Monika et al. referred in [37] it is explored how an intelligent digital companion(agent) can support persons with stress-related exhaustion to manage daily activities. Also it is explored how different individuals approach the task of designing their own tangible interfaces for communicating emotions with a digital companion.

In the work of Inkster Becky referred in [33] it is presented an empathy-driven, conversational artificial intelligence agent (Wysa) for digital mental well-being that is using mindfulness as mild therapy in combination with transfer to psychologist whenever the user ask for it. According to Samuel Bell et al. several studies have investigated the clinical efficacy of remote-, internet- and chat-bot-based therapy, but there are other factors, such as enjoyment and smoothness, that are important in a good therapy session.

In the work of Cindy Mason [43] it is exposed an Intelligent Agent Software for Medicine, it describes how software agents that incorporate learning, personalization, proactivity, context-sensitivity and collaboration will lead to a new generation of medical applications that will streamline user interfaces and enable more sophisticated communication and problem-solving.

In the work of Cidy Mason [51] it is presented how Human-Level AI Requires Compassionate Intelligence, much more than just common sense about the world, it will require compassionate intelligence to guide interaction and build applications of the future. The cognition of such an agent includes Meta-cognition: thinking about thinking, thinking about feeling, and thinking about others’ thoughts and feelings. Cindy Mason summarize the core meta-architectures and meta-processes of EM-2, a meta-cognitive agent that uses affective inference and an irrational TMS.

In [28] it is showed an emotions ontology for collaborative modelling and learning of emotional responses.

In [48] it is presented the Multi-Disciplinary Case for Human Sciences in Technology Design, where it is exposed that connecting the dots between discoveries in neuroscience(neuroplasticity), psychoneuroimmunology(the brain-immune loop) and user experience (gadget rub-off) indicate the nature of our time spent with gadgets is a vector in human health - mentally, socially and physically. The positive design of our interactions with devices therefore can have a positive impact on economy, civilization and society. Likewise, the absence of design that encourages positive interaction may encourage undesirable behaviors. The consequences of the architecture of the 21stcentury conversation between man and machine may last generations. AI and the Internet of Things are primary vectors for positive and negative impacts of technology. The work of [48] describes a growing body of co-discoveries occurring across a variety of disciplines that support the argument for human sciences in technology design.

In the work of Cindy Mason [49] it is presented an Engineering Kindness architecture where it is proposed the Building of A Machine With Compassionate Intelligence.

2.2 Applied Knowledge Graph for Mental Health Well-Being

In [22] it is described definition and works on Knowledge Graph. In [56] it is described the use of Knowledge Graph in Health Well-begin application for Supporting decision making in organ transplanting using argumentation theory. In [91] it is reported a Survey of Knowledge Graph applied in Clinical Decision Support Reasoning Systems. In [79] shows a Knowledge Graph application and construction for Health Domain using Learning Techniques from electronic medical records. Finally in [31] presents different approaches on how to encode graph structure intolow-dimensional embeddings, using techniques based on deep learning and non-linear dimensionality reduction.

In [87] it is described an extension of the Knapsack problem with weighted edges in the graph, it is computed in two phases as a combination of a knapsack problem with a shortest path.

In our proposal CCP as CDP is applied to optimize maximizing the well-being and mental health of the student but also optimizing the smoothness, coherence, enjoyment and engagement each time the dialogue session is composed. As far as we know our Creative Composition Problem as an optimization problem has not been described in the literature. It differs from the work of Voloch [87] since we are maximizing with respect to vertices and weight on the edges. While Voloch is combining Knapsack with Shortest Path, our problem seems a combination between Knapsack and Travelling Sales Problem, we don’t compute the optimal solution in two phases but in a single algorithm using dynamic programming.

3 Cecilia: An Architecture of a Digital Companion Artificial Intelligence Agent System Composer of Dialogue Scripts for Well-Being and Mental Health

In this section is presented the architecture of our system Cecilia which is detailed in [70].

This section has the aim to help the reader to be introduced in the context of our general ‘Creative Composition Problem (CCP)’, where the CCP is instantiated into a specific application domain (mental health and well-being optimization). The CCP will be discussed in the next section since the contribution of our present work is concerning the definition, model and computation of the CCP using Graph Theory, Algorithms and Logic programming solvers. The CCP is instantiated in our Cecilia architecture in order to solve the ‘The Problem of Creating a Dialogue Composition (PCDC)’.

A contribution of this present work is our proposal for the definition for The Problem of Creating a Dialogue Composition (PCDC) and we propose a feasible and optimal solution of it in the next section.

Definition 1

The Problem of Creating a Dialogue Composition (PCDC) . Given a set of resources of AI-tasks, the profit that each AI-task contributes to development mental health and well being of student, the length that each AI-tasks lasts interacting with the student, the profit that a sequence of two distinct related AI-tasks contributes to the coherence, enjoyment and smoothness of a session, the number of AI-tasks interactions expected for a single dialogue session and the time length expected that the dialogue session may last. The problem is To Compose a Dialogue Session as a sequence of AI-Tasks such that optimizes the mental health and well being of the student with an optimal coherent, enjoyable and smoothable session.

An optimal solution for PCDC instance is the ‘Abstract Sequence Dialogue Session (ASDS)’ to be proposed by Cecilia, where for each AI-Task represented as an abstract token name. Each token is associated to Semantic Knowledge, and each token will be mapped to a script specified in a Basic Resources Script Language (BSRL). Each BSRL script is described in a machine language that an imperative language will interpret managing the dialogue interaction as a chat-bot with the User Agent (in our case the Student).

3.1 Cecilia: A Master-Slave AI Agents Digital Companion System Design

Cecilia defines a master-salve conceptual design following a centralized approach. Namely, we create hundreds of slaves (at least one thousand) such that each of them can perform a very concrete task. All the tasks correspond to interactions with the students. Each interaction are specified as atomic micro-dialogues. An example could be simple or complex task such as to teach the student how to try a meditation exercise. Each task performed by a slave-agent is programmed in the Basic Script/Resources Language (BSRL). Associated to each slave we have its Semantic Knowledge. All the Semantic Knowledge of each slave plus a general theory of interaction among them is written in Logic Programming (LP) Language.

So, the LP theory corresponds to the Master-Agent Artificial Intelligent Composer (MAIC) that reasons/plans a sequence of few tasks (for a 10–15 min estimated session) that are performed by our slaves that are presented (coordinated) by a distinguished slave (a program interpreter of BSRL in Python) to the student. An analogy that we can make is the following. The LP agent is like a master composer of a symphony for a particular audience. The pianist is a particular slave that performs a specific task (playing the piano). The director corresponds to our distinguished slave that actually coordinate the rest of slaves. After the execution of the symphony, according to the feedback (applause, reviews, etc.), the composer hopefully learns how to create a better symphony.

The main concrete tasks of our intelligent agent described in [61,62,63, 70].

3.2 The Cecilia Logical-Based AI Agent Digital Companion System

Cecilia is a Reasoning Planning System that consist in a cycle of 4 sequential (Fig. 1) processes-modules described below.

Fig. 1.
figure 1

Architecture of Cecilia logical-based AI agent digital companion system.

I. Abstract Script Dialogue Session (ASDS) is generated by MAIC in this process (Fig. 2 ). ASDS is a composition of slave agents tasks sequence to be performed by Cecilia as a single dialogue session with the student. MAIC basically consists of two modules of KB-reasoning represented and specified via ASP, the lowest one consists of a logical theory that generates -Diagnoses a set of recommendations (resources/assets) that would correspond to construct a graph a CCP as PCDC instance. The highest module consist of an ASP program that proposes the ASDS plan solving an specific problem based in the constructed graph providing a Prescription in dialogue to the student in order to optimize her mental health and well-being. The formal specification of this second stage in terms of an optimization problem The Problem of Creating a Dialogue Composition (PCDC) that is an instance of The Creative Composition Problem.

Fig. 2.
figure 2

I. Abstract script generation

An optimal solution for DCP instance is the intended ASDS to be proposed by Cecilia.

Figure 3 is example of an abstract dialogue session built by MAIC.

Fig. 3.
figure 3

Example of an abstract dialogue session built by MAIC.

Fig. 4.
figure 4

Example of a AI-Task ‘questioning/answering student w.r.t. Finding Element’ BRSL program.

II. Concrete Dialogue Script Generation. Each AI-Task in the composed dialogue sequence (the CCP optimal solution) is translated into a single BSRL script by concatenation.

Figure 4 is an example of a concrete AI-Task dialogue script ‘questioning/answering student w.r.t. Finding Element’ for it’s abstract token name ‘c2’ specified as a BRSL program.

III. Dialogue Interpreter Chat-bot corresponds to the director of the orchestra that executes the composed dialogue session (Single BSRL program) as interactions of AI-Tasks with the student.

We present a simple example of a conversation in Fig. 5.

Fig. 5.
figure 5

Fragment of a conversation between Cecilia and a student.

IV. Feedback Module is an extraction process of relevant information and knowledge. This module filters a user conversation record to obtain the Student Profile State (SPS) updating the extensional Knowledge Base.

4 The Creative Composition Problem (CCP)

This section presents the definition, model and computation of The Creative Composition Problem (CCP) using graph theory, algorithms and logic programming solvers. It is formalized the CCP Knowledge Graph (KG) used by MAIC within Cecilia to make prescription, after this KG has been constructed by reasoning-diagnostic of MAIC. CCP corresponds to The Problem of Creating a Dialogue Composition (PCDC) in our instantiated mental health and well-being domain for Cecilia framework. The prescription, using the constructed Knowledge Graph by diagnostic, builds a composition sequence of AI-task interactions in form of micro-dialogues joined into a single Dialogue Composition Session, a single composed dialogue script, to optimize mental health and well-being of the student (user agent), and to optimize at the same time the links between interactions to provide a smooth, enjoyable and coherent dialogue session.

4.1 Formal Definition

CCP Graph Instance

Let \(G_{L,K}\) be a complete directed graph defined as tuple \(G_{L,K} = (V,E, P_{V}, P_{E},W_{V})\), where V is a set of vertexes;

E is a relation between the set of vertexes \(E = V \times V\);

\(P_{V}\) is function \(P_{V}: V \rightarrow \mathbb {N}\) that represents the profit that each vertex contributes in the sequence that forms the optimal composition to be created;

\(P_{E}\) is a function \(P_{E}: E \rightarrow \mathbb {N} \cup \{0\}\) that represents the profit that a sequence of two distinct vertexes related in E contributes in the sequence that forms the optimal composition to be created;

\(W_{V}\) is a function \(W_{V} \rightarrow \mathbb {N}\) that represents the associated size to each vertex in V that will be considered to restrict the length of the optimal composition sequence to be created.

K is the maximal length in terms of size of vertexes that an optimal composition sequence could sizes.

L is the number of vertexes that must compound the optimal composition sequence.

Feasible Solution

Is a L-tuple \(X = [x_1,\ldots ,x_L]\), where \(\{x_1,\ldots ,x_L\} \in 2^{V}\), \(|\{x_1,\ldots ,x_L\}| = L\) and \(\sum _{i=1}^{L} W_{V}(x_i) \le K\).

Optimal Solution

Is a feasible solution \(X = [x_1,\ldots ,x_L]\) such that maximizes \(Z = \sum _{i=1}^{L} P_{V}(x_i) + \sum _{i=1}^{L-1} P_{E}((x_i,x_{i+1}))\).

Remark: In our instantiated domain problem for mental health and well-being there are always sufficient tasks with weight 1, hence there is always a feasible solution.

The CCP is an ‘Optimal Solution’ of a given ‘CCP Graph Instance’. The ’Optimal Solution’ is also named Optimal Creative Composition Sequence. A ’Feasible Solution’ is also named a Creative Composition Sequence.

4.2 Dynamic Programming Definition of CPP

Given a CCP instance instance \(G(S,K) = <V,E,Pv,Pe>\) we compute the optimal solution using a Dynamic Programming strategy. For a subset S of vertices V, an initial vertex s and a vertex j s.t. \(j \ne s\), let C(Sjkl) be the maximal profit between all feasible solutions of CCP ( composition sequences of vertices in S, starting in vertex s and ending in vertex j, with l number of vertices and which cumulative sum of vertices sizes is lower equal than k).

When \(|S| > 1\) we define \(C(S,s,k,l) = -\infty \) where \(0 \le k \le K, k \in \mathbb {N} \cup \{0\}, 0< l \le |V|, l \in \mathbb {N}\), since the composition sequence can not start and end at s.

Now, let’s express C(Sjkl) in terms of smaller sub-problems. We need to start at s and end at j; if \(i \in S -\{j\}\) is the second last vertex to j in the composition sequence, then the overall profit is the profit from s to i, namely, \(C(S-\{j\},i,k- W_{V}(j),l-1)\) plus the profit of the vertex j, and the profit of the (ij) edge. We must pick the best i such that: \(max \{C(S\!-\!\{j\},i,k\!-\!W_{V}(j),l-1) + P_{V}(j) + P_{E}((i,j)) : i \in S, i \ne j \}\) where \(S \subseteq V, j \in S, j \ne s, 1< l\le |V|, l \in \mathbb {N}, W_{V}(j) \le k, 0 \le k \le K, k \in \mathbb {N} \cup \{0\} \).

\(C(V-\{s\},j,K,L)\) is optimal solution of CCP from vertex s to vertex j, intermediate vertices are in \(V - \{j\}\).

So the Recursive Definition to compute the CCP optimal solution is:

Base case

\(C(\{s\},s,k,1) = P_{V}(s) \) if \(W_{V}(s) \le k, 0 \le k \le K\)

\(C(\{s\},s,k,1) = -\infty \) if \(W_{V}(s) > k, 0 \le k \le K \)

Recursive case

\(C(S,j,k,L) = max \{C(S\!-\!\{j\},i,k\!-\!W_{V}(j),L-1) + P_{V}(j) + P_{E}((i,j)) : i \in S, i \ne j \}\) where \(S \subseteq V, j \in S, j \ne s, L>1, W_{V}(j) \le k, 0 \le k \le K \)

In our Cecilia instantiated framework, for mental health and well-being domain, it must be computed \(max \ C(V-\{s\},j,15,5)\) for all \(j \in V-\{s\}\), where our distinguished vertex s is a ‘greetings’ AI-task micro-dialogue, 15 the estimated time that a dialogue session may last, and 5 the number of different interaction tasks for the student. These constants were recommended as fixed numbers according to a specialized psychological therapist, in order to compose a comfortable dialogue session for the student.

4.3 Dynamic Programming Algorithm

Using dynamic programming, based on the recursive definition to compute the CCP optimal solution, in Algorithm 1 is computed the optimal solution for a given CCP instance. It is used dynamic programming strategy to avoid duplicates in recursive call, using a memory table C(Sjk), where S is \(S \subseteq V\), \(j \in V\), and \(0 \le k \le K\). In this case, for a given CCP instance, the optimal solution will be the \(max \ C(S,j,K)\) for all \(S\subseteq V, |S| = L, j \in V - \{s\}\)

figure a

Observe that lines 8–9, in Algorithm 1, can be easily programmed as a single iteration if the subset of fixed cardinality are already precomputed. In Algorithm 2 it is presented the pseudo code to recover all the feasible solutions that are optimal solution for a given CCP instance. Using traditional backtracking strategy, as usual in dynamic programming techniques, when it is used a memory table.

figure b

4.4 Computational Complexity of Dynamic Programming Algorithm to Compute the Optimal CCP Solution

Given a CCP instance, we would like to know the estimated computational complexity time to compute an optimal solution. When the computation definition of a problem is NP-Hard class, then complexity computation time could be intractable in terms of real run-time machine computation [20].

Sometimes, a NP-Hard problem can be parametrized in order to achieve polynomial time computation, so is the case when in an algorithm definition with a greater than factorial-exponential order complexity, commonly present in combinatorial NP-Hard problems, it can be computable in polynomial time, when one of the argument of the given input instance of a problem definition is fixed as a constant number [20].

It can be easily seen that the definition to compute a CCP optimal solution, for a given CCP instance, is a combination between the well know combinatorial problems The Travelling Sales Problem and The Knapsack Problem see [13]. This since the CCP optimal composition sequence requires to compute a ‘Hamiltonian path’ of a fixed length, where the cost between edges is maximized, but also we would like to select those vertices subject to a capacity knapsack constraint (As in the knapsack problem definition), where also the profits of vertexes is maximized. Since the computation of an optimal solution for a given CCP instance is a combinatorial problem, then this give us an exponential time to compute the solution.

Note that between Algorithm 1 and Algorithm 2 a more complex number of computation is required to solve Algorithm 1 instead of Algorithm 2.

So let’s focus in Algorithm 1 to estimate computation time complexity.

The iterative statements on lines 8–12 are greater in computation time than the iteration on line 3. The computation time on lines 8–12 can be expressed as the number of permutation P(|V|, L) in the ‘for’ statement on lines 8–9, the computation time in the ‘for’ statement on line 11 can be expressed as \(|V|-1\), and computation time of the ‘for’ statement on line 13 can be expressed as K. Therefore the estimated computational complexity time to compute an optimal CCP solution is \(O(V,L,K) = P(|V|,L) \cdot |V| \cdot K\).

However, since we have fixed limit constants as boundaries for the arguments L and K, then we have a polynomial time computation.

Specifically after receiving guidance from a psychologist and other mindfulness experts, many short dialogue sessions are suggested, not a long one, and for this it can be seen that setting the parameter \(L = 5\) (five task per dialogue session ) and \(K = 15\) (15 min that the a whole dialogue session may last) seems to be a recommended measure. This does not exclude recommending to the student some relatively long exercise (20–30 minutes) that he can do on his own.

Since the suggested L is fixed to a value of 5, a naive strategy would require P(|V|, 5) permutations, that would mean a 5 grade polynomial, which is still expensive for a large |L|.

For our mental health and well-being instantiated domain in Cecilia, MAIC constructs a Knowledge Graph with \(|V| \le 20\). This is possible due the logical theories in Diagnostic Module, and also due the structure of the nature of knowledge present in our enriching talks (mild-therapies) domain, when they are formally represented using mathematical logic by LP. Each one of the mild therapies theories presents a partial order structure as a relation between stages to progress in the acquisition of skills, for instance Mindfulness requires an ordered sequence of stages.

Then for the worst case we would have \(P(20,5) = 15504\), and for a worst case where \(L=5\) and \(K = 15\) we have \(O(V,5,15) = 15504 \cdot 5 \cdot 15\), that is around 1, 000, 000, which is still tractable in computation time.

A trade-off w.r.t |V| could be in average cases a fixed value of 15, that can also be considered feasible in computational terms (run time). Moreover diagnostic and prescription are not computed in real time of the session, but between sessions.

It is always possible to relax the problem and use, for example, greedy techniques to obtain feasible solutions close to the optimal for a much larger instance. For example, it can be used a similar strategy such as the one used in a rational Knapsack problem computation, where the ratios between profits of objects and the cost of objects are sorted, in ascendant way, to propose a feasible solution for large inputs, getting close to the optimal solution with an approximate complexity lower than \(O(V,K)= |V|log(|V|)\), lower than 400 for \(|V| = 20\), and it could be considered to prescribe a KG with more than 100, 000 vertexes (AI-Tasks).

4.5 Running Example

In Appendix A there is an example of a CCP Graph Instance. In Appendix B it is shown how dcp is computed using the presented dynamic programming Algorithm 1 and Algorithm 2. Note that the computation is made as a table where sets are increasing by cardinality, then the recursive function C to obtain a DCP optimal solution is computed in terms of the memory table of simpler cases calculated before.

5 Creative Reasoning-Planning: The Master-Agent Artificial Intelligent Composer (MAIC) of Dialogue Scripts for Well-Being and Mental Health

Conceptually the MAIC in Cecilia reasons using Answer Set Programming (ASP) [27, 82] and consists of two modules described in Sect. 3. The first module Diagnoses - Reasons based in a complex theory in a LP KB that will compose an instance of the CCP KG, the diagnostic defines and construct the Knowledge Graph input of the CCP as PCDC problem, presented in the previous Sect. 4. Further details are discussed in this section. The second module Prescribes an optimal solution for CCP as PCDC KG instance to optimize mental health and well-being of the student but also the dialogue session interactions.

5.1 The MAIC Diagnostic: Enriching Talks (Mild Therapies) Theories Specified in ASP

It has been defined for this project 7 logic programming theories under Answer Sets Programming semantics to model the student profile, and to create a dialogue composition proposal for each session with the student.

  1. 1.

    Hobbies Theory. It suggests exercises and conversation recommendations encompassing the student likes.

  2. 2.

    Emotional Well-being Theory. It states description in logic of the OCC model of emotion [60, 80, 81, 86] that has an objective to achieve and maximize happiness of the student [70].

  3. 3.

    Diagnosis of Emotional Type Theory.It diagnoses the emotional status of the student inferred from the student conversation with Cecilia. It keeps track of the emotional status of the student through past conversation sessions to make a better diagnose.

  4. 4.

    Well-being Theory. It suggests mild therapies AI-tasks interactions to compose a enriching talk dialogue session, while considering the feedback of student profile.

  5. 5.

    Academic Theory. It suggest AI-tasks interactions with the aim to upgrade the scholar status of the student, considering academic and emotional student profile.

  6. 6.

    Empathy Theory. It suggests AI-tasks interactions with the aim of strengthening the empathy with Cecilia, but also mainly help the student to achieve a healthy emotional status.

  7. 7.

    Causal Chat Theory. It suggest AI-tasks interactions of casual chat dialogue, within the student dialogue session, with the main purpose of retrieving from the student relevant information that is out from the scope in the retrieval of traditional specific domain theories.

  8. 8.

    Prescription Theory. Obtains an optimal solution given a CCP as PCDC KG instance.

5.2 The MAIC Prescription and Recommendation: Solving the Creative Composition Problem (CCP)

The CCP as PCDC optimization problem as presented in Sect. 4 can be solved by Algorithm. But also It can naturally be encoded in logic programming, for instance it can be easely encoded in CIAO [32], DLV [29] as well as CLASP [26] solvers.

Since CCP 4 is actually a logically stratified logic program and hence we can informally say that is logically very simple program. The three codes (CIAO, DLV, CLASP) are almost the same with minor changes in coding details. The CCP can be encoded with recursive approach as presented in Sect. 4 using APOL. APOL [64] is a partial order programming [67, 69] very similar to mathematical programming, where a function is minimized ( or maximized ) and has a set of restrictions, the difference is that the domain of values is a partial order, where partial order clauses can be expressed as normal clauses. APOL is an extension of ASP that allows to express optimization problems in a very suitable way, integrating disjunctive clauses and partial-order clauses. It performs a dynamic programming algorithm and interacts with DLV [23]. On the other hand there is also an implementation of partial order programming following a standard top-down approach [36].

Defining Profits. Recall that we have profits in the definition of CCP as PCDC instance. One kind of them are associated to each AI-task asset, recall that each AI-task asset is a micro dialogue. The other kind of them are profits associated to every pair of micro-dialogues with the intended meaning of measuring the coherence, enjoyment and smoothness of a session.

The first type of profits assignment to micro-dialogues is defined by means of a logical theory in ASP that would take into account previous answers of the user. For example, suppose the student has anxiety and that for a suggested mindfulness exercise A the user has said to Cecilia that it has been of benefit for him. Then the MAIC by ASP theory would assign a value v1. However, let us also assume that he has previously performed a mindfulness exercise B, and the student has been sceptic regarding the usefulness of that exercise. Then MAIC by ASP theory assign a value of v2 less than v1 to micro dialogue B. For instance v2 could be 1, and v1 could be 8, these values are adjusted through more interactions between Cecilia and the student, but also with a semi-automatic process using Machine learning specially Inductive Logic Programming (this point is still outside the scope of this paper, and for the moment we have fixed rules stated with the endorsement of an expert psychologist). The second type of profits (not yet considered in this work) we assume that it would be a learning process possibly using Machine Learning specially Inductive Logic Programming. It will consist in a combination of a priori rules stated by psychologist combined with Machine Learning rules and the answer of the student. The rules would be derived from a pilot starting group of students interacting with Cecilia, that generalizes in a universal way the concluded rules for profit assignment of the micro-dialogues.

Transition from reasoning about theories representing domain knowledge that generates by reasoning the Knowledge Graph CCP (DCP) instance is made by the following rules structure described in LP under Answer Set Programming Semantics:

To assign profit to an AI-task:

\(vertices(v(x_{i}), P(x_i)) :- \ condition_{m}^{+}, \ not \ condition_{n}^{-}.\)

To assign profit between two AI-tasks:

\(edges(e(x_{i},x_{j}), P_{E}(x_i,x_j)) :- \ condition_{m}^{+}, \ not \ condition_{n}^{-}.\) where \(condition_{m}^{+}\) and \(not \ condition_{n}^{-}.\) are predicates inferred and described from ASP Knowledge Base representing the instantiated domain knowledge.

6 Pre-evaluation of Cecilia

Cecilia was pre-evaluated by bachelor students. The pre-evaluation asked to the students about they appreciation of Cecilia conversations.

What It was made to test the software consisted in the follwing steps:

  1. 1.

    Semi-automatic conversations were generated using Cecilia as an automated user agent (simulating the student) to have dialogue with Cecilia.

  2. 2.

    It was included some Mathematics topic conversations additionally to the ones proposed in Enriching Talks Theories.

  3. 3.

    Some of the automated conversations were selected randomly.

  4. 4.

    It was asked the students what they thought of the conversation, in order to receive retrieval if the conversations are interesting or not.

The students didn’t chat, this is an indirect pre-evaluation.

The pre-evaluation considered a test with the following target aspects for obtain retrieval from the students: 1) creativity, 2) easy to read/learn, 3) interesting, 4) supportive, 5) good, 6) easy, 7) motivating, 8) clear and 9) friendly. Using a discrete scale between 1 and 7, where 1 means the worst behaviour, and 7 means the best behavior. The results were in average a value of 6 for each considered aspect. Seven examples, one for each student, were pre-evaluated.

The Table 1 exposes the pre-evaluation results obtained from the students.

Table 1. Pre-evaluation retrieval obtained from the students

Three comments of the students about the conversations are the following:

“I really like what I read, basically because I learn a lot of thing besides the logical exercises, I like history, and I like a little of literature with the analogy of the ying-yang and the poem, subjects that I am really in love, it’s too interesting to appreciate these subjects to be combined. It makes the learning process to be much funny, that’s motivated me to change my attitude talking about maths, I know maths, I just need to practice, It’s like anything else, you have to practice to be a master, there’s not other way. We are the only ones who are responsibles of develop our knowledge, we already have it! :)”

“It was an interesting conversation, and it helped me to better understand logical connectives. The conversation was very friendly and I liked how the concepts are simplified. Also, it was very easy to read.”

“Very interesting I love it!”

Figure 6 shows an example of the Cecilia GUI application. The used language in the application is Spanish, however it will be translated to an English language version. Cecilia is designed to be independent of the knowledge scripts domain, for example, the use of Enriching Talks. Also Cecilia is independent of the used human language to dialogue with the Agent User (in our case the student).

Fig. 6.
figure 6

Example of Cecilia’s GUI

7 Technologies Suitable to Solve CCP and to Implement the Design of Cecilia Architecture

Another major issue of this paper was to justify the use of ASP besides the one present in the last subsection.

We also propose ASP for the following list of reasons.

  • Flexibility to represent all major issues of the Belief Model of the student in different forms. For instance in a previous work [63] we use a standard Generate/Test technique to represent our problem. Here we use an optimization problem. Both forms were easily encoded in ASP. Default rules were very helpful in both cases. In this second approach the Well-founded semantics was sufficient to express our problem. However adding integrity constraints were useful to ensure correctness of our approach. When the system became inconsistent, due mainly because it finished all the resources that it has, we have a fixed default plan to propose.

  • Availability of well known and mature solvers to be used such as CLASP and DLV. Furthermore, new interesting solvers such as s(CASP) [1, 47] have potential interest in our problem. It is worth to mention that Prolog-type solvers of such as XSB and CIAO [1, 32] can also be considered.

  • ASP can naturally interact with Inductive Logic Programming (ILP)[12]. Recall that ILP [39, 54] is a machine learning paradigm based on logic that allows learning from cases in order to generate rules needed to reason about future similar cases. It should be clear that learning is fundamental in Cecilia with the purpose to understand better the student. For instance, it could learn that the student become sad on Sundays.

  • There are ASP approaches [3, 73] that can used to help in understanding Natural Language (NLP). Clearly NLP is major issue for Cecilia. Being able to understand written text by the students also allows the system to know her better, and hence have more enriching conversations.

  • Updates and believe revision are also fundamental concepts required in our application. There are many well known proposed solutions based on ASP such as [17, 65, 92].

  • There is promising work related with ethical chatbots [21] that could allow Cecilia to become more respectful to improve its ethical interaction with the student.

  • ASP parallelism [19, 74].

  • Planning [23, 44] for example the use of Coala in CLASP [25].

  • Rapid Prototyping: Note that our generate and test code for DCP [63], and the solver to obtain the Optimal Solution of DCP KG described in this work is simply and directly written in ASP, that is one of the reasons why we are using ASP. Furthermore, for example, the use in sentiment analysis computed by solving the set covering [77] and minimal cut [72] problems. It is possible to use set covering to classify patterns where tests of properties can separate between emotions and the number of tests be minimized mapping to a set covering problem. Note that this kind of combinatorial problems are easily encoded in ASP.

  • Handle Preferences and Optimization [7, 8, 53].

Following Gupta’s advice, complex applications, as proposed in this work, will become possible if all these extensions where combined into a single system [30].

8 Conclusions

Contribution of this workFootnote 1 is to Define the Creative Composition Problem (CCP) for Human Well-being Optimization by Construction of Knowledge Graph using Knowledge Representation and logic-based Artificial Intelligence reasoning-planning where the computation of the Optimal Solution is achieved by Dynamic Programming or Logic Programming. The Creative Composition Problem is embedded within CeciliaFootnote 2: an architecture of a digital companion artificial intelligence agent system composer of dialogue scripts for Well-being and Mental Health. Where Cecilia Framework is instantiated in Well-being and Mental Health domain for optimal Well-being development of first year university students. We define the ‘The Problem of Creating a Dialogue Composition (PCDC)’ and we propose a feasible and optimal solution of it. CCP is instantiated in this applied domain to solve PCDC optimizing the Mental Health and Well-being of the student. CCP as PCDC is applied to optimize maximizing the mental health of the student but also maximizing the smoothness, coherence, enjoyment and engagement each time the dialogue session is composed. For Future Work Optimization of Mental Health and Well-being can be enhanced by sentiment analysis. It is possible to use set covering to classify patterns where tests of properties can separate between emotions and the number of tests to be minimized by mapping them to a set covering problem. For this it is possible to use of set covering [77] and minimal cut [72] algorithms. Note that this kind of combinatorial problems are easily encoded in ASP. Also MAIC can be enhanced with Logic Programming integrating Preferences and Optimization [7, 8, 53]. Following Gupta’s advice complex applications as proposed in this work will become possible if all these extensions where combined into a single system [30]. In a recent paper, we investigated how to generate class notes for the development of psycho-affective learning based on a similar methodology as the one presented in this paper, namely the “Creative Composition Problem”, see [10]. For future work we consider to explore the idea of representing Knowledge using alternative non-monotonic paradigms (besides from ASP) such as those found in [11, 57, 58, 66, 68, 69]. As Cindy Mason stated in [49], the mechanisms for reasoning with regards to another’s feelings only makes sense if there is wisdom to go along with it. This is a very important point. For a machine to engage in our world with a compassionate stance, we are faced with the task of articulating the common sense of compassion. Not all engineers and scientists are born with the gift for empathy, sympathy or compassion. We require collaboration with educators, psychologists, mothers, priests, our pets and even the kindness of strangers, to achieve the level of interaction that would enable the compassionate stance in a computational machine. The idea of programming our interfaces and embodied agents with a compassionate stance has great potential for positive influence in our cultures. This is why in our future work we will be integrating assessment of other disciplines to improve the development of compassion in our research work [48, 50].