Manuscript Offprint
arXiv:2610.34327Vector space embeddings of modal logic formulas: theory and application
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Pietro Casavecchia [0009-0000-9117-234X], Alberto Paparella [0009-0007-1653-3660], and Leonardo Serrentino [0009-0004-9884-0194]
University of Ferrara, Ferrara, Italy
{pietro.casavecchia, alberto.paparella, leonardo.serrentino}@unife.it
Abstract. Reasoning tasks over modal logics are notoriously difficult, comprising problems which are often semi-decidable. Hence, it is not rare for applications leveraging such tasks to exploit heuristic approaches able to give results in an acceptable amount of time, at the cost of some inaccuracies. Some approaches may benefit from vector embeddings, allowing for instance to involve neural networks and machine learning models in the reasoning process. This work aims at providing a new way to provide such embeddings specifically for the modal case, aiming for faster reasoning through both mathematical and learning techniques.
Keywords: Modal logic · Vector embeddings · Automated reasoning.
1 Introduction
Vector space embeddings of logic formulas aim to represent symbolic logic as vectors. This enables, for example, neural networks and machine learning models to perform reasoning over logic-based representations [9]. Such embeddings can be given [8] or learned from data [6,12]. More recently, embeddings have also been leveraged for neurosymbolic tasks [5,10,1]. However, there seems to be no literature about embeddings of modal logics. Therefore, a formal framework for vector space embeddings of modal formulas would be of great value, providing an essential tool for faster reasoning.
This work describes a novel approach to embed modal logic formulas over a vector space, with the key idea of interpreting a set of representative modal logic models as dimensions and hence providing a binary encoding of formulas based on the models that satisfy them. This shares some ideas with [2], however following different goals: while the latter aims at describing the semantic meaning of propositions, this work focuses on finding a set of non-equivalent representative models that describes the entire universe of all possible Kripke structures. Furthermore, some examples of both theoretical and applicative interest are described, solving classical problems in a heuristic way somewhat similar
Presented at the Student Session of the 36th European Summer School in Logic, Language and Information (ESSLLI 2025), Bochum, 28 July to 8 August 2025. An extended version appeared as Semantic Embeddings for Modal Logic (Extended Abstract), Proceedings of ICTCS 2026, CEUR-WS Vol-4269, pp. 30–35.
P. Casavecchia et al.

Fig. 1. On the left: example of a semantic entailment in a 3-dimensional vector space; is the projection of on the (hyper)-plane formed by the models satisfying . On the right: abstract representation of a high-dimensional vector space; formulas in the gray region are considered similar to .
to [3,4,7,11]. Finally, we provide an open-source implementation, also describing how one can get more insightful embeddings.
where is the set of worlds in , is an accessibility relation between worlds, and is a valuation function assigning a truth value to each propositional letter in each world. A vector space embedding for formulas in is defined through a satisfaction matrix of dimensions , where each element is given by:
The matrix summarizes the satisfaction of every formula in in every Kripke structure in . Note that , where is the complete matrix of every possible formula evaluated on every possible Kripke model. Such an embedding can be interpreted as a vector space comprised by Kripke models (the columns of ) as axes where formulas (the rows of ) are represented by binary vectors, i.e., where each coordinate is either 0 or 1. To assess how reliably the embedding captures the core logical properties of each formula, one could leverage a modal reasoner providing a ground-truth classification by exploring a broad
Vector space embeddings of modal logic formulas
3
set of formulas and checking their validity, unsatisfiability, or satisfiability: the embedding should approximate this classification by mapping the truth values of each formula across M into a row of S, with a row comprising only ones (resp. zeros) suggesting validity (resp. unsatisfiability), while a row comprising at least a one should always correspond to satisfiability.
Given a vector space embedding as described in eq. 1, one can be interested in a notion of “similarity” between formulas: since there seems to be no shared definition of similarity, this work proposes to consider a notion of similarity based on the number of models the formulas share. A figurative example is represented in Figure 1, on the right. Such a notion can be grasped by common similarity metrics between vectors, e.g., the rather popular cosine similarity and its variants. In particular, we employ a similarity measure between two formulas and defined as follows:
where represents the number of Kripke structures satisfying formula ; in fact, represents the -th row of matrix , while represents its 1-norm (also called Manhattan distance).
Given a vector space embedding as described in eq. 1 and a notion of similarity such as the one in eq. 2, one could easily solve, for example, the problem of stating if a formula entails another, i.e., where . In fact:
An example is given in Figure 1, on the left. One should notice that this is still a heuristic: there could be a model . Hence, the choice of and is crucial to get reliable results, and will be discussed in the next section.
Another application of interest could be solving the minimization problem, which can be defined as follows: given a formula , find the formula which satisfies exactly the same models (i.e., ) and has the least number of symbols. One possible way to solve this problem is considering all formulas:
and taking the one with the least number of symbols. This could be taken even a step further if someone is interested in getting a least number of symbols even at the cost of the formulas disagreeing on some models. Should this be the case, one could consider a relaxation of the problem, referred to as quasi-minimization, setting a similarity threshold , and considering all formulas and taking the one with the least number of symbols.
P. Casavecchia et al.
Algorithm 1 GENERATE EMBEDDING
Require: m: target dimension, depth: maximum formula depth, W: maximum number of worlds
Ensure: S: embedding matrix, F: list of formulas, M: list of models
1: Initialize F with 3 randomly generated modal formulas of depth ≤ depth
2: Initialize M with 3 Kripke models, each with at most W worlds
3: Construct initial matrix S by evaluating each formula in F on each model in M
4: for i = 3 to m - 1 do
5: Generate a new modal formula with depth ≤ depth
6: Generate a new Kripke model with at most W worlds
7: Append to F, and to M
8: Expand S to size
9: Evaluate on all existing models in M and insert as new row
10: Evaluate all existing formulas in F on and insert as new column
11: Evaluate on and insert at the new diagonal cell
12: Optimize S, F, and M using ITERATIVE OPTIMIZATION
13: end for
14: return S, F, M
3 Implementation
The implementation follows an iterative approach to construct the satisfaction matrix S identifying a representative subset of Kripke structures M aiming to approximate the diversity of the space of all possible Kripke structures while maintaining computational feasibility. The process (Alg. 1) begins with a small set of formulas and Kripke models, forming an initial satisfaction matrix S. Then, S is expanded by iteratively introducing new formulas and models variations (Alg. 2) within the universe of all Kripke models while maintaining meaningful embeddings ensuring that no two columns in S are identical, removing redundancies and enforcing structural differentiation among the selected Kripke models. Whenever a duplication is detected, either new models or formulas are generated to increase the expressiveness of S. The process continues until a further expansion does not significantly alter the structural diversity of the embedding, indicating that M has reached a sufficient approximation of the broader Kripke space, capturing key structural variations necessary for logical reasoning, or when other termination criteria (e.g., a timeout) are reached.
Once the optimization is complete, the final satisfaction matrix provides a vector space embedding of modal logic formulas, where each formula's position is determined by its truth values across the most representative Kripke structures in M. This embedding can then be leveraged for reasoning tasks or integration with machine learning models, facilitating a more efficient and scalable approach to modal logic computations.
The implementation is open-source and is made available through the following repository: https://github.com/aclai-lab/ESSLLI2025.
Vector space embeddings of modal logic formulas
5
Algorithm 2 ITERATIVE OPTIMIZATION
Require: S: truth matrix , F: set of n formulas, M: list of m models, depth: formula depth, W: maximum number of worlds
Ensure: S has only unique columns; return updated F, M
1: while some columns of S are identical do
2: for each model index j do
3: Generate a new Kripke model with at most W worlds
4: Evaluate all formulas in F on to get a new column
5: if is not already present in S then
6: Replace column j in S with
7: Update model M[j] with
8: break to re-check uniqueness of S
9: end if
10: end for
11: if no unique model was found for any column then
12: for each formula index i do
13: Generate a new formula of depth depth
14: end for
15: for each model index j do
16: Recompute column j of S using the new formulas and model M[j]
17: end for
18: end if
19: end while
20: return S, F, M
4 Conclusions and future works
In this work, a possible embedding of modal logic formulas has been proposed aiming to solve classical problems, such as minimization and entailment, in a fast way. One should notice how considering only binary encodings is rather constraining, resulting in much sparsity in the vector space. Hence, a natural next step would be generalizing this approach to modal fuzzy logics.
Disclosure of Interests. The authors have no competing interests to declare that are relevant to the content of this article.
References
-
Badreddine, S., d'Avila Garcez, A., Serafini, L., Spranger, M.: Logic tensor networks. Artificial Intelligence 303, 103649 (Feb 2022). https://doi.org/10.1016/j.artint.2021.103649
-
van Benthem, J., Bezhanishvili, N.: Modal structures in groups and vector spaces. Journal of Logic and Computation 34(1), 75–124 (Feb 2023). https://doi.org/10.1093/logcom/exac105
-
Bresolin, D., Jiménez, F., Sánchez, G., Sciavicco, G.: Finite satisfiability of propositional interval logic formulas with multi-objective evolutionary algorithms. In: Proceedings of the Twelfth Workshop on Foundations of Genetic Algorithms XII.
P. Casavecchia et al.
p. 25–36. FOGA XII '13, Association for Computing Machinery, New York, NY, USA (2013). https://doi.org/10.1145/2460239.2460243
-
Harmeling, S.: Solving satisfiability problems with genetic algorithms. In: Genetic Algorithms and Genetic Programming at Stanford 2000: Book of Student Papers from John Koza's Course at Stanford on Genetic Algorithms and Genetic Programming, pp. 206–213. Stanford Bookstore (2000)
-
Ren, H., Leskovec, J.: Beta embeddings for multi-hop logical reasoning in knowledge graphs. In: Larochelle, H., Ranzato, M., Hadsell, R., Balcan, M., Lin, H. (eds.) Advances in Neural Information Processing Systems. vol. 33, pp. 19716–19726. Curran Associates, Inc. (2020), https://proceedings.neurips.cc/paper_files/paper/2020/file/e43739bba7cdb577e9e3e4e42447f5a5-Paper.pdf
-
Rocktäschel, T., Bosnjak, M., Singh, S., Riedel, S.: Low-dimensional embeddings of logic. In: Artzi, Y., Kwiatkowski, T., Berant, J. (eds.) Proceedings of the ACL 2014 Workshop on Semantic Parsing. pp. 45–49. Association for Computational Linguistics, Baltimore, MD (Jun 2014). https://doi.org/10.3115/v1/W14-2409
-
Rossi, C., Marchiori, E., Kok, J.N.: An adaptive evolutionary algorithm for the satisfiability problem. In: Proceedings of the 2000 ACM symposium on Applied computing-Volume 1. pp. 463–469 (2000)
-
Sato, T.: Embedding tarskian semantics in vector spaces. In: The Workshops of the The Thirty-First AAAI Conference on Artificial Intelligence, Saturday, February 4-9, 2017, San Francisco, California, USA. AAAI Technical Report, vol. WS-17. AAAI Press (2017), https://aaai.org/ocs/index.php/WS/AAAIW17/paper/view/15072
-
Smolensky, P.: Tensor product variable binding and the representation of symbolic structures in connectionist systems. Artificial Intelligence 46(1), 159–216 (1990). https://doi.org/10.1016/0004-3702(90)90007-M
-
Tang, X., Zhu, S.C., Liang, Y., Zhang, M.: RulE: Knowledge graph reasoning with rule embedding. In: Ku, L.W., Martins, A., Srikumar, V. (eds.) Findings of the Association for Computational Linguistics: ACL 2024. pp. 4316–4335. Association for Computational Linguistics, Bangkok, Thailand (Aug 2024). https://doi.org/10.18653/v1/2024.findings-acl.256
-
Venhuizen, N.J., Hendriks, P., Crocker, M.W., Brouwer, H.: Distributional formal semantics. Information and Computation 287, 104763 (2022). https://doi.org/10.1016/j.ic.2021.104763, special Issue: Selected Papers from WoLLIC 2019, the 26th Workshop on Logic, Language, Information and Computation
-
Wang, W.Y., Cohen, W.W.: Learning first-order logic embeddings via matrix factorization. In: International Joint Conference on Artificial Intelligence (2016), https://api.semanticscholar.org/CorpusID:12071886