Diagnosis in Tennis Serving Technique

: Tennis is a sport with a very complex technique. Amateur tennis players have trainers and/or coaches, but are not usually accompanied by them to championships. Curiously, in this sport, the result of many matches can be changed by a small hint like ‘hit the ball a little higher when serving’. However, the biomechanical of a tennis stroke is only clear to an expert. We, therefore, developed a prototype of a rule-based expert system (RBES) aimed at an amateur competition player that is not accompanied by his/her coach to a championship and is not serving as usual (the RBES is so far restricted to serving). The player has to answer a set of questions about how he/she is serving that day and his/her usual serving technique and the RBES obtains a diagnosis using logic inference about the possible reasons (according of the logic rules that have been previously given to the RBES). A certain knowledge of the tennis terminology and technique is required from the player, but that is something known at this level. The underlying logic is Boolean and the inference engine is algebraic (it uses Groebner bases).


Introduction
The first and third authors of this paper are veteran tennis players, regularly taking part in both veterans and open tennis championship (they were the +55 doubles champions of Extremadura region in 2018). They have a patent ( Fernando María Sánchez Fernández, Eugenio Roanes Lozano: Dispositivo de entrenamiento para determinar la posición óptima en el tenis. Country: Spain. Request number: 201730051. Priority date: 3 de febrero de 2017. Patent holder: Universidad de Extremadura y Universidad Complutense de Madrid.) regarding the recovery position in tennis [1]. The first author has been the +45 champion of Extremadura region several times and is a tennis instructor ranked not so long ago among the top 500 players of Spain).
The second author was their tennis coach. He is an "ITF Level 2 Tennis Coach" with a long experience in teaching tennis and coaching tennis players both in Argentina and Spain.
Finally, the fourth author is an experienced expert systems developer.
Tennis is a sport with a sophisticated technique [2][3][4]. The big distance between the hand and the racket's sweet spot makes it difficult to play well. The high precision required is normally achieved through the learning of the technique and a hard training. Something similar happens with golf.
It is well known that there are many aspects in tennis teaching that have to be addressed (tactic, technique, physical training, etc.) and a coach is clearly needed for improving the player's level. For instance, the biomechanical of a stroke is only clear to the expert's eyes (although there are some personalized computer studies of this aspect for elite athletes like high jumpers).
Most amateur tennis players are not accompanied by a coach when playing championships, except when playing team competitions. In this kind of championship, only the captain of the team can talk to players during the matches. An experience of many tennis players is that a simple hint like "hit the ball at a higher point when you serve" can change the result of a match.
We would like to address here just this aspect of the whole process of tennis coaching: finding out what is going wrong in a certain match with respect to the player's usual technique. It applies inference to the answers of the player to a set of questions regarding both the problem and the player's usual technique. It requires a certain knowledge of the technique from the player (let us underline that it is focused to amateur competition players, not to beginners). Therefore, this is neither a system devoted to learn how to play tennis, nor a substitute for a coach. It only tries to correct the mistakes of the stroke going wrong along one match and return the situation to the usual one.
The article is illustrated with the part of the system corresponding to the serve. While the algebraic model for rule-based expert systems (RBES) is well known (see Section 4), the application to tennis is, as far as we know, entirely novel.
The expert system we have developed tries to model a well-known international standard describing the tennis serving technique. An important issue in an expert system is the knowledge base and the formalism used to represent it. Since propositional Boolean logic is enough to represent this standard, we have adopted this logic to embody the knowledge of our expert system. Artificial Intelligence has proposed many elaborated representation formalisms to model uncertainty or fuzzy knowledge in expert systems, as well as machine learning techniques to acquire this knowledge base. However, we have not required all these techniques for designing our system because of the same purpose of our system: output the recommendations for tennis serving technique, according to a well-known international standard. For our purpose we have only needed to model this standard by means of propositional Boolean logic, resulting in a system with a high performance.

Some Introductory Notes about Rule-Based Expert Systems Based on Boolean Propositional Logic
In this section, we will describe some outlines of RBES based on Boolean propositional logic for representing knowledge. It may be skipped by an acquainted reader, but it is included in order to make the article self-contained, as it could have readers from different environments.

Definition 1 (Formula).
A formula A is recursively defined as: We define C as the set of formulae.
Definition 2 (Rule). By its importance, we define rules as the formulae with the form ( where each formula A 1 , . . . , A n is either an atomic proposition (X) or the negation of an atomic proposition (¬X).

Remark 1.
We have chosen the previous definition of rule because we believe it is the most intuitive one. A rule of the form: Similarly, the implications could be substituted by disjunctions, what has the advantage of using fewer symbols, but would make it less readable.

Remark 2.
Sometimes some rules with the same antecedent and different consequents are grouped into a single formula for the sake of brevity and clarity. For example, the information in the three rules: Although it is not formally correct (it doesn't comply with Definition 2), we shall hereinafter admit these abbreviations as rules too (in order to save space and to clarify the underlying ideas related to tennis hitting technique). The algebraic approach used has no problem to deal with this sort of formulae, and the timings obtained for globally computing which output are obtained are negligible (as will be shown in Section 6).

Definition 3 (IC).
An integrity constraint (IC) is a piece of knowledge added by the experts and expressing that some potential facts cannot hold at the same time.
Definition 4 (elements of a RBES). By means of the concept of formula, we can define the elements of which a RBES is composed: The input of a RBES is concerned with the information related to the environment of the RBES. This information is described by means of a finite number of different atomic propositions. Output: The output of a RBES is concerned with the information inferred by the RBES. It is also described by means of a finite number of atomic propositions. Knowledge-Base: The knowledge-base of the RBES is concerned with the information contained in the system, which is used along with the input of the RBES to infer the output of the system. In a RBES based on propositional Boolean logic, this knowledge-base will be mostly represented by a finite set of rules which may require to define new atomic propositions. Consequently, the knowledge-base of the RBES is described by a finite set of formulae {R 1 , ..., R n } ⊂ C.
The concept of tautological consequence of propositional logic is used for determining the knowledge which the RBES can infer. As usual, we make use of {A 1 , ..., A n } |= B to denote that the formula B is a tautological consequence of the formulae A 1 , ..., A n (we say that {A 1 , ..., A n } |= B if and only if, whenever the formulae A 1 ,...,A n hold, then B also holds). In this way, a RBES with knowledge base {R 1 , ..., R n } and having as input the set of formulae {F 1 , ..., F n } infers the formula B ∈ C if and only if the following holds: Another important issue on propositional Boolean logic is related to the concept of consistency (in an informal way, {A 1 , ..., A n } is inconsistent if both a formula and its negation can be simultaneously inferred). Obviously, the formulae embodying the knowledge-base of a RBES must be consistent.

Organizing the Knowledge of the Tennis Hitting Technique RBES
The propositional variables of the RBES have been grouped in four homogeneous blocks: The structure of the RBES is summarized in Figure 1.

Facts-Block I (Generalities)
In this first block consists just of three questions: the system is informed about the kind of serve the player is executing and two technical details about his/her abilities (see Table 1). We shall briefly explain these facts for those unaware of tennis technique. You are an expert player and you can serve in any of the three ways (x 1 , x 2 , x 3 ) tossing the ball the same place z 0 You usually jump when executing this kind of serve y 1 Regarding the spin: • in a flat serve the ball is not rotating, • in the slice serve it rotates around a vertical axis (the trajectory is curved and bounces to one side), • in the topspin serve the ball is rotating around an horizontal axis (the upper part of the ball moves forward and the lower part moves backwards): the aerodynamic effect is that the ball bounces closer and higher.
For the sake of simplicity we consider x 1 , x 2 , x 3 mutually exclusive. This is not completely accurate, as an advanced player could serve with a mixture of topspin and slice spins.
Each kind of serve normally requires the ball to be tossed at different places (see l 1 , l 2 , l 3 below) (Let us underline that the encoding chosen use redundant variables, that could be avoided if using 3-valued variables instead. Nevertheless, according to our experience, Boolean computations are much faster, even if more variables are needed.). But this way the opponent is aware of the kind of spin of the serve. It is really difficult although possible to always toss the ball at the same place (z 0 ) (Observe that there is no particular reason for choosing the subscripts of the variables (0, 1, 2, 3, 4, 5, 6, 7) the way they have been chosen.). Roger Federer is a good example of this ability.
If the serve is correctly executed, the player tends to move upwards (y 1 ) and forward (inside the court).

Facts-Block II (Details)
Tennis is not a precise science in the sense that there isn't a unique valid truth for everyone. There are different "schools" and ways to teach and even to execute the different strokes.
They also change with time: before Björn Borg nearly no player played two-handed backhand and used topspin. Nowadays the vast majority of professional players play two-handed backhand and use topspin in most strokes from the back of the court. Meanwhile, two-handed forehand wasn't a success and was only used by a few players like Hans Gildemeister.
There are very successful unorthodox styles, like Jim Courier's baseball-style forehand or Rafael Nadal's forehand finishing. A system like the one presented here would be useless in such a case.
There are also great tennis players with an untraditional serve, like John P. McEnroe, and players with a pure traditional service, like Roger Federer.
Therefore we have just considered what could be considered the standard serving technique [2][3][4], and have transcribed the causality underlying what is explained in the tennis books into logical rules to the best of our knowledge.
After many years of development of this sport, we consider that there is a consensus in the clear cause-effect relation in tennis hitting technique. For instance, a clear simplified example is the following: if you serve and the ball is too far away in front of you and too low when you hit it, the racket will be facing the floor when it hits the ball, so the ball will bounce just in front of you, never on the other side of the net. Obviously most situations are more complex, but the consensus in the standard technique and the above mentioned causality is what makes plausible (from our point of view) to use a Boolean logic approach, as we compare what the player is doing with the standard theoretical technique (the latter admitted as a truth). Something due to the authors is how they have translated that consensual knowledge into rules.
As said in Section 3.2 above, we have considered that the different spins are mutually exclusive as simplification.
Tables 2 and 3 (splitted only for the sake of space) collects the most typical items of the execution of the serve to be taken into account (in our personal opinion).
Let us underline the difference between t 1 and a 1 : the toss can be correct or even too high, but the player can let the ball fall too low anyway.
It is clear that we have the following incompatibilities: • d 1 and d 2 are incompatible, • t 1 , t 2 and t 3 are mutually incompatible, • l 1 , l 2 and l 3 are mutually incompatible, • a 1 and a 2 are incompatible.

Description Propositional Variable
Feet initial position / distance (choose at most one): Distance between feet too big d 1 Distance between feet too small d 2 Arms initial situation: Arms initially not relaxed Grip: You are holding the grip firmly e 1 This is your usual grip for this kind of serve e 2 Table 3. Facts-Block IIb.

Description Propositional Variable
Kinetic: You flex slightly your knees before hitting the ball k 1 Your knees are straight when hitting the ball k 2 You balance slightly backward and forward during the execution of the serve and you move or tend to move forward k 3 You feel your abdominals do work during the execution of the serve k 4 Your racket begins the swing more or less behind your head at its usual initial position k 5 The swing of your racket finishes too early k 6 You are hitting the ball with your feet on the air k 7 Coordination: You "feel coordinated" when serving today o 1

Guards
Some rules will clearly have an immediate consequence in the serve, but others just provoke intermediate consequences that we have denoted "guards" (Table 4). We have decided to introduce these technical intermediate steps in the rule base in order to organize it more clearly, as they somehow give technical reasons for the knowledge expressed in the rules involved. They can be very useful for an expert in tennis and logic revising the RBES.

Description Propositional Variable
Lack of balance (equilibrium of the body) g 1 Physical difficulty or impossibility to execute the stroke that way g 2 Acceleration w.r.t. normal rhythm or some parts of the execution of the serve not on time g 3 Incompatibility with the player's own technique g 4 Initially, we have decided that guards were not visible to the players, as they are technical reasons for reaching an effect in the serve. Nevertheless they could be an explanation for a player that is curious for obtaining a logic explanation of what happens, as they are somehow an intermediate level of diagnosis. If it is considered interesting for the system to include them as visible output, it would be enough to compute some more normal forms (see Sections 6.1 and 6.2 below).

Output
Let us detail the main different output of performing a certain serve (Table 5). No incompatibility should be included among the output. Different technical errors could lead to opposite outputs, what is not contradictory.

Rules and Incompatibilities (Integrity Constraints)
We shall not detail all the rules but we shall begin by giving an example of two simple concatenated rules.
Rule 5 is: and it means: R5: Too low toss → Lack of balance (equilibrium of the body) (the consequent not an output, but a guard-an intermediate technical conclusion, not visible for the end user). This rule expresses that, if the player throws the ball in to the air too low, he/she will hit the ball in a flexed position, what will provoke a lack of balance. Rule 23 is: and it means: R23: Lack of balance (equilibrium of the body) → Imprecision ∧ Stroke too weak (lack of power) (the latter are conclusions-output). Therefore, if we have t1, we conclude c1 and c3 This is a very simple example, just to get the flavour of the process. We do not detail all rules in this way for the sake of space. The rules regarding the facts considered are: and the rules corresponding to the guards are: Let us underline that we have grouped some rules for the sake of brevity. For instance should be formally written (this way it would be in accordance with Definition 4). Similarly, we have included xor (exclusive or) in R10: The knowledge behind this rule could have also be written: (note that in this case R10n ∧ IC0 → R10 but R10 → R10n ∧ IC0). Next, we enumerate integrity constraints related to choose one option over three ones: and the integrity constraints regarding choosing at most one option out of two are:

An Algebraic Model for RBES
In this section, we will see how we can implement an expert system based on Boolean propositional logic in a computer algebra system.
Let us consider an expert system based on Boolean propositional logic with propositions X 1 . . . X m . Each formula in C can be represented as a Boolean polynomial (see Definition 5). This representation makes use of the ideal I in Z 2 [x 1 , ..., x m ]: Notation 1 (NF). Let NF(pol, I) denote the 'normal form' of polynomial pol modulo ideal I.

Definition 5 (function ϕ).
We define recursively the function ϕ : C −→ Z 2 [x 1 , ..., x m ] as follows: As may be seen in the previous definition, for any formula A, ϕ(A) is a polynomial in Z 2 [x 1 , ..., x m ] whose variables are never to a power greater than 1 (continuously computing the reduction modulo ideal I is equivalent to work in the residue class ring Z 2 [x 1 , ..., x m ]/I). Besides, the total degree of the polynomial may be, at most, equal to the number of variables.
Indeed, the question of determining whether a RBES with knowledge-base {R 1 , ..., R n } infers the formula B when its input is the set of facts {F 1 , ..., F n } may be solved by checking whether the following holds: NF(ϕ(¬B), I + ϕ(¬F 1 ), ..., ϕ(¬F n ), ϕ(¬R 1 ), ..., ϕ(¬R n ) ) = 0 We can simplify the previous expression through the definition of the following ideals: In this way, the expression above results into: Similarly, the consistency of such RBES for the set of facts {F 1 , ..., F n } can be decided using Groebner bases, as it is equivalent to: what can be written: GB(I + J + K) = 1

Maple Implementation
The implementation used has been written in the computer algebra system Maple (Maple is a trademark of Waterloo Maple Inc., Waterloo, ON, Canada) and was introduced in 2008 [22] . The complete code is included in order to show how brief the code of the algebraic approach is (just a few lines). Firstly the algebraic packages for computing Groebner bases and normal forms and for declaring the polynomial ring where calculations will take place, are loaded: restart; with(Groebner): with(Ore_algebra): Afterwards the list of polynomial variables, the polynomial ring, and the ordering (pure lexicographic with the order for variables given by list SV), are declared: SV:=x1,x2,x3,z0,y1,d1,d2,v1,w1,t1,t2,t3,l1,l2,l3,a1,a2,m1,e1,e2, k1,k2,k3,k4,k5,k6,k7,o1,g1,g2,g3,g4,c1,c2,c3,c4,c5: A:=poly_algebra(SV,characteristic=2): Orde:=MonomialOrder(A,'plex'(SV)): Now the ideal (iI), generated by the square of the polynomial variables minus themselves, is defined using the auxiliary function fu: Let us observe that the generators of the ideals are given as lists of polynomials. The Groebner bases of the ideals are automatically computed by Maple command Basis just by introducing the list of generators and the chosen order, as shown in Section 6.

A Remark about Timings
Although it is well-known that the complexity of Groebner bases computation is double exponential in the worst case in the general case, there are very important simplifications in the algebraic model for RBES knowledge extraction and verification: • the base field of the polynomial ring is Z 2 (it has characteristic 2, instead of 0), • the degree in each variable is at most 1 for all polynomials, • the total degree of all polynomials is less or equal to the number of variables (it is a polynomial Boolean ring, or, if the structure of the RBES is directly translated, a polynomial Boolean algebra [10]). These features allow to treat problems of a size that would not be treatable, for instance, in real geometry. For example, the RBES of [18] consists of 313 rules (of the type specified in Remark 1) that are simplified to 182 complex rules (in the way mentioned in Remark 2). The problem treated here, with 26 rules and 14 integrity constraints, is tiny in comparison.
The specialized software PolyBoRi [23] is extremely fast due to dealing only with Boolean rings, that is, with this special kind of rings.

Conclusions
The main achievement is that there is no comparable RBES devoted to tennis hitting technique (as far as we know).
This is a first step in the exploration of this kind of RBES. Many more things could be done. As future work, a comfortable GUI should be developed, either stand alone, like in [18], or accessible through Internet, like [19]. If Maple was the chosen tool to implement the RBES, Maplets could be used, although it would be even faster to use a specialized software such as MiniSat [24] or PolyBoRi [23]. Nevertheless, performance is not the key issue here, as we are just exploring the field and the system is (at least so far) simple.
Another important extension is to include backward reasoning in order to automatically determine which single propositional changes could change a certain output. This can be achieved with the same algebraic approach used, as shown in [25], but it development is not trivial and is left for a future work.
Also the possibility to use modal many-valued logics is not yet discarded, as the player can have doubts and perhaps not all variables should be considered Boolean.
Obviously the system could be detailed with more facts (like wind) and more complex possibilities (like mixing slice and topspin effects). Moreover, it could be extended to the other main strokes of tennis.
With the implementation included above, the player can study the effect of changing some of the given facts.