Extending Real Logic with Aggregate Functions Samy Badreddine1 , Michael Spranger1,2 1 Sony AI Inc, 1-7-1 Konan Minato-ku, Tokyo, 108-0075 Japan 2 Sony Computer Science Laboratories Inc, 3-14-13 Higashi Gotanda, Tokyo, 141-0022 Japan Abstract Real Logic is a recently introduced first-order language where formulas have fuzzy truth values in the interval [0, 1] and semantics are defined concretely with real domains. The Logic Tensor Networks (LTN) framework has applied Real Logic to many important AI tasks through querying, learning, and reasoning. Motivated by real-life relational database applications, we study adding aggregate functions, such as averaging elements of a relation table, to Real Logic. The key contribution of this paper is the formalization of such functions within Real Logic. This extension is straightforward and fits coherently in the end-to-end differentiable language that Real Logic is. We illustrate it on FooDB, a food chemistry database, and query foods and their nutrients. The resulting framework combines strengths of descriptive statistics modeled by fuzzy predicates, FOL to write complex queries and formulas, and SQL-like expressiveness to aggregate insights from data tables. Keywords Many-Valued Logic, Relational Database, Querying, Aggregation, Neurosymbolic AI 1. Introduction Real Logic is introduced in Logic Tensor Networks (LTN) [1, 2], a neurosymbolic framework that supports querying, learning, and reasoning with rich data and abstract knowledge about the world. Real Logic is a first-order language with concrete semantics such that every expression has an interpretation in real and continuous domains. In particular, LTN converts Real Logic formulas, e.g. βˆ€π‘₯βˆƒπ‘¦(is_friend(π‘₯, 𝑦) ∧ Italian(𝑦)), into TensorFlow computational graphs. Recent works have applied Real Logic to many of the most important AI tasks, including supervised classification, data clustering, semi-supervised learning, embedding learning, reasoning or query answering [1, 3, 4, 5, 6]. Querying, however, remains limited by syntactic limitations of First-Order Logic (FOL). Despite being a powerful query language on knowledge graphs, FOL cannot express many useful queries written in the most popular database applications such as SQL. These databases organize relations in tables defined with rows and columns. We commonly apply aggregate functions to extract insight features over sets of row values. For example, the following query proposed in [7] over a relation R 1 with attributes ”employee” and ”department”, and a relation R 2 with attributes ”employee” and ”salary”, is trivial in SQL: NESY’20/21 : 15th International Workshop on Neural-Symbolic Learning and Reasoning, October 25–27, 2021, IJCLR. Envelope-Open badreddine.samy@gmail.com (S. Badreddine); michael.spranger@gmail.com (M. Spranger) Orcid 0000-0003-1624-9188 (S. Badreddine); 0000-0001-9443-7008 (M. Spranger) Β© 2021 Copyright for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0). CEUR Workshop Proceedings http://ceur-ws.org ISSN 1613-0073 CEUR Workshop Proceedings (CEUR-WS.org) SELECT R1.Dept, AVG(R2.Salary) FROM R1, R2 WHERE R1.Employee = R2.Employee GROUPBY R1.Dept HAVING SUM(R2.Salary) > 1000000 Comparable queries are not adequately captured by traditional logical languages, as their semantics are not naturally equipped with aggregate functions such as S U M or A V G . In this paper, we study adding aggregate functions to Real Logic. Real Logic can naturally support aggregate functions for two reasons: 1) individuals and domains are grounded with real features, 2) variables are interpreted as finite sequences of individuals. These sequences and real features are reminiscent of the rows in SQL-like tables and constitute ranges over which the aggregate functions can straightforwardly operate. The paper starts with an overview of Real Logic in Section 2. In Section 3, we formalize aggregate functions as mathematical operators and as part of a Real Logic signature, the latter being the key contribution of this paper. In Section 4, we illustrate the functions with simple queries on FooDB, a food chemistry dataset. In [7], authors dress a comprehensive summary for adding aggregation functions in the context of logics. The authors study aggregates for a 2-sorted logics. The first sort is interpreted as a usual logical domain, with ”abstract” semantics and set relationships. The second denotes the rationals β„š, on which the aggregate functions operate. In contrast, the concrete semantics of Real Logic does not require a distinction between such sorts. Aggregate operators have also been studied in Prolog and Datalog-like languages [8, 9, 10]. Perhaps the closest fit to this paper are fuzzy querying systems for relational databases [11, 12, 13]. Real Logic similarly grounds the semantics of formulas with fuzzy truth-values. Let π‘₯ be a variable that denotes people. To represent is_tall(π‘₯), rather than using a crisp boolean condition height(π‘₯) > 180, one can use a continuous truth-value in [0, 1] whose scaling depends on descriptive statistics of the height in the population. Notice that these truth values do not denote probabilities like in probabilistic databases [14]. Fuzzy querying systems allow making flexible queries about traditional (crisp) or fuzzy data. Incorporating aggregate functions in Real Logic gives such expressive power to LTN, and integrates coherently with its other aspects. 2. Real Logic 2.1. Basics and Notations Real Logic [1, 2] is defined on a first-order language β„’ with a signature that contains a set of constant symbols (individuals), a set of functional symbols, a set of relational symbols (predicates), and a set of variable symbols. It allows to specify relational knowledge about the world, e.g. the atomic formula is_friend(bob, alice) states that alice is a friend of bob and the formula βˆ€π‘’βˆ€π‘£(is_friend(𝑒, 𝑣) β†’ is_friend(𝑣, 𝑒)) states that the relation is_friend is symmetric, where 𝑒, 𝑣 are variables, bob, alice are constants and is_friend is a predicate. Contrarily to the abstract semantics of FOL, the elements of the signature are grounded to data, mathematical functions, and neural computational graphs. The connectives are grounded to fuzzy semantics. To emphasize that symbols are grounded using real-valued features, we use the term grounding, denoted by 𝒒. Individuals are grounded as tensors 1 of real features. Functions are grounded as real functions, and predicates as real functions that specifically project onto a value in the interval [0, 1]. Consequently, β„’-formulas are not assigned to boolean true or false values, but instead are grounded to a truth-value in the continous interval [0, 1]. For example, in the expression is_friend(bob, alice), 𝒒 (bob) and 𝒒 (alice) can be vector embeddings in β„π‘š . The friendship relationship can be approximated by a cosine similarity function 𝒒 (is_friend) ∢ xβ‹…y (x, y) ↦ ||x||||y|| , or a more complex function, depending on the application. Individuals are typed and belong to domains. Logical domains are grounded to real domains that shape the individuals. For example, alice, bob are individuals of the domain people, and 𝒒 (people) = β„π‘š . β„’-functions and predicates are defined with an arity and a domain for each argument. For functions, we also define an output domain. For example, the function best_friend(π‘₯) takes an argument from people and returns an individual from people. A variable π‘₯ is grounded as an explicit sequence of 𝑛π‘₯ individuals from a domain, with 0 < 𝑛π‘₯ < ∞. 2 This differs from a FOL variable, which is a placeholder for any individual from the universe. Consequently, a term 𝑑(π‘₯) or a formula 𝑃(π‘₯) constructed recursively with a free variable π‘₯, will be grounded to a sequence of 𝑛π‘₯ values too. Terms and formulas are constructed recursively in the usual way, given that functional and predicate symbols are applied to an appropriate number of terms with appropriate domains. Complex formulas are constructed using the usual logical connectives, ∧, ∨, β†’, Β¬, and the quantifiers βˆ€, βˆƒ. Real Logic interprets connectives using fuzzy semantics, and quantifiers using special aggregator functions. In particular, [1] recommends to use the product configuration, which has been shown in [15] to be better suited for gradient-based optimization (see Section 2.2), with minor modifications for numerical stability. In the product configuration, conjunctions (∧) are grounded with the product t-norm Tprod , disjunctions (∨) with the product t-conorm Sprod , implications (β†’) with the Reichenbach implication IR and negations (Β¬) with the standard fuzzy negation NS . Existential quantifiers (βˆƒ) are grounded with the generalized mean M𝑝 , with 𝑝 β‰₯ 1, which also corresponds to the p-norm of the inputs in this particular setting. Universal quantifiers (βˆ€) are grounded with the generalized mean w.r.t. the error values ME𝑝 , with 𝑝 β‰₯ 1. limπ‘β†’βˆž M𝑝 (𝑒1 , … , 𝑒𝑛 ) = max{𝑒1 , … , 𝑒𝑛 } and limπ‘β†’βˆž ME𝑝 (𝑒1 , … , 𝑒𝑛 ) = min{𝑒1 , … , 𝑒𝑛 }. Tprod (𝑒, 𝑣) = 𝑒𝑣 (1) Sprod (𝑒, 𝑣) = 𝑒 + 𝑣 βˆ’ 𝑒𝑣 (2) IR (𝑒, 𝑣) = 1 βˆ’ 𝑒 + 𝑒𝑣 (3) NS (𝑒) = 1 βˆ’ 𝑒 (4) 1 𝑛 𝑝 1 𝑝 M𝑝 (𝑒1 , … , 𝑒𝑛 ) = ( βˆ‘ 𝑒𝑖 ) (5) 𝑛 𝑖=1 1 Here, a ”tensor” denotes a multidimensional numerical array, as commonly used in the ML community. This is not to confuse with how tensors are defined in mathematics or physics. 2 Notice that, because a variable π‘₯ is grounded as a sequence instead of a set, the same value can occur multiple times in π‘₯. However, the order of the values in the sequence does not matter. Figure 1: A Real Logic sentence grounded to a computational graph. 1 𝑛 𝑝 1 ME𝑝 (𝑒1 , … , 𝑒𝑛 ) = 1 βˆ’ ( βˆ‘(1 βˆ’ 𝑒𝑖 )𝑝 ) (6) 𝑛 𝑖=1 In [1], authors also introduce diagonal quantification and guarded quantifiers. Guarded quantifiers restrict the quantification over the individuals with groundings that satisfy some boolean condition. For example, in: βˆ€π‘₯ (βˆƒπ‘¦ ∢ age(π‘₯) > age(𝑦) (is_parent(π‘₯, 𝑦))) (7) the boolean condition age(π‘₯) > age(𝑦) restricts the quantification over 𝑦. We do not use diagonal quantification in this paper, but the interested reader will find more information in [1]. Intuitively, it is a special form of quantification that performs a Python’s z i p over two or more variables before applying the aggregator.3 2.2. Knowledge, Querying and Optimization Knowledge is represented not only by logical formulas but also by the grounding 𝒒 which explicitly connects symbols occurring in formulas and what concretely holds in the domain. For example, the grounding of alice in real features that describe her height, age, etc., is knowledge. This grounding definition can be parametric if 𝒒 (alice) is a set of embedded features to learn. In that case, we write 𝒒 (alice ∣ πœƒ), where πœƒ is the set of trainable parameters. Similarly, is_friend(alice, bob) can be grounded using an explicit cosine similarity function or can be grounded using a trainable neural network. Consequently, learning knowledge in Real Logic is not limited to inferring new formulas, but also concerns the parameters of a grounding. We define the satisfaction of a formula as its grounding. Querying a formula πœ™ is therefore equivalent to evaluating 𝒒 (πœ™), which returns a truth-value in [0, 1]. One can also query a term 𝑑 by evaluating 𝒒 (𝑑), which returns an individual (or a sequence of individuals, if the term has free variables) from some real domain. 3 https://docs.python.org/3/library/functions.html#zip Let 𝒦 define a collection of formulas, as represented in traditional logical knowledge bases. The satisfaction of 𝒦 under a parametric grounding 𝒒 (β‹… ∣ πœƒ) is defined as the aggregation of the satisfactions of each πœ™ ∈ 𝒦. The result depends on the choice of aggregate operator, denoted by SatAgg. Often, SatAgg is defined as ME𝑝 , also used to ground the βˆ€ operator. In LTN, one can search the optimal grounding, that is the optimal set of parameters, to satisfy a theory according to the following objective: πœƒβˆ— = argmaxπœƒ SatAgg 𝒒 (πœ™ ∣ πœƒ) (8) πœ™βˆˆπ’¦ Because Real Logic grounds expressions in real and continuous domains, LTN attaches gradients to every sub-expression and consequently learns through gradient-descent optimization. 3. Aggregate Functions 3.1. Definition An aggregate function is a mathematical operation involving a range of values that results in a single representative value. Existing literature usually defines aggregate functions on (sub)sets of real or rational numbers [9, 16, 7]. We adapt the definition for Real Logic, where logical domains can be grounded to many types of real domains. Let 𝕀in and 𝕀out denote such domains. Definition 1. An aggregate function is a collection of functions π’œ = {A(0) , A(1) , … , A(∞) }, where A(𝑛) ∢ (𝕀in )𝑛 β†’ 𝕀out . Each 𝑛-ary function A(𝑛) describes how the aggregator behaves on an 𝑛-element input. In particular, A(0) is the constant produced on an empty set of inputs, and A(∞) defines the behavior when applied to an infinite set of inputs. When no confusion can arise, we simply write A instead of A(𝑛) . In many cases, 𝕀in = 𝕀out . For example, if 𝕀in = ℝ, then mean, min, max are all operators that return objects in the same domain. On the other hand, if 𝕀in = ℝ3 , a function count will output results in ℝ (more precisely, β„•) and therefore 𝕀in β‰  𝕀out . Notice that, for an application in Real Logic, the behavior of A(∞) does not have to be specified as variables cannot be sequences of infinite length for practical reasons. Notice also that the aggregators used to approximate βˆ€, βˆƒ are a special case of aggregate functions with 𝕀in = 𝕀out = [0, 1]. 3.2. As Real Logic Functions Incorporate such aggregate functions into β„’ is straightforward. The concrete, real domains of Real Logic can be mapped to the ones in Definition 1, Additionally, β„’-variables are sequences, and any term recursively constructed from a variable is a sequence too. Aggregate functions can operate over these sequences. Definition 2. An β„’-aggregate function symbol 𝐴 with input domain 𝐷in and output domain 𝐷out , is grounded using an aggregate function A (Definition 1) such that 𝒒 (𝐷in ) = 𝕀in and 𝒒 (𝐷out ) = 𝕀out . Let π‘₯ be a variable symbol, and |𝒒 (π‘₯)| = 𝑛, that is π‘₯ is grounded as a sequence of 𝑛 individuals. For any term 𝑑(π‘₯) with free variable π‘₯, such that 𝒒 (𝑑(π‘₯)) ∈ 𝒒 (𝐷in ), we have: 𝒒 (𝐴π‘₯ 𝑑(π‘₯)) = A𝑖=1,…,𝑛 (𝒒 (𝑑(π‘₯))(𝑖) ) (9) where 𝒒 (𝑑(π‘₯))(𝑖) is the evaluation of 𝒒 (𝑑(π‘₯)) using the 𝑖-th individual of π‘₯. The syntax is similar to that of quantifiers, e.g. βˆ€π‘₯ πœ™(π‘₯). Here, βˆ€ is replaced by an β„’-aggregate function symbol 𝐴, and the formula πœ™(π‘₯) is replaced by a term 𝑑(π‘₯). For ease of notation, and if no confusion can arise, we simply write A to denote both the β„’-symbol 𝐴 and its grounding A. Example 1. Let π‘₯ be a variable that denotes people. In particular, let 𝒒 (π‘₯) = ⟨alice, bob, charlie⟩ denote a sequence of three individuals. We can query the average height of π‘₯, using an aggregate function mean, with: 𝒒 (meanπ‘₯ height(π‘₯)) = mean3𝑖=1 𝒒 (height(π‘₯))(𝑖) (10) 𝒒 (height(alice)) + 𝒒 (height(bob)) + 𝒒 (height(charlie)) = (11) 3 The output is a new term, embedding the average height in the population, which can be used as an input to other formulas. Notice that we can combine aggregate functions with guarded quantification (see Equation 7) by re-using the same syntax and functionality. Example 2. Following the Example in 1, let us consider that alice and bob are Italian, but charlie is not. Let Italian(π‘₯) be a boolean predicate that returns either 1 (true) or 0 (false). One can query the average height of Italians with: 𝒒 (meanπ‘₯∢𝐼 π‘‘π‘Žπ‘™π‘–π‘Žπ‘›(π‘₯) height(π‘₯)) = mean3𝑖 = 1 𝒒 (height(π‘₯))(𝑖) (12) 𝑠.𝑑. 𝒒 (Italian(π‘₯))(𝑖) = 1 𝒒 (height(alice)) + 𝒒 (height(bob)) = (13) 2 Most of the common aggregate functions (except count) are differentiable. Consequently, they still integrate nicely with the end-to-end differentiability of Real Logic and LTN. In the following experiments, we only explore querying with aggregate functions. However, aggregate functions could also be integrated with optimization in LTN. 4. Experiments 4.1. FooDB Dataset FooDB 4 is a database that provides information on food chemistry and food constituents, including macronutrients, micronutrients, and many of the constituents that give foods their 4 www.foodb.ca Table 1 Excerpt of macronutrient data gathered from FooDB. Proteins, fats, carbohydrates and fibers numbers are listed in g/100g. Energy is in kcal/100g. In total, there is macronutrient data for 797 ingredients. food name food group kcal proteins fats carbs fibers Savoy cabbage Vegetables 27.0 2.0 0.1 6.1 3.1 Kiwi Fruits 60.5 1.1 0.6 14.2 2.6 Garlic Herbs and Spices 245.0 11.5 0.6 52.9 5.8 Cashew nut Nuts 579.8 16.6 47.2 30.4 2.9 Cucumber Gourds 35.5 0.5 0.2 8.3 1.0 Pineapple Fruits 65.8 0.5 0.1 16.4 0.8 Dill Herbs and Spices 196.4 12.6 5.1 36.2 10.2 Peanut Nuts 580.2 24.6 49.8 18.8 7.7 Asparagus Vegetables 19.9 2.3 0.3 3.4 1.7 Oat Cereals and cereal products 385.3 11.7 16.6 53.8 8.7 flavor, color, taste, texture, and aroma. The data is compiled from existing literature and databases, in order to provide the most comprehensive food chemical database. We focus on querying macronutrient data from FooDB. In total, FooDB lists macronutrient information for 797 ingredients. We average the information sourced from the USDA5 and from the Technical University of Denmark6 . We also use some of the simple ontologies about food groups defined in FooDB. 4.2. Grounding Ingredients are grounded using their macronutrient attributes and their food groups, the latter being encoded as integer labels. Functional symbols are mostly getters of these attributes. We use explicit vocabulary for most of the terms. For example, let π‘₯ be a variable for ingredients. The function symbol prot(π‘₯) gives the protein level of ingredients, kcal(π‘₯) gives their energy level, and so forth. For the aggregate functions, we use traditional operators such as mean, max, or std. Predicates such as is_cereal(π‘₯) assert if the ingredient belongs to the corresponding food group. In this experiment, such ontology predicates evaluate to 0 (false) or 1 (true). For grounding the connectives of the language, we use the product configuration presented in Section 2. ME𝑝 (βˆ€) is implemented with 𝑝 = 20, making it relatively close to the min operator. 4.2.1. Predicate is_high We use two fuzzy predicates is_high and is_low to describe values on a scale. Let π‘₯ be a real value sampled from a distribution 𝑋. To define how high is π‘₯ compared to the other values in the distribution, we use the concept of Cumulative Distribution Functions (CDF). is_high𝑋 (π‘₯) = 𝑃𝑋 (𝑋 ≀ π‘₯) (14) 5 U.S. Department of Agriculture, Agricultural Research Service. FoodData Central, 2019. https://fdc.nal.usda.gov/ 6 Food data (frida.fooddata.dk), version 4, 2019, National Food Institute, Technical University of Denmark Intuitively, we use the probability that another sample will take a value less than or equal to π‘₯ as a truth degree that defines how high the value of π‘₯ is. In this experiment, we assume that logistic distributions approximately fit the nutrient data.7 Let πœ‡ be the mean value of the distribution and 𝜎 be its standard deviation. Using the formula of the CDF of a logistic distribution, the model for is_high computes: π‘₯ βˆ’πœ‡ is_high(π‘₯, πœ‡, 𝜎 ) = S( ) (15) 𝜎 where S(𝑦) = 1+𝑒1 βˆ’π‘¦ is a sigmoid function. is_low is computed by querying Β¬is_high. Aggregate functions are used to compute the mean πœ‡ and standard deviation 𝜎 in Equation 15. 4.3. Queries We illustrate using queries about food nutrients in ingredients, that mix descriptive statistics and complex logical queries. In particular, we ask: Q 1. What cereal product is not high in calories? Q 2. What cereal product is high in protein? Q 3. What cereal product is high in protein and not high in calories? Q 4. For every ingredient, being high in protein implies being high in calories? Q 5. For every ingredient, being high in fats implies being high in calories? The detailed formulas are in Table 2. We evaluate if a cereal is high in, for example, calories, using other cereals as a scale (notice the guarded quantifier with condition is_cereal(π‘₯)). When querying about free variables (Q 1 , Q 2 , Q 3 ), we present the top 3 ranking results. Using a similar approach, we could integrate information on price, seasonability, etc., to rank alternatives on continuous scales. Virtually, there is no limitation to the complexity of queries. 5. Conclusion In this paper, primarily motived by commercial database applications, we studied adding aggregate functions to Real Logic. As a querying system, it combines strengths of 1) descriptive statistics, modeled through fuzzy predicates, 2) FOL syntax to write complex queries, and 3) SQL-like expressiveness to aggregate and collect insights from data tables. As many common aggregate functions are differentiable, Real Logic with aggregate functions can still be end-to-end differentiable. If the knowledge graph entries are associated with embeddings, one can use continuous optimization techniques to efficiently answer queries [17, 18, 19]. In particular, in [17], authors propose an approach based on gradient-descent that uses a logical language akin to Real Logic, where fuzzy semantics approximate connectives. The same approach could incorporate aggregate functions and support a wider range of queries. 7 In real-life applications, adequate statistical tests should validate the choice of distribution. In this paper, we do not conduct such tests as our results are illustrative and not part of our contribution. Table 2 Querying about calorific and protein levels of cereal products in FooDB. id Query Top-3 Results Scores 𝑦? is_cereal(𝑦) ∧ Β¬is_high(kcal(𝑦), Bulgur 0.84 Q1 meanπ‘₯∢is_cereal(π‘₯) kcal(π‘₯), Wild rice 0.79 stdπ‘₯∢is_cereal(π‘₯) kcal(π‘₯)) Corn 0.79 𝑦? is_cereal(𝑦) ∧ is_high(prot(𝑦), Multigrain bread 0.92 Q2 meanπ‘₯∢is_cereal(π‘₯) prot(π‘₯), Triticale 0.88 stdπ‘₯∢is_cereal(π‘₯) prot(π‘₯)) Potato bread 0.84 𝑦? Q 1 (𝑦) ∧ Q 2 (𝑦) Multigrain bread 0.56 Q3 Potato bread 0.55 Oriental wheat 0.50 βˆ€π‘¦ (is_high(prot(𝑦), meanπ‘₯ prot(π‘₯), stdπ‘₯ prot(π‘₯)) Q4 0.56 β†’ is_high(kcal(𝑦), meanπ‘₯ kcal(π‘₯), stdπ‘₯ kcal(π‘₯))) βˆ€π‘¦ (is_high(fats(𝑦), meanπ‘₯ fats(π‘₯), stdπ‘₯ fats(π‘₯)) Q5 0.74 β†’ is_high(kcal(𝑦), meanπ‘₯ kcal(π‘₯), stdπ‘₯ kcal(π‘₯))) References [1] S. Badreddine, A. d. Garcez, L. Serafini, M. Spranger, Logic Tensor Networks, arXiv:2012.13635 [cs] (2021). URL: http://arxiv.org/abs/2012.13635, arXiv: 2012.13635. [2] L. Serafini, A. d. Garcez, Logic Tensor Networks: Deep Learning and Logical Reasoning from Data and Knowledge, arXiv:1606.04422 [cs] (2016). URL: http://arxiv.org/abs/1606. 04422, arXiv: 1606.04422. [3] F. Bianchi, M. Palmonari, P. Hitzler, L. Serafini, Complementing Logical Reasoning with Sub-symbolic Commonsense, 2019, pp. 161–170. doi:1 0 . 1 0 0 7 / 9 7 8 - 3 - 0 3 0 - 3 1 0 9 5 - 0 _ 1 1 . [4] F. Bianchi, P. Hitzler, On the Capabilities of Logic Tensor Networks for Deductive Rea- soning, in: AAAI Spring Symposium: Combining Machine Learning with Knowledge Engineering, 2019. [5] I. Donadello, L. Serafini, Compensating Supervision Incompleteness with Prior Knowledge in Semantic Image Interpretation, arXiv:1910.00462 [cs, stat] (2019). URL: http://arxiv.org/ abs/1910.00462, arXiv: 1910.00462. [6] E. van Krieken, E. Acar, F. van Harmelen, Semi-Supervised Learning using Differentiable Reasoning, arXiv:1908.04700 [cs] (2019). URL: http://arxiv.org/abs/1908.04700, arXiv: 1908.04700. [7] L. Hella, L. Libkin, J. Nurmonen, L. Wong, Logics with aggregate operators, Journal of the ACM 48 (2001) 880–907. URL: https://doi.org/10.1145/502090.502100. doi:1 0 . 1 1 4 5 / 5 0 2 0 9 0 . 502100. [8] W. Faber, G. Pfeifer, N. Leone, T. Dell’Armi, G. Ielpa, Design and Implementation of Aggregate Functions in the DLV System, arXiv:0802.3137 [cs] (2008). URL: http://arxiv. org/abs/0802.3137, arXiv: 0802.3137. [9] M. Grabisch, J.-L. Marichal, R. Mesiar, E. Pap, Aggregation functions: Means, Information Sciences 181 (2011) 1–22. URL: https://hal.archives-ouvertes.fr/hal-00539028. doi:1 0 . 1 0 1 6 / j . i n s . 2 0 1 0 . 0 8 . 0 4 3 , publisher: Elsevier. [10] A. Van Gelder, The well-founded semantics of aggregation, in: Proceedings of the eleventh ACM SIGACT-SIGMOD-SIGART symposium on Principles of database systems, PODS ’92, Association for Computing Machinery, New York, NY, USA, 1992, pp. 127–138. URL: https://doi.org/10.1145/137097.137854. doi:1 0 . 1 1 4 5 / 1 3 7 0 9 7 . 1 3 7 8 5 4 . [11] S.-M. Chen, W.-T. Jong, Fuzzy query translation for relational database systems, IEEE Transactions on Systems, Man, and Cybernetics, Part B (Cybernetics) 27 (1997) 714–721. doi:1 0 . 1 1 0 9 / 3 4 7 7 . 6 0 4 1 1 7 , conference Name: IEEE Transactions on Systems, Man, and Cybernetics, Part B (Cybernetics). [12] J. Galindo, A. Urrutia, M. Piattini, Fuzzy Databases: Modeling, Design and Implementation, IGI Global, 2006. URL: http://services.igi-global.com/resolvedoi/resolve.aspx?doi=10.4018/ 978-1-59140-324-1. doi:1 0 . 4 0 1 8 / 9 7 8 - 1 - 5 9 1 4 0 - 3 2 4 - 1 . [13] R. Mama, M. Machkour, A study of fuzzy query systems for relational databases, in: Proceedings of the 4th International Conference on Smart City Applications, SCA ’19, Association for Computing Machinery, New York, NY, USA, 2019, pp. 1–5. URL: https: //doi.org/10.1145/3368756.3369105. doi:1 0 . 1 1 4 5 / 3 3 6 8 7 5 6 . 3 3 6 9 1 0 5 . [14] D. Suciu, D. Olteanu, C. RΓ©, C. Koch, Probabilistic Databases, Synthesis Lectures on Data Management 3 (2011) 1–180. URL: https://www.morganclaypool.com/doi/abs/10. 2200/S00362ED1V01Y201105DTM016. doi:1 0 . 2 2 0 0 / S 0 0 3 6 2 E D 1 V 0 1 Y 2 0 1 1 0 5 D T M 0 1 6 , publisher: Morgan & Claypool Publishers. [15] E. van Krieken, E. Acar, F. van Harmelen, Analyzing Differentiable Fuzzy Logic Operators, arXiv:2002.06100 [cs] (2020). URL: http://arxiv.org/abs/2002.06100, arXiv: 2002.06100. [16] E. GrΓ€del, Y. Gurevich, Metafinite Model Theory, Information and Computation 140 (1998) 26–81. URL: https://www.sciencedirect.com/science/article/pii/S0890540197926754. doi:1 0 . 1 0 0 6 / i n c o . 1 9 9 7 . 2 6 7 5 . [17] E. Arakelyan, D. Daza, P. Minervini, M. Cochez, Complex Query Answering with Neural Link Predictors, arXiv:2011.03459 [cs] (2021). URL: http://arxiv.org/abs/2011.03459, arXiv: 2011.03459. [18] T. Friedman, G. V. d. Broeck, Symbolic Querying of Vector Spaces: Probabilistic Databases Meets Relational Embeddings, arXiv:2002.10029 [cs] (2020). URL: http://arxiv.org/abs/2002. 10029, arXiv: 2002.10029. [19] M. Wang, R. Wang, J. Liu, Y. Chen, L. Zhang, G. Qi, Towards Empty Answers in SPARQL: Approximating Querying with RDF Embedding, in: D. VrandečiΔ‡, K. Bontcheva, M. C. SuΓ‘rez-Figueroa, V. Presutti, I. Celino, M. Sabou, L.-A. Kaffee, E. Simperl (Eds.), The Semantic Web – ISWC 2018, Lecture Notes in Computer Science, Springer International Publishing, Cham, 2018, pp. 513–529. doi:1 0 . 1 0 0 7 / 9 7 8 - 3 - 0 3 0 - 0 0 6 7 1 - 6 _ 3 0 . A. Computational Efficiency As LTN implements Real Logic using Tensorflow computational graphs8 , it inherits from Tensorflow’s built-in optimizations. For example, on a local portable machine, we measure the computation time of two queries averaged on 10000 runs: Q 6. is_high(kcal(orange), meanπ‘₯ kcal(π‘₯), stdπ‘₯ kcal(π‘₯)) which takes 2.58 ms to execute, Q 7. is_high(kcal(𝑦), meanπ‘₯ kcal(π‘₯), stdπ‘₯ kcal(π‘₯)) which takes 3.57ms to execute. Q 6 returns a single result for orange, whereas Q 7 returns results for each ingredient, that is 797 results. One could expect Q 7 to be approximately 797 slower than Q 6 if LTN would need to recompute the terms meanπ‘₯ kcal(π‘₯) and stdπ‘₯ kcal(π‘₯) as many times. Instead, we find that Q 6 is executed in 2.58ms and Q 7 is executed in 3.57ms. Using Tensorflow built-in optimization, LTN can efficiently re-use common parts of the computational graph for optimal complexity. 8 https://www.tensorflow.org/