what4-1.0: Solver-agnostic symbolic values support for issuing queries

Copyright(c) Galois Inc 2019-2020
LicenseBSD3
Maintainerrdockins@galois.com
Safe HaskellNone
LanguageHaskell2010

What4.SemiRing

Contents

Description

The algebraic assumptions we make about our semirings are that:

  • addition is commutative and associative, with a unit called zero,
  • multiplication is commutative and associative, with a unit called one,
  • one and zero are distinct values,
  • multiplication distributes through addition, and
  • multiplication by zero gives zero.

Note that we do not assume the existence of additive inverses (hence, semirings), but we do assume commutativity of multiplication.

Note, moreover, that bitvectors can be equipped with two different semirings (the usual arithmetic one and the XOR/AND boolean ring imposed by the boolean algebra structure), which occasionally requires some care.

In addition, some semirings are "ordered" semirings. These are equipped with a total ordering relation such that addition is both order-preserving and order-reflecting; that is, x <= y iff x + z <= y + z. Moreover ordered semirings satisfy: 0 <= x and 0 <= y implies 0 <= x*y.

Synopsis

Semiring datakinds

data SemiRing Source #

Data-kind representing the semirings What4 supports.

Instances
TestEquality OrderedSemiRingRepr Source # 
Instance details

Defined in What4.SemiRing

TestEquality SemiRingRepr Source # 
Instance details

Defined in What4.SemiRing

Methods

testEquality :: SemiRingRepr a -> SemiRingRepr b -> Maybe (a :~: b) #

OrdF OrderedSemiRingRepr Source # 
Instance details

Defined in What4.SemiRing

OrdF SemiRingRepr Source # 
Instance details

Defined in What4.SemiRing

HashableF OrderedSemiRingRepr Source # 
Instance details

Defined in What4.SemiRing

HashableF SemiRingRepr Source # 
Instance details

Defined in What4.SemiRing

OrdF f => TestEquality (SemiRingProduct f :: SemiRing -> Type) Source # 
Instance details

Defined in What4.Expr.WeightedSum

Methods

testEquality :: SemiRingProduct f a -> SemiRingProduct f b -> Maybe (a :~: b) #

OrdF f => TestEquality (WeightedSum f :: SemiRing -> Type) Source # 
Instance details

Defined in What4.Expr.WeightedSum

Methods

testEquality :: WeightedSum f a -> WeightedSum f b -> Maybe (a :~: b) #

type SemiRingNat Source #

Arguments

 = SemiRingNat
:: SemiRing

type SemiRingInteger Source #

Arguments

 = SemiRingInteger
:: SemiRing

type SemiRingReal Source #

Arguments

 = SemiRingReal
:: SemiRing

type SemiRingBV Source #

Arguments

 = SemiRingBV
:: BVFlavor -> Nat -> SemiRing

data BVFlavor Source #

Data-kind indicating the two flavors of bitvector semirings. The ordinary arithmetic semiring consists of addition and multiplication, and the "bits" semiring consists of bitwise xor and bitwise and.

Instances
TestEquality BVFlavorRepr Source # 
Instance details

Defined in What4.SemiRing

Methods

testEquality :: BVFlavorRepr a -> BVFlavorRepr b -> Maybe (a :~: b) #

OrdF BVFlavorRepr Source # 
Instance details

Defined in What4.SemiRing

HashableF BVFlavorRepr Source # 
Instance details

Defined in What4.SemiRing

type BVBits Source #

Arguments

 = BVBits
:: BVFlavor

type BVArith Source #

Arguments

 = BVArith
:: BVFlavor

Semiring representations

data BVFlavorRepr (fv :: BVFlavor) where Source #

Instances
TestEquality BVFlavorRepr Source # 
Instance details

Defined in What4.SemiRing

Methods

testEquality :: BVFlavorRepr a -> BVFlavorRepr b -> Maybe (a :~: b) #

OrdF BVFlavorRepr Source # 
Instance details

Defined in What4.SemiRing

HashableF BVFlavorRepr Source # 
Instance details

Defined in What4.SemiRing

Hashable (BVFlavorRepr fv) Source # 
Instance details

Defined in What4.SemiRing

Methods

hashWithSalt :: Int -> BVFlavorRepr fv -> Int #

hash :: BVFlavorRepr fv -> Int #

semiRingBase :: SemiRingRepr sr -> BaseTypeRepr (SemiRingBase sr) Source #

Compute the base type of the given semiring.

orderedSemiRing :: OrderedSemiRingRepr sr -> SemiRingRepr sr Source #

Compute the semiring corresponding to the given ordered semiring.

Semiring coefficients

type family Coefficient (sr :: SemiRing) :: Type where ... Source #

The constant values in the semiring.

Semiring product occurrences

type family Occurrence (sr :: SemiRing) :: Type where ... Source #

The Occurrence family counts how many times a term occurs in a product. For most semirings, this is just a natural number representing the exponent. For the boolean ring of bitvectors, however, it is unit because the lattice operations are idempotent.