Smart Sensorization Using Propositional Dynamic Logic

The current high energy prices pose a serious challenge, especially in the domestic economy. In this respect, one of the main problems is obtaining domestic hot water. For this reason, this article develops a heating system applied to a conventional water tank in such a way as to minimize the necessary energy supply by converting it, under certain circumstances, into atmospheric. For this purpose, the domotic system has been equipped with sensors that automate the pressurization of the compartment and solenoid valves that regulate the external water supply. This design, to which different level sensors are applied, sends the information in real time to an artificial intelligence system, by means of deductive control, which recognizes the states of the system. This work shows the introduction of an extension of propositional dynamic logic in the field of energy efficiency. Thanks to this formalism, a qualitative control of the program variables is achieved by incorporating qualitative reasoning tools. On the other hand, it solves preventive maintenance systems through the early detection of faults in the installation. This research has led to the patenting of an intelligent domestic hot water system that considerably reduces energy consumption by setting disjointed heating intervals that, powered by renewable or non-renewable sources, are controlled by a propositional dynamic logic.


Introduction
In this paper we present an intelligent control system for the storage and supply of domestic hot water suitable for domotic installations. This system can take advantage of alternative energy sources (such as DHW solar panels and/or photovoltaic panels for heating the electrical resistance) in order to achieve the highest degree of sustainability and ecology. The behavior of this system can be represented by a logical formalism that allows to describe the processes of the system, to detect failures in it, and to facilitate the tasks of maintenance of the installation. The formalism used is very versatile and allows its application in very diverse areas of domotics, which we will demonstrate through some examples.
Current domotic control systems [1] and energy efficiency [2] have evolved from the simple activation and deactivation of loads [3] to having to consider combinations of states in sensors and actuators [4], determining the mode of operation of the same. An example of this can be found in the control of large photovoltaic solar farms [5], where possible reconfiguration [6] and maintenance [7] problems in the panels require precise measurement [8] and control of each unit [9] through separate activations or outages [10]. The profusion of states to be considered in some systems means that a process is needed to ensure that none of the circumstances that may occur in that process are ignored. This is not something new; in fact, there are already languages that try it, such as GRAFCET, using logic gates [11]. This language is a procedure of synthesis and reduction of both the steps and the memory locations needed to automate an industrial process, using the existing digital simplification methods [12]. Its main problem is that if there is a malfunction of the deduced system, it is very difficult to determine where the error is, since the relationship between the resulting equation and the real logic of the system's operation has been lost [13]. We need a formalism in which that does not happen, so that it can easily be determined where the dysfunction of the resulting equation is located. One of our fundamental aspirations in this paper is to introduce a logic that takes this aspect into account.
On the other hand, in domotic systems, many applications require incremental regulation in what are called "relative values" [14]. An example can serve to clarify these concepts: if we have an intelligent irrigation system, its operation will allow irrigation of it only when the humidity level of the soil requires it, and it can even take measurements in several locations to determine an average value of that humidity [15]. If the value of this humidity advises it, the irrigation system will be activated, but how long will it be irrigated? Normally, for a complete irrigation cycle to be carried out, it suffices that the activation threshold value has been reached, whether or not so much water is required. We need a reasoning system through which we can get it to irrigate, not according to a specific calendar and time, but in the fair value of humidity that our plants require [16]. For this reason, what we will undertake is to increase "a little" the necessary activation time until the desired humidity level is reached.
The examples presented prove the importance of considering qualitative aspects that require to have an intelligent control. The advantage of using qualitative information is that it allows us to handle situations in which we do not need precise numerical information of the system to make decisions [17]. In doing so, we incorporated tools of the qualitative reasoning (QR) to domotic, an approach with many applications in artificial intelligence (AI) (see, for example, [18]).
We propose in this paper a formal representation of domotic systems dealing with all these issues and applied to our invention. Our purpose is to overcome both errors and omissions that may have occurred during its application, in order to be able to contrast what was programmed with the intended rational operation. In addition, the formalism employed allows the incorporation of qualitative information on the status of certain variables and manages it to perform actions [19].
A domotic system can be modeled as a (finite) set of objects belonging to a building (windows, lights, taps, awnings, elevators, appliances, heating systems, etc.) or physical entities with measurable magnitudes (temperature of the water or of a room, the water flow of a tap, the intensity of light, etc.). We will express the properties of states by labels (state labels) that can be numerical (if we want to be precise) or qualitative. Qualitative state labels can be either dichotomous (e.g., open or closed) as well as with gradations (e.g., little, quite, many, . . . ) [20].
The representation of the behavior of a domotic system can be performed by what are called scenes. A scene is an abstract representation of the behavior of a domotic system at a given time, taking into account the state of the variables that we use to describe it. Since a domotic system is a dynamic system, it undergoes modifications, which gives rise to a transition between scenes. In our approach, this transit can be expressed through operations of composition between qualitative labels as values of our variables. For this purpose we will use a qualitative arithmetic based on absolute orders of magnitude (AOM) [21], in which different qualitative sum operations will be defined. The orders of magnitude arise from making some kind of partition of the real line into equivalence classes, where the numbers are grouped under the same category or qualitative class (large, medium, small, . . . ). Arithmetic operations between qualitative classes depend on how the boundaries of these intervals are defined. A study of the properties of different tables for the qualitative sum can be found in [22].
An appropriate formalism to attend transitions between states as well as qualitative arithmetic operations which can generate these states is propositional dynamic logic (PDL) [23]. An advantage of using PDL as a base is that we can make the transition between scenes using a program. PDL also allows us to describe the interaction between actions of computer domain and propositions about situations that we consider relevant for the system that we are dealing with. In addition, it is easy to integrate qualitative arithmetic into PDL through programs. The extended PDL with this feature will be called Dom.
Other logics are also designed to deal with state transitions (e.g., transaction logic [24], event calculus [25], situation calculus [26]); however, we do not need represent specifically the time (as event calculus or situation calculus). In addition, many of the aforementioned are predicate languages [27], which leads to problems with decidability. In our case we have a decidable propositional language, PDL [28], for which has been developed model checking techniques [29] and automated theorem proving techniques [30] through application examples [31].
The article is structured as follows: Section 2 introduces the intelligent multi-behavioral solar water heating system. Section 3 is dedicated to the logic Dom, created specifically to solve domotic systems. In Section 4, the formalization of the intelligent solar water heating system is carried out, using propositional dynamic logic. The last section is devoted to conclusions.

Design of an Intelligent Solar Water Heating System (ISWHS)
The system presented is a hot water accumulator model adapted for solar collector systems which also incorporates an electrical resistance to heat the water of the accumulator when it is required. In actuality, there are multiple systems of this type and in all cases the consumption of hot water is replaced by cold water entering from the external network causing a decrease in temperature, while the electrical resistance tries to compensate for this loss of heat. The problem is that it is not always possible to maintain a temperature acceptable to the user, and, in addition, there is a significant consumption of electrical energy.
Our system solves these problems, is innovative in its design and operation (there is a patent: [32]), minimizes the consumption of electrical energy, and ensures the maximum efficiency of solar panels. Briefly stated, we start from an initial situation in which the accumulator is completely full, the inlet valve of cold water from the network is open, and the air inlet/outlet valve and hot water outlet valve are closed. When there is no solar supply and there is hot water consumption, the system will allow, by means of a set of solenoid valves (the air inlet/outlet valve and the hot water outlet valve open, meanwhile the cold water closes), that the accumulator is emptied to a certain level, significantly lower than the maximum (first stage). At that moment, the second stage begins, during which cold water is allowed to enter from the network and an electrical resistance can be placed into operation. When the water reaches a predetermined intermediate level (third stage), the cold water valve closes. With the consumption, the water of the accumulator descends again to the low level (of the second stage) and the process is repeated, oscillating the water between the two levels (low and intermediate). This process continues as long as there is no caloric inlet from the solar panels. When the solar collector circuit supplies hot water again, the cold water circuit is opened and the electrical resistance (fourth stage) is deactivated. When the water reaches the maximum level (fifth stage), the system returns to the initial state (closing the air inlet/outlet valves and the hot water inlet valve).
We note that the fourth stage can begin in any of the first three stages above, depending on how long the solar collectors circuit is inactive. The second hot water outlet ( 7 in Figure 1) is opened and closed automatically and its behavior has not been described, as it lacks logical control. This system has several advantages over traditional systems: • In traditional systems, the cold water that enters from the network is heated to replenish the hot water consumed when there is not enough solar radiation. In our case, the accumulator is left emptying and the only contribution of the electrical resistance is usually used to keep the water in the accumulator hot (but at a low level of the accumulator volume). Once the solar contribution is recovered, cold water is introduced from the network but it is heated by solar energy. This is a significant energy saving. • As no cold water is introduced during the first stage, in which the water of the accumulator is emptied by the consumption of hot water by the users, there is no decrease of the water temperature in the accumulator by the inlet of cold water, which is normal since the cold water inlet valve is closed. This system keeps the water hot for longer.

•
During the second stage, the hot water consumed is replaced by cold water from the network heated by the electrical resistance. However, since the water volume of the accumulator is lower (not the entire tank, but a quarter), the heat input of the resistance is also lower than a traditional system. Therefore, the energy saving also occurs at this stage. • During the third stage, the accumulator is filled with cold water from the network to return to the initial situation and the solar collectors are heating the water. The temperature of the water inside the accumulator decreases and therefore the temperature difference in relation to the water temperature of the solar collectors is maximum. For this reason, this design ensures maximum efficiency of the solar panels, since the differential of temperature of the water passing through the panels with the water of the accumulator will always be maximum. This produces the maximum performance of the solar collectors.

System Description
The system presented (see Figure 1) aims to achieve maximum energy efficiency. Unlike traditional ones, where the accumulator has four inlets/outlets, the current one has six. The conventional inlets/outlets are those that connect the accumulator 12 to the solar collectors or primary circuit 13 , a cold water inlet of the network controlled by the solenoid valve 6 and a hot water outlet controlled by the solenoid valve 7 . The two additional inlets/outlets are one to allow air to enter the tank 1 and another one for the hot water outlet 8 . The solenoid valves or non-return valves have the purpose of controlling the opening/closing of the inlets/outlets. In total there are three solenoid valves, two of which we have already mentioned, and are as follows: - The air inlet to the accumulator (A). - The cold water inlet from the network to the accumulator (CW). - The hot water outlet from the accumulator (HW) (located in the figure in the places 1 , 6 , and 8 , respectively).
We also have three water level probes inside the accumulator (numbers 2 , 3 , and 4 and an electrical resistance (ER) 5 ).
In this system we will consider three types of temperature: -The temperature of the water inside the accumulator (AT), measured by the temperature probe 11 . - The temperature of the water passing through the panels (PT) measured by the temperature probe 10 . - The temperature requested by the user or setpoint temperature (ST).

System Operation
The general operation is based on the comparison between three different types of temperature and the levels reached by the water inside the accumulator, which will condition the opening and closing of three solenoid valves and the activation or deactivation of an electrical resistance.
We start with a situation where the accumulator is full of water and the CW is open while A and HW are closed.

1.
The operation of the primary circuit is automatic: when the temperature of the water leaving the panels (the same water passes through them, one after another, since they are in series) is greater than that of the water inside the accumulator, water circulates due to the thermosyphon effect. When this is not the case, the water will not flow. This does not need control since it is a physical phenomenon.

2.
Let us describe the operation of the rest of the circuit: • When AT is greater than PT, the three solenoid valves will be activated as follows: CW closes, while A and HW open. The three valves remain in their respective states until the water level inside the accumulator reaches the position of the level probe 3 (LP3) (see Figure 2). At that time, CW opens and we proceed to activate, or not, the electrical resistance (ER), according to the comparison between AT and ST as follows: -If AT is lower than ST, then ER is activated to the hot state; -If AT = ST, then ER is activated to the normal state; -if AT is greater than ST, then ER must be deactivated (cold state).
In addition, cold water will continue to enter until the water level inside the accumulator reaches the level probe 2 (LP2). In this case, CW is closed. This process will allow the water level to be between probe 2 and 3 while the hot water is being used to consume through the lower outlet of the accumulator (see Figure 3). • When PT is greater than or equal to AT, CW will open and ER will be deactivated; when the water reaches level probe 1 (LP1), A and HW will close (see Figure 4).
It should be noted that this process will lead to AT being greater than or equal to PT (again, previous case). Recall that previously we started from the situation we have now reached with respect to the three solenoid valves: CW is open while A and HW are closed; this describes a circuit.   With this system we can guarantee the maximum efficiency of the solar panels, since the temperature differential with the water inside the accumulator will always be maximum.
In addition, the cooling of the water inside the accumulator is also prevented by the entry of cold water from the network, a situation that occurs when hot water is consumed in conventional installations.
The operation of the above described system can be expressed by the following Algorithm 1: Algorithm 1 Procedure of an intelligent water heating system (PIWHS) Initial situation: the accumulator is full of water, CW is open, and A and HW are closed.

The Logic Dom
When using tools for solving domotic problems, such as the one described above, the application of propositional dynamic logic will be used. In this case it will be called Dom logic.

Notation and Basic Concepts
We will use two types of expressions. On the one hand, expressions such as (x 1 , . . . , x k ) are called scene formulas, where each x i is an element of a set of state labels L i . These labels express gradations of the physical magnitudes (e.g., light intensity, tap water flow, room temperature, etc.) or certain states in which the element of the system are found (e.g., the elevator is on second floor, the tap is closed). For example, consider a domotic system in which we want to refer to the state (off or on) of the light and the degree of temperature of a room. We can consider a scene x = (x 1 , x 2 ), where x 1 is the state of light within the range L 1 = {on, off} and x 2 is the state of the room temperature within the range L 2 = {very low, low, normal, high, very high}. Then the scene (on, high) means that the light is on and the room temperature is high. In actuality, in a scene formula we wish to represent only certain relevant aspects of the states in which a domotic system is found; however, many other things can happen that are beyond the description of the scene formula and which, eventually, we may be interested in taking into account. That expressed by the previous scene (on, high) could happen, for example, whether the room temperature is pleasant for the homeowner or not, as if one of the lamps does not work, or all are in perfect condition, etc.
In a scene formula we can use a special label, the empty label, denoted by "−"; its intuitive meaning is to represent that there is no information about the state of a particular component of the scene or that it is not necessary to specify that state (because it has not been modified from a previous specification or for any other reason). The label "−" also allows us to create a common scene to specific scenes, which implies a greater degree of abstraction. Thus, (on, −) refers as concrete instances to (on, very-low), (on, low), etc. Note that "−" (which is not actually a state label) in the latter sense comes to play the logical role of a variable.
Given a scene formula x = (x 1 , . . . , x k ), we will use the expression x { 1 /1,..., k /k} to indicate that we replace simultaneously in x each component x i for i (we admit the possibility x i = i . This indicates that there is no substitution in the i position. It will be useful to consider this possibility), which we denote abbreviated by i /i and where i denotes a state label in L i . The expression x {p 1 ,...,p r } means that we highlight in x the positions p 1 , . . . , p r ∈ {1, . . . , k}. Similarly, the expression x { p 1 /p 1 ,..., p r /p r } , with highlighting positions p 1 , . . . , p r , is obtained by replacing simultaneously the label of each position p i of x by p i .
The composite operations to make transitions among scenes are performed between the elements of each set of state labels L i with a special set of labels called gradient labels, denoted by L G . We can use different sets of gradient labels for different set of state labels depending on the application in mind. As an example of set L G of qualitative labels, a classical partition of R in qualitative classes appears in Figure 5 (see [20,21]): The labels means "negative large" (NL), "negative medium" (NM), "negative small" (NS), "zero" (0), "positive small" (PS), "positive medium" (PM), and "positive large" (PL). The constants α, β are real numbers that are used to delimit the equivalence classes (the particular criteria to choose these numbers would depend on the application in mind). Now, we introduce some notation. If 1 and 2 are two labels (of state or gradient), then 1 2 means that 1 is previous to 2 , that is, for any x ∈ 1 , and y ∈ 2 , we have that x < y. In the previous case, we have the order NL NM NS 0 PS PM PL.
When we use state labels that express dichotomy such as on, off, we will consider off on. The notation indicates the inverse relationship of ; also, 1 2 means that 1 2 or 1 = 2 .
A set of gradient labels L G is intended to increase or decrease the magnitudes of the variables of a scene operating on the status labels using composition. Thus, using the previous partition as set of gradient labels, if the light has a low intensity (state label), we can increase it a little, that is, with a small number or belonging to PS (gradient label), which may result that the light remains within the range of low (even if it has increased in intensity) or pass to the normal state (new label status). In order to perform the compositing operations in this case, we will translate the state labels into gradient labels and use a previously defined qualitative sum operation according to our interests.
There are several types of expressions that we can form when performing operations of composition in the positions of a scene formula. Therefore, the notation p i + + i : p i indicates that in the position p i we must perform a composition operation (sum) between the state label p i ∈ L p i and the (positive) label + i . The nature of + (numerical or qualitative) obviously depends on the labels involved. The sum is qualitative if at least one of the factors is qualitative. If both labels are qualitative, then + i is always a (positive) gradient label and the operation must always generate a qualitative state label p i ∈ L p i such that p i p i . If p i ∈ L p i is qualitative and + i is numerical, then the result of the composition is also a qualitative state label p i ∈ L p i such that p i p i . In the same sense, it occurs if p i ∈ L p i is numerical and + i is qualitative. Similarly, p i + − i : p i indicates that in the position p i , we compose its corresponding state label p i ∈ L p i with the (negative) gradient label − i , which generates a state label p i ∈ L p i such that p i p i .

Syntax
The language of Dom is an extension of the language of PDL with a new set of atomic formulas and specific atomic programs. Concretely, Dom contains the propositional operators → (material implication) and ⊥ (falsity), the program operators ; (composition), ∪ (choice), and * (iteration) and the mixed operators [ ] (necessity) and ? (test). As defined symbols we have (truth), ∧ (and), ∨ (or), ↔ (if and only if), and (possibility) as usual. Formulas and programs are built inductively, using the previous operators, from P (a set of alphanumeric chains), L = L 1 × · · · × L k (a set of scene formulas) being each L i (1 ≤ i ≤ k) a finite set of state labels and a specific parametrized program (called regulator) consisting of several subroutines that analyze below (although regulator can be declared in subprograms we consider it an atomic program, since it requires the simultaneity of all the subprograms that form it, so that it can not be obtained from these with the classic PDL operations as ; or ∪).
If x = (x 1 , . . . , x k ) is a scene formula, then we have as programs the following ones: • Inc {p 1 + + 1 : p 1 ,...,p n + + n : p n } x (increase): This program means that we must increase the level of the values of the positions p 1 , . . . , p n of x, respectively, by the positive labels + 1 , . . . , + n , using a sum operation + (qualitative or numerical). A simultaneous replacement of p i by p i + + i is carried out; e.g., increase a little the temperature of the living room.
• Dec {p 1 + − 1 : p 1 ,...,p n + − n : p n } x (decrease): This program means that we must decrease the level of the values of the positions p 1 , . . . , p n of x, respectively, by the negative labels − 1 , . . . , − n , using a sum operation + (qualitative or numerical); e.g., decrease much the intensity of the kitchen light.
• Watch {p 1 ,...,p n } x (watch): This program means that we simply watch the state labels of the positions p 1 , . . . , p n of x; it is assumed that these would be maintained if there are no actions that change them. The purpose of this program is to explicitly check that these labels do not change even if those in other positions do.
The following program collects all of the above in a single order and is defined: That is, regulator executes the actions of Inc x , and Watch Ψ 4 x simultaneously, something very important in domotic, and without problems, because the positions of the different subprograms that include it are all different. This allows to create a final scene with all the actions executed of these programs without going through intermediate scenes, which would result in case of proceed sequentially.
Note that we can define the previous programs in terms of regulator by a very simple procedure: place the empty set of operations with labels in the corresponding part. Thus, we define Inc In general, we will use an expression such as Inc Ψ x , Dec Ψ x , etc., when we want to refer to one of these programs without specifying the set of substitutions that the program performs in the x scene. With this in mind, we can introduce new specific programs from Change Ψ x to treat dichotomous states, so we have  We can also define mixed dichotomous programs that combine the actions of the previous ones. For example, • Onoff . This program combines On  . We say that y is x-regulated with respect to (abbreviated wrt) Ψ 1 -Ψ 4 if for every i with (1 ≤ i ≤ k) we have one of the following cases: , + is an operation defined for L i and + i is a positive label of the set L G (chosen for L i ).
, + is an operation defined for L i and − i is a negative label of the set L G (chosen for L i ). (on,normal) ](on, normal) ∨ (on, much) indicates that any action that opens the window a little more will lead to it either remaining within the normal parameter of opening or change to a new state, i.e., to become quite open (this requires us to predefine a matrix where a + operation is handled between the state labels and gradient labels so that normal + PS leads to normal or much). The notation normal+PS:2 indicates that in the second position of the scene (on, normal) its label is replaced by some label resulting from the composition normal + PS. Now, we will express a more complex situation. Let us consider the atoms p, q with the respective meanings "the heating is on" and "it is economically beneficial". The following program (denoted by a) expresses the action of closing the window, and also, while the heating is on, makes sure the window is closed: is an instruction of type «while». Then the formula [a] q means that the result of the previous action is always something economically beneficial.

Semantics
A model M is a tuple (W, m) where W is a nonempty set of states (called, more specifically, domotic states). We will use letters as u, v, w (with or without indexes) as representing states. By convenience, each element u ∈ W is to be understood as a domotic state labeled by elements of L.

1.
The meaning function m is required to fulfill the following: (a) m(p) ⊆ W, for every atomic formula p ∈ P.
(b) m(x) ⊆ W, for every scene formula x ∈ L and m(x) = ∅.
(c) For all w ∈ W there exists a scene formula x ∈ L such that w ∈ m(x) (all the states of a model are described by a scene formula). (d) For all w ∈ W and x ∈ L, if w ∈ m(x), then x is unique, that is, for all y ∈ L different from x (in the sense of Definition 1) we have w / ∈ m(y).

2.
We define now the semantics of the specific program regulator. if x = (x 1 , . . . , x k ) is a state formula, then Finally, if ϕ and ψ are formulas and a, b are programs, then we have the following: The semantic concepts of satisfiability, valid in a model, and valid are the usual ones.

Formalizing ISWHS
In this section we will express the operation of the system using the programming language of the logic.

System States
We will use scene formulas with seven state variables (x 1 , x 1 denotes the temperature of the water accumulated in the accumulator (AT). • x 2 denotes the temperature of the water passing through the solar panels (PT). • x 3 denotes the status of the cold water solenoid valve of the network to the accumulator (CW). • x 4 denotes the status of the solenoid valve in the upper part of the accumulator (A). • x 5 denotes the status of the solenoid valve of the lower hot water outlet of the accumulator (HW). • x 6 denotes the status of the electrical resistance (ER). • x 7 denotes the set point temperature defined by the user (ST).
We will also use "propositional constants" to denote a certain behavior of the system: • si denotes that the water level inside the accumulator reaches the probe of the upper level i (i = 1, 2, 3).
The sets of state labels L 1 , . . . , L 7 are as follows:

Composition Operations
In this section we introduce the composition operations. We start with the table for the gradient labels (L G ). Recall the partition made in Figure 5, where we consider NL = (−∞, −β), PS = (0, α], NM = [−β, −α), 0 = [0] and PM = (α, β]. The L G partition can contain a different numerical set appropriate for each application (a subset of R). On the other hand, from now on, we will consider that β = 2α.
In Table 1, the operation + G between qualitative classes yields either a qualitative class or a range of qualitative classes [X, Y] (where X Y), which we express, indicating all the qualitative classes that compose this interval separated by commas for clarity. For example, NS+ G PS provide us, as a result, the interval [NS, PS], comprising NS, 0, PS. On the other hand, we used 1 to denote the interval [NL, PL]. The operation + G verifies the following: + G is consistent with the usual real sum +, that is, for all qualitative classes, X, Y, and all x ∈ X, y ∈ Y, X + G Y corresponds to the smallest interval (in the sense of inclusion) formed by qualitative classes containing x + y (see [19,22]). For example, NM+ G PM = [NS, PS].
In Tables 1-3, the state labels are translated to gradient labels to make the composition that we make in Table 1. In Table 2 we take vc = NL, c = NM, n = [NS, PS], h = PM, and vh = PL. In Table 3 Table 3 Table 3 is [n, h] = [NS, PL], we finally have this output. Table 2 describes the behavior of both the water temperature of the solar panels and the water inside the accumulator. The composition Table 3 with the labels of L 6 ( Table 2) allows us to calculate both the increase and the gradual decrease of the ER intensity. For instance, we took a scale for L G where α = 5 and β = 10. Now we consider the following projection of L G over L 1 (L 2 ) in Table 2 . Now, adding, for example, a small number (say 3) to a normal temperature (n) can lead us to stay within that temperature or go to hot (h), depending on how close the system is to the limit 35.

Logical Description of System Behaviour
The Dom logic can describe the behavior of the system. For instance, let us assume a state where AT > PT, AT < ST, the valves CW, A, and HW are open, and ER has a normal intensity and water level reaches probe 3 (a state perfectly coherent with a correct run of the algorithm for the system). Thus, s3 and the scene x = (−, −, on, on, on, n, −) hold at that state. The procedure establishes then that a new state where the scene y = (−, −, on, on, on, h, −) holds must be reached. If we operate gradually, increasing the intensity a little (a small number) until reaching the hot level, the formula

Detecting Failures in System Operation
In this section we show how our formalism captures what should not happen if we want the system described to work correctly.
We will give some examples of significant failures of the system. We will consider transitions from a state w to a state v, placing below each state some formulas true at it. The failure detected is a trouble with a valve or the resistance. In the following we add new atoms of the type sij, with the intuitive meaning "the water inside the accumulator is between the level probes i and j". Now, we list some troubles emphasizing in the scenes only the information more relevant.
The first case in the previous Table 4 states that in the scene x = (−, −, −, off, −, −, −), the component x 2 belongs to a qualitative class lower than the component x 1 . At the state w, the formulas x and s1 are true. At the state v, the same scenes x and s12 are true. The program establishes that A should be opened if AT > PT (i.e., x 2 x 1 ). This means that the scene x must vary the component x 4 to on. However, at state v, valve A stays off. After a sufficient lapse of time the water will be between probes 1 and 2, so the situation at v should be a different scene of x, namely, (−, −, −, on, −, −, −). This means that, according to the behavior of the program at this stage, the formula Onoff {4,5},{3} x (−, −, −, off, −, −, −) must be false at w. Therefore, if the procedure for the system is correct, we can suspect a failure in valve A. The rest of the cases are interpreted in a similar way. In general, for these troubleshooting tasks in a graph, model-checking techniques can be applied. Scene Formula x w v Trouble x 1 x, s1 x, s12 HW x 3 = on, x 2 x 1 x, s2 x, s12 CW x 2 x 1 , x 7 x 1 , x 6 = n x, s3 y, s2 (where y 6 = c) ER

Conclusions
The main conclusions of this work are as follows: Efficiency: The proposed solution increases the efficiency of domestic hot water heating systems using renewable energies. Normally, the thermal profitability of this type of installation, powered by solar energy, represents a saving of around 80% of that required for heating [1]. The use of the system presented in this paper represents an additional saving of (100 − x)% (depending on the position x of the lowest level sensor with respect to the bottom of the tank). Multiplicity: The water heater itself has three different behaviors, depending on its load level. In principle, when the solar thermal input is sufficient, it works as a conventional domestic hot water storage tank powered by solar thermal energy. In a second state, when the heat transfer fluid coming from the panels has a lower temperature than the water in the tank to be heated, it cuts off the external supply and becomes atmospheric, allowing the interior water to be used without any possible mixing with the water at a lower temperature from the network. In the third state, when a minimum level is reached, it will behave similar to an electric heater, powered by renewable or non-renewable energies, working on a minimum level of water compared to the original. Economy: The system would allow an estimated global saving of 0.80 × 100−x 100 based on the conventional energy used for the heating process. In addition, it allows to use all the water contained in the tank at the maximum temperature reached (until reaching the minimum load level marked by the probe located in the lowest zone) without mixing it with the water coming from the supply network (which would cool the mixture at a considerable speed). Likewise, when the outside temperature does not allow the stored water to be heated, it considerably reduces the consumption of electrical energy by significantly reducing the volume of water that will be used from that moment onwards (it practically becomes a heating as the water flow passes through). Complexity: The resolution by means of propositional dynamic logic has overcome the disadvantages of traditional systems to detect faults in the logical operation of the system. In addition, it contains programs that allow qualitative control of the states of the variables, with built-in qualitative addition operations, which gives the system great flexibility. This type of operation is very useful in home automation as many applications require qualitative regulation.

Patents
In parallel to this paper was developed the patent number ES2627209B2 [32].