Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Language.Hasmtlib.Counting
Description
This module provides functions for counting symbolic formulas and creating cardinality-constraints.
Internally this converts each given Expr
BoolSort
into a numerical Expr
using ite
, then sums them up:
count :: forall t f. (Functor f, Foldable f, Num (Expr t)) => f (Expr BoolSort) -> Expr t count = sum . fmap (\b -> ite b 1 0)
Therefore additional information for the temporal summation may need to be provided.
E.g. if your logic is "QF_LIA" you would want count'
@IntSort
$ ...
It is worth noting that some cardinality constraints use optimized encodings, such as
.atLeast
1 ≡ or
Synopsis
- count :: forall t f. (Functor f, Foldable f, Num (Expr t)) => f (Expr BoolSort) -> Expr t
- count' :: forall t f. (Functor f, Foldable f, Num (Expr t)) => Proxy t -> f (Expr BoolSort) -> Expr t
- atLeast :: forall t f. (Functor f, Foldable f, KnownSMTSort t, Num (HaskellType t), Ord (HaskellType t)) => Expr t -> f (Expr BoolSort) -> Expr BoolSort
- exactly :: forall t f. (Functor f, Foldable f, KnownSMTSort t, Num (HaskellType t), Ord (HaskellType t)) => Expr t -> f (Expr BoolSort) -> Expr BoolSort
- atMost :: forall t f. (Functor f, Foldable f, KnownSMTSort t, Num (HaskellType t), Ord (HaskellType t)) => Expr t -> f (Expr BoolSort) -> Expr BoolSort
Count
count :: forall t f. (Functor f, Foldable f, Num (Expr t)) => f (Expr BoolSort) -> Expr t Source #
Out of many bool-expressions build a formula which encodes how many of them are true
.
count' :: forall t f. (Functor f, Foldable f, Num (Expr t)) => Proxy t -> f (Expr BoolSort) -> Expr t Source #
At-Least
atLeast :: forall t f. (Functor f, Foldable f, KnownSMTSort t, Num (HaskellType t), Ord (HaskellType t)) => Expr t -> f (Expr BoolSort) -> Expr BoolSort Source #
Out of many bool-expressions build a formula which encodes that at least k
of them are true
.
Exactly
exactly :: forall t f. (Functor f, Foldable f, KnownSMTSort t, Num (HaskellType t), Ord (HaskellType t)) => Expr t -> f (Expr BoolSort) -> Expr BoolSort Source #
Out of many bool-expressions build a formula which encodes that exactly k
of them are true
.