Abstract
Weighted programs were recently introduced by Batz et al. (Proc. ACM Program. Lang. 2022) as a generalization of probabilistic programs which can also represent optimization problems and, in general, programs whose execution traces carry some sort of weight. Batz et al. show that a weighted version of Dijkstra’s weakest precondition operator can be used to reason about the competitive ratios of weighted programs. In this paper we study a propositional abstraction of weighted programs with three main contributions. First, we formulate a semantics for weighted programs with the weighted weakest precondition operator based on functions from multimonoids to quantales. Second, we show that the weighted weakest precondition operator corresponds to a generalization of the domain operator known from Kleene algebra with domain, and we study the properties of the generalized domain operator. Third, we formulate a weighted version of Kleene algebra with domain as a framework for reasoning about weighted programs with weakest precondition in an abstract setting.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
If \((S, +, 0)\) is a complete idempotent commutative monoid, then it is a complete join-semilattice. Every complete join-semilattice gives rise to a complete lattice. Note that \(0 = \bigvee \emptyset \).
- 2.
There is w such that Rxyw and Rwzv iff there is u such that Ryzu and Rxuv.
- 3.
In particular, the KAT has to satisfy the properties that result from the ones in Proposition 1 by replacing f, g with arbitrary elements of the KAT and h with an arbitrary element of the Boolean algebra of tests.
- 4.
E.g. \(\textsf{d}(p)p = p\) is a natural candidate for a “definition” of crisp elements but it does not seem to be adequate.
- 5.
These would in fact require \(\,^{-}\) to be defined on Q as well.
- 6.
In addition, weighted predicates are represented by a semiring, not a quantale.
- 7.
In these residuated lattices, also known as \(\mathsf {FL_{ew}}\)-algebras, multiplication is commutative and the multiplicative identity is the top element; see [8].
References
Apt, K.R., de Boer, F.S., Olderog, E.R.: Verification of Sequential and Concurrent Programs, 3rd edn. Texts in Computer Science, Springer (2009)
Batz, K., Gallus, A., Kaminski, B.L., Katoen, J.P., Winkler, T.: Weighted programming: a programming paradigm for specifying mathematical models. Proc. ACM Program. Lang. 6(OOPSLA1), 1–30 (2022). https://doi.org/10.1145/3527310
Desharnais, J., Möller, B., Struth, G.: Kleene algebra with domain. ACM Trans. Comput. Logic 7(4), 798–833 (2006). https://doi.org/10.1145/1183278.1183285
Desharnais, J., Struth, G.: Internal axioms for domain semirings. Sci. Comput. Program. 76(3), 181–203 (2011). https://doi.org/10.1016/j.scico.2010.05.007
Dijkstra, E.W.: Guarded commands, nondeterminacy and formal derivation of programs. Commun. ACM 18(8), 453–457 (1975). https://doi.org/10.1145/360933.360975
Fahrenberg, U., Johansen, C., Struth, G., Ziemiański, K.: Catoids and modal convolution algebras. Algebra Univ. 84(2), 2023. https://doi.org/10.1007/s00012-023-00805-9
Fischer, M.J., Ladner, R.E.: Propositional dynamic logic of regular programs. J. Comput. Syst. Sci. 18, 194–211 (1979). https://doi.org/10.1016/0022-0000(79)90046-1
Galatos, N., Jipsen, P., Kowalski, T., Ono, H.: Residuated Lattices: An Algebraic Glimpse at Substructural Logics. Elsevier (2007)
Gomes, L., Madeira, A., Barbosa, L.S.: On Kleene algebras for weighted computation. In: Cavalheiro, S., Fiadeiro, J. (eds.) Formal Methods: Foundations and Applications, pp. 271–286. Springer International Publishing, Cham (2017). https://doi.org/10.1007/978-3-319-70848-5_17
Gomes, L., Madeira, A., Barbosa, L.S.: Generalising KAT to verify weighted computations. Sci. Ann. Comput. Sci. 29(2), 141–184 (2019). https://doi.org/10.7561/SACS.2019.2.141
Groenendijk, J., Stokhof, M.: Dynamic predicate logic. Linguist. Philos. 14(1), 39–100 (1991). https://doi.org/10.1007/BF00628304
Hoare, C.A.R.: An axiomatic basis for computer programming. Commun. ACM 12, 576–580 (1969). https://doi.org/10.1145/363235.363259
Kozen, D.: On Kleene algebras and closed semirings. In: Rovan, B. (ed.) International Symposium on Mathematical Foundations of Computer Science, pp. 26–47. Springer (1990). https://doi.org/10.1007/BFb0029594
Kozen, D.: A completeness theorem for Kleene algebras and the algebra of regular events. Inf. Comput. 110(2), 366–390 (1994). https://doi.org/10.1006/inco.1994.1037
Kozen, D.: Kleene algebra with tests. ACM Trans. Program. Lang. Syst. 19(3), 427–443 (1997). https://doi.org/10.1145/256167.256195
Kozen, D., Smith, F.: Kleene algebra with tests: completeness and decidability. In: Dalen, D., Bezem, M. (eds.) Computer Science Logic, pp. 244–259. Springer Berlin Heidelberg, Berlin, Heidelberg (1997). https://doi.org/10.1007/3-540-63172-0_43
Kudryavtseva, G., Mazorchuk, V.: On multisemigroups. Portugaliae. Mathematica 72(1), 47–80 (2015). https://doi.org/10.4171/pm/1956
Paseka, J., Rosický, J.: Quantales. In: Coecke, B., Moore, D., Wilce, A. (eds.) Current Research in Operational Quantum Logic: Algebras, Categories, Languages, pp. 245–262. Springer Netherlands, Dordrecht (2000). https://doi.org/10.1007/978-94-017-1201-9_10
Restall, G.: An Introduction to Substrucutral Logics. Routledge, London (2000)
Rosenthal, K.I.: Quantales and Their Applications. Longman Scientific & Technical, (1990)
Routley, R., Plumwood, V., Meyer, R.K., Brady, R.T.: Relevant Logics and Their Rivals, vol. 1. Ridgeview (1982)
Różowski, W., Silva, A.: A Completeness Theorem for Probabilistic Regular Expressions. Technical report (2023). https://doi.org/10.48550/ARXIV.2310.08779
Różowski, W., Kappé, T., Kozen, D., Schmid, T., Silva, A.: Probabilistic Guarded KAT modulo bisimilarity: Completeness and complexity. In: Etessami, K., Feige, U. and Puppis, G. (eds.) Proc. 50th International Colloquium on Automata, Languages, and Programming (ICALP 2023), pp. 136:1–136:20. No. 261 in Leibniz International Proceedings in Informatics (LIPIcs), Schloss Dagstuhl - Leibniz-Zentrum für Informatik, Dagstuhl, Germany (2023). https://doi.org/10.4230/LIPIcs.ICALP.2023.136
Sedlár, I.: Kleene algebra with tests for weighted programs. In: Proceedings of the IEEE 53rd International Symposium on Multiple-Valued Logic (ISMVL 2023), pp. 111–116 (2023). https://doi.org/10.1109/ISMVL57333.2023.00031
Sedlár, I.: On the complexity of Kleene algebra with domain. In: Gl ück, R., Santocanale, L., Winter, M. (eds.) Relational and Algebraic Methods in Computer Science (RAMiCS 2023). LNCS, vol. 13896, pp. 208–223. Springer, Cham (2023). https://doi.org/10.1007/978-3-031-28083-2_13
Smolka, S., Foster, N., Hsu, J., Kappé, T., Kozen, D., Silva, A.: Guarded Kleene algebra with tests: Verification of uninterpreted programs in nearly linear time. In: Proceedings 47th ACM SIGPLAN Symp. Principles of Programming Languages (POPL’20), pp. 61:1–28. ACM, New Orleans (2020). https://doi.org/10.1145/3371129
Acknowledgement
This work was supported by the grant 22-16111S of the Czech Science Foundation.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
A Technical appendix
A Technical appendix
1.1 A.1 Identities in multimonoids
Lemma 2
Let M be a multimonoid. For all \(x,y \in M\) and \(i, j \in I\):
Proof
The proof is based on some of the arguments in [6]. (1.) This holds since \(\{ x \} \otimes I = \{ x \} = I \otimes \{ x \}\) by definition. (2.) If \(x \in i \otimes j\), then \(x = i\) and \(x = j\) by the previous item. (3.) By definition, \(i \otimes I = \{ i \}\); hence there is \(j \in I\) such that \(i \in i \otimes j\). By the previous item, \(i \in i \otimes i\). If \(x \in i \otimes i\), then \(x = i\) by the first item. (4.) If the assumption holds, then \(\emptyset \ne i \otimes x = i \otimes (j \otimes x) = (i \otimes j) \otimes x\). It follows that \(y \in i \otimes j\) for some y, and so \(i = j\) by the second item. (5.) is similar. \(\square \)
1.2 A.2 Proof of Proposition 1
Before we give the proof, we state a useful lemma of [6] (the following is an excerpt of their Lemmas 3.1 and 3.3). In the lemma, we use the set lifting of \(\textsf{s}\) defined in the obvious way: for \(X \subseteq M\), \(\textsf{s}(X) = \{ \textsf{s}(x) \mid x \in X \}\). We also write xy instead of \(x \otimes y\).
Lemma 3
The following holds for each multimonoid M: 1. \(\textsf{s}(x) \textsf{s}(x) = \textsf{s}(x)\); 2. \(\textsf{s}(\textsf{s}(x) y) = \textsf{s}(x) \textsf{s}(y)\); 3. \(\textsf{s}(xy) \subseteq \textsf{s}(x \textsf{s}(y))\). If M is local, then 4. \(\textsf{s}(x \textsf{s}(y)) \subseteq \textsf{s}(xy)\).
Now we turn to the proof of Proposition 1.
Proof
(1.) If \(h \in Di(Q^{M})\), then \(\textsf{d}(h) = h\). Note that \( \textsf{d}(h)(x) = \bigvee _{x = \textsf{s}(y)} h(y) = \bigvee _{x = \textsf{s}(y) \& y \in I} h(y)\) (the last equality holds since \(h \in Di(Q^{M})\)). However, \(\textsf{s}(y) = y\) by Lemma 2(1), and so \( \bigvee _{x = \textsf{s}(y) \& y \in I} h(y) = h(x)\).
(2.) \(\textsf{d}(f \cdot g) \le \textsf{d}(f \cdot \textsf{d}(g))\). We reason as follows:
We note that (5.) is established in a similar fashion using Lemma 3(3).
(3.) \(\textsf{d}(\textsf{d}(f) \cdot g) = \textsf{d}(f) \cdot \textsf{d}(g)\). We reason as follows:
(4.) \(\textsf{d}\left( \bigvee _{i \in I} f_i \right) = \left( \bigvee _{i \in I} \textsf{d}(f_i) \right) \). This is established as follows:
\(\square \)
1.3 A.3 Proof of Proposition 2
Proof
(1.) \(\textsf{d}(f) \le 1\) is not valid: it is sufficient to consider a non-integral Q (1 is not the top element). (2.) \(\textsf{d}(f) \cdot f = f\) is not valid: consider the pair multimonoid \(\{ w \} \times \{ w \}\) and the non-idempotent product quantale \( \varPi \) where \(f(w,w) = 0.5\). \(\square \)
1.4 A.4 Proof of Proposition 3
Proof
We reason as follows:
The first two equalities hold by definition. The third equality holds since g is diagonal. The fourth equality is established as follows: \(y \in y \otimes \textsf{t}(y)\), and so the right hand side is less or equal than the left hand side; conversely, if \( y \in u \otimes v \& v \in I\), then \(y = u\) by Lemma 2(1) and \(v = \textsf{t}(y)\) since \(\textsf{t}(y)\) is the unique right identity of y by definition. Hence, the left hand side is less or equal than the right hand side. \(\square \)
Rights and permissions
Copyright information
© 2024 The Author(s), under exclusive license to Springer Nature Switzerland AG
About this paper
Cite this paper
Sedlár, I. (2024). Kleene Algebra of Weighted Programs with Domain. In: Gierasimczuk, N., Velázquez-Quesada, F.R. (eds) Dynamic Logic. New Trends and Applications. DaLí 2023. Lecture Notes in Computer Science, vol 14401. Springer, Cham. https://doi.org/10.1007/978-3-031-51777-8_4
Download citation
DOI: https://doi.org/10.1007/978-3-031-51777-8_4
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-031-51776-1
Online ISBN: 978-3-031-51777-8
eBook Packages: Computer ScienceComputer Science (R0)