A Knowledge Graph Logical-Based AI Construction and Optimization Solution Applied in Cecilia: An Architecture of a Digital Companion Artiﬁcial Intelligence (AI) Agent System Composer of Dialogue Scripts for Well-Being and Mental Health

. Contribution of this work is to Deﬁne the Creative Composition Prob-lem (CCP) for Human Well-being Optimization by Construction of Knowledge Graph using Knowledge Representation and logic-based Artiﬁcial 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 arti-ﬁcial 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 ﬁrst year university students. We deﬁne 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. Cecilia helps students to manage stress/anxiety to attempt the prevention of depression. Students can interact through the digital companion making questions and answers. While the system “learns” from the user it allows the user to learn from herself. Once the student discovers elements that were unnoticed by her, she will ﬁnd a better way to improve when discovering her points of improvement.

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.

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 templatebased 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 mindfulnessbased 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 wellbeing.
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 metacognitive 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.

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.

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).

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 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.

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. 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.

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.

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 wellbeing 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.

CCP Graph Instance
Let G L,K be a complete directed graph defined as tuple 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 → N ∪ {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 → 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.

Optimal Solution
Is a feasible solution X = [x 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.

Dynamic Programming Definition of CPP
Given a CCP instance instance G(S, K) =< V, E, P v, P e > 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 = s, let C(S, j, k, l) 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).
since the composition sequence can not start and end at s. Now, let's express C(S, j, k, l) in terms of smaller sub-problems. We need to start at s and end at j; if i ∈ 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, plus the profit of the vertex j, and the profit of the (i, j) edge. We must pick the best i such that: So the Recursive Definition to compute the CCP optimal solution is: 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 ∈ 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.

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 (S, j, k), where S is S ⊆ V , j ∈ V , and 0 ≤ k ≤ K. In this case, for a given CCP instance, the optimal solution will be the max C(S, j, K) for all for all S s.t. S ⊆ V , |S| = c, s ∈ S do 10: for all j ∈ S, j = s do 12: for k = 0 to K do 13: if (WV (j) ≤ k) then 14: 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.

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 for all j ∈ V do 5: for k = 0 to K do 6: if dcp(S, j, k) == Opt then 7: tuple = empty queue 8: getT uples(C, S, j, k, s, tuple, tuples) 9: 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) · |V | · 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 | ≤ 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 · 5 · 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).

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.

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.

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. Hobbies Theory. It suggests exercises and conversation recommendations encompassing the student likes. 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. 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. 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. 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. 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. 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. Prescription Theory. Obtains an optimal solution given a CCP as PCDC KG instance.

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: where condition + m and not condition − n . are predicates inferred and described from ASP Knowledge Base representing the instantiated domain knowledge.

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. Semi-automatic conversations were generated using Cecilia as an automated user agent (simulating the student) to have dialogue with Cecilia. 2. It was included some Mathematics topic conversations additionally to the ones proposed in Enriching Talks Theories. 3. Some of the automated conversations were selected randomly. 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.  Three comments of the students about the conversations are the following: "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).

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].

Conclusions
Contribution of this work 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 Cecilia 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].

A Appendix 1 % The f o l l o w i n g i s an example o f a CCP Graph I n s t a n c e .% The f o l l o w i n g i s an example o f a CCP Graph I n s t a n c e . % The i n p u t f o r m a t c o n s i s t o f t h e numeric c o n s t a n t s : number o f v e r t i x e s , L , K . % F o l l o w i n g by two v e c t o r s W and P V and one m a t r i x P E .
n u m v e r t i x e s = 9 . L = 4 . K = 15 . Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license and indicate if changes were made.
The images or other third party material in this chapter are included in the chapter's Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the chapter's Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder.