This library defines the semiring abstraction used throughout SWAL and provides all concrete implementations.
Algebra.Semiring defines Algebra.Semiring.T, the module type every semiring must satisfy. It bundles the carrier type, the semiring operations (โ and โ) with their identities, and the SMT sub-module that lifts those operations into Smtml expressions. Every functor in the Encoding and Learner libraries is parameterized over a value of type (module Algebra.Semiring.T).
Algebra.Bool โ Boolean semiring ({false, true}, โจ, โง). Used by the residual NFA benchmarks. Encoded in QF_BV.Algebra.Nat โ Natural-number semiring (โ, +, ร), optionally bounded. Nat.get (Some b) returns the bounded variant {0,โฆ,b}. Encoded in QF_NIA.Algebra.Rat โ Rational-number semiring (โ, +, ร). Represented as integer (numerator, denominator) pairs in SMT. Encoded in QF_NIA.Algebra.Prob โ Probabilistic semiring (0,1โฉโ, min(ยท+ยท,1), ร). Like Algebra.Rat but with domain constraint num โค den. Encoded in QF_NIA.Algebra.Bottleneck โ Bottleneck semiring ({-โ}โชโคโช{+โ}, max, min). Uses integer sentinel encoding. Encoded in QF_LIA.Algebra.Tropical_lia โ Tropical semiring ({โ}โชโ, min, +), bounded or unbounded, encoded in QF_LIA.Algebra.Tropical_bv โ Bounded tropical semiring, encoded as bitvectors in QF_BV for faster solving.Algebra.Matrix โ Dense matrix algebra parameterized over any semiring. Used internally by Automata.WFA and Learner.Angluin.Implement Algebra.Semiring.T (in particular its SMT sub-module) and add a get function following the pattern of Algebra.Nat or Algebra.Tropical_lia. Register the new semiring in Lang.Lang by adding a variant to Lang.t and a case in Lang.get.