Skip to main content

Kleene Algebra of Weighted Programs with Domain

  • Conference paper
  • First Online:
Dynamic Logic. New Trends and Applications (DaLí 2023)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 14401))

Included in the following conference series:

  • 113 Accesses

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 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. 2.

    There is w such that Rxyw and Rwzv iff there is u such that Ryzu and Rxuv.

  3. 3.

    In particular, the KAT has to satisfy the properties that result from the ones in Proposition 1 by replacing fg with arbitrary elements of the KAT and h with an arbitrary element of the Boolean algebra of tests.

  4. 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. 5.

    These would in fact require \(\,^{-}\) to be defined on Q as well.

  6. 6.

    In addition, weighted predicates are represented by a semiring, not a quantale.

  7. 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

  1. Apt, K.R., de Boer, F.S., Olderog, E.R.: Verification of Sequential and Concurrent Programs, 3rd edn. Texts in Computer Science, Springer (2009)

    Book  Google Scholar 

  2. 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

  3. 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

    Article  MathSciNet  Google Scholar 

  4. 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

    Article  MathSciNet  Google Scholar 

  5. 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

    Article  MathSciNet  Google Scholar 

  6. 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

  7. 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

    Article  MathSciNet  Google Scholar 

  8. Galatos, N., Jipsen, P., Kowalski, T., Ono, H.: Residuated Lattices: An Algebraic Glimpse at Substructural Logics. Elsevier (2007)

    Google Scholar 

  9. 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

    Chapter  Google Scholar 

  10. 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

    Article  MathSciNet  Google Scholar 

  11. Groenendijk, J., Stokhof, M.: Dynamic predicate logic. Linguist. Philos. 14(1), 39–100 (1991). https://doi.org/10.1007/BF00628304

    Article  Google Scholar 

  12. Hoare, C.A.R.: An axiomatic basis for computer programming. Commun. ACM 12, 576–580 (1969). https://doi.org/10.1145/363235.363259

    Article  Google Scholar 

  13. 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

  14. 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

    Article  MathSciNet  Google Scholar 

  15. Kozen, D.: Kleene algebra with tests. ACM Trans. Program. Lang. Syst. 19(3), 427–443 (1997). https://doi.org/10.1145/256167.256195

    Article  Google Scholar 

  16. 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

    Chapter  Google Scholar 

  17. Kudryavtseva, G., Mazorchuk, V.: On multisemigroups. Portugaliae. Mathematica 72(1), 47–80 (2015). https://doi.org/10.4171/pm/1956

    Article  MathSciNet  Google Scholar 

  18. 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

    Chapter  Google Scholar 

  19. Restall, G.: An Introduction to Substrucutral Logics. Routledge, London (2000)

    Google Scholar 

  20. Rosenthal, K.I.: Quantales and Their Applications. Longman Scientific & Technical, (1990)

    Google Scholar 

  21. Routley, R., Plumwood, V., Meyer, R.K., Brady, R.T.: Relevant Logics and Their Rivals, vol. 1. Ridgeview (1982)

    Google Scholar 

  22. Różowski, W., Silva, A.: A Completeness Theorem for Probabilistic Regular Expressions. Technical report (2023). https://doi.org/10.48550/ARXIV.2310.08779

  23. 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

  24. 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

  25. 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

  26. 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

Download references

Acknowledgement

This work was supported by the grant 22-16111S of the Czech Science Foundation.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Igor Sedlár .

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\):

figure l

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:

$$\begin{aligned} \textsf{d}(f \cdot \textsf{d}(g))(x) & = \bigvee _{x = \textsf{s}(y)} \bigvee _{y \in z \otimes u} \left( f(z) \cdot \textsf{d}(g)(u) \right) \quad = \bigvee _{x \in \textsf{s}(z \otimes u)} \left( f(z) \cdot \bigvee _{u = \textsf{s}(v)} g(v) \right) \\ & = \bigvee _{x \in \textsf{s}(z \otimes \textsf{s}(v))} \left( f(z) \cdot g(v) \right) \quad \overset{\text {Lemma 3(3)}}{\ge } \bigvee _{x \in \textsf{s}(z \otimes v)} \left( f(z) \cdot g(v) \right) \quad \\ & = \textsf{d}(f \cdot g)(x) \end{aligned}$$

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:

$$ \begin{aligned} \textsf{d}(\textsf{d}(f) \cdot g)(x) & = \bigvee _{x \in \textsf{s}(y \otimes z)} \left( \textsf{d}(f)(y) \cdot g(z) \right) \quad = \bigvee _{x \in \textsf{s}(y \otimes z) \& y \in I} \left( \textsf{d}(f)(y) \cdot g(z) \right) \\ & \overset{\text {Lemma 2(1)}}{=} \bigvee _{x \in \textsf{s}(\textsf{s}(x) \otimes z)} \left( \textsf{d}(f)(x) \cdot g(z) \right) \\ & \overset{\text {Lemma 3(1, 2)}}{=} \left( \textsf{d}(f)(x) \cdot \bigvee _{x = \textsf{s}(z)} g(z) \right) \quad = \, \textsf{d}(f)(x) \cdot \textsf{d}(g)(x)\\ & \overset{\text {Lemma 2(1--3)}}{=} \left( \textsf{d}(f) \cdot \textsf{d}(g)\right) (x) \end{aligned}$$

(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:

$$\begin{aligned} \textsf{d}\left( \bigvee _{i \in I} f_i \right) (x) & = \bigvee _{x = \textsf{s}(y)} \left( \bigvee _{i \in I} f_i \right) (y) \quad = \quad \bigvee _{x = \textsf{s}(y)} \left( \bigvee _{i \in I} f_i(y) \right) \\ & \quad \bigvee _{i \in I} \left( \bigvee _{x = \textsf{s}(y)} f_i(y) \right) \quad = \quad \bigvee _{i \in I} \left( \textsf{d}(f_i)(x) \right) \quad = \quad \left( \bigvee _{i \in I}\textsf{d}(f_i) \right) (x) \end{aligned}$$

   \(\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:

$$ \begin{aligned} \textsf{d}(f \cdot g)(x) & = \bigvee _{x = \textsf{s}(y)} \left( (f \cdot g)(y) \right) \quad = \quad \bigvee _{x = \textsf{s}(y)} \left( \bigvee _{y \in u \otimes v} \left( f(u) \cdot g(v) \right) \right) \\ & = \bigvee _{x = \textsf{s}(y)} \left( \bigvee _{y \in u \otimes v \& v \in I} \left( f(u) \cdot g(v)\right) \right) \quad = \quad \bigvee _{x = \textsf{s}(y)} \left( f(y) \cdot g(\textsf{t}(y)) \right) \end{aligned}$$

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

Reprints and permissions

Copyright information

© 2024 The Author(s), under exclusive license to Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

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)

Publish with us

Policies and ethics