Copyright | (C) 2017-18 Jakub Daniel |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Jakub Daniel <jakub.daniel@protonmail.com> |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Usage:
You can build expressions in predefined languages (QFLogic
, QFLia
,
QFALia
, Lia
, ALia
) using the smart constructors such as var
, and
,
or
, not
, forall
, exists
(or operators .&.
, .|.
, .->.
, .<-.
,
.<->.
) or you can define your own sorted language as a fixpoint (IFix
)
of a sum (:+:
) of indexed functors (IFunctor
).
- module Data.Expression.Arithmetic
- module Data.Expression.Array
- module Data.Expression.Equality
- module Data.Expression.IfThenElse
- module Data.Expression.Parser
- module Data.Expression.Sort
- module Data.Expression.Utils.Indexed.Eq
- module Data.Expression.Utils.Indexed.Foldable
- module Data.Expression.Utils.Indexed.Functor
- module Data.Expression.Utils.Indexed.Show
- module Data.Expression.Utils.Indexed.Sum
- module Data.Expression.Utils.Indexed.Traversable
- type QFLogicF = EqualityF :+: (ConjunctionF :+: (DisjunctionF :+: (NegationF :+: VarF)))
- type QFLiaF = ArithmeticF :+: (IfThenElseF :+: QFLogicF)
- type LiaF = ExistentialF BooleanSort :+: (ExistentialF IntegralSort :+: (UniversalF BooleanSort :+: (UniversalF IntegralSort :+: QFLiaF)))
- type QFALiaF = ArrayF :+: QFLiaF
- type ALiaF = ExistentialF BooleanSort :+: (ExistentialF IntegralSort :+: (UniversalF BooleanSort :+: (UniversalF IntegralSort :+: QFALiaF)))
- type Var = IFix VarF
- type QFLogic = IFix QFLogicF
- type QFLia = IFix QFLiaF
- type Lia = IFix LiaF
- type QFALia = IFix QFALiaF
- type ALia = IFix ALiaF
- class BoundedLattice a => ComplementedLattice a where
- type VariableName = String
- data VarF a s where
- Var :: VariableName -> Sing s -> VarF a s
- data ConjunctionF a s where
- And :: [a BooleanSort] -> ConjunctionF a BooleanSort
- data DisjunctionF a s where
- Or :: [a BooleanSort] -> DisjunctionF a BooleanSort
- data NegationF a s where
- Not :: a BooleanSort -> NegationF a BooleanSort
- data UniversalF v a s where
- Forall :: [Var v] -> a BooleanSort -> UniversalF v a BooleanSort
- data ExistentialF v a s where
- Exists :: [Var v] -> a BooleanSort -> ExistentialF v a BooleanSort
- newtype Substitution f = Substitution {
- runSubstitution :: forall s. IFix f s -> Maybe (IFix f s)
- substitute :: (IFunctor f, IEq1 f) => IFix f s -> Substitution f -> IFix f s
- for :: forall f s. (IFunctor f, IEq1 f) => IFix f s -> IFix f s -> Substitution f
- var :: forall f s. (VarF :<: f, SingI s) => VariableName -> IFix f s
- true :: ConjunctionF :<: f => IFix f BooleanSort
- false :: DisjunctionF :<: f => IFix f BooleanSort
- and :: ConjunctionF :<: f => [IFix f BooleanSort] -> IFix f BooleanSort
- or :: DisjunctionF :<: f => [IFix f BooleanSort] -> IFix f BooleanSort
- not :: NegationF :<: f => IFix f BooleanSort -> IFix f BooleanSort
- forall :: UniversalF v :<: f => [Var v] -> IFix f BooleanSort -> IFix f BooleanSort
- exists :: ExistentialF v :<: f => [Var v] -> IFix f BooleanSort -> IFix f BooleanSort
- (.&.) :: ConjunctionF :<: f => IFix f BooleanSort -> IFix f BooleanSort -> IFix f BooleanSort
- (.|.) :: DisjunctionF :<: f => IFix f BooleanSort -> IFix f BooleanSort -> IFix f BooleanSort
- (.->.) :: (DisjunctionF :<: f, NegationF :<: f) => IFix f BooleanSort -> IFix f BooleanSort -> IFix f BooleanSort
- (.<-.) :: (DisjunctionF :<: f, NegationF :<: f) => IFix f BooleanSort -> IFix f BooleanSort -> IFix f BooleanSort
- (.<->.) :: (ConjunctionF :<: f, DisjunctionF :<: f, NegationF :<: f) => IFix f BooleanSort -> IFix f BooleanSort -> IFix f BooleanSort
- (./=.) :: forall f s. (NegationF :<: f, EqualityF :<: f, SingI s) => IFix f s -> IFix f s -> IFix f BooleanSort
- literals :: (ConjunctionF :<: f, DisjunctionF :<: f) => IFix f BooleanSort -> [IFix f BooleanSort]
- conjuncts :: ConjunctionF :<: f => IFix f BooleanSort -> [IFix f BooleanSort]
- disjuncts :: DisjunctionF :<: f => IFix f BooleanSort -> [IFix f BooleanSort]
- vars :: (VarF :<: f, IFoldable f, IFunctor f) => IFix f s -> [DynamicallySorted VarF]
- freevars :: (IFunctor f, MaybeQuantified f) => IFix f s -> [DynamicallySorted VarF]
- class MaybeQuantified f
- isQuantified :: MaybeQuantified f => IFix f s -> Bool
- isQuantifierFree :: MaybeQuantified f => IFix f s -> Bool
- class (NegationF :<: f, HasDual f f) => NNF f
- nnf :: forall f. NNF f => IFix f BooleanSort -> IFix f BooleanSort
- class (VarF :<: f, NegationF :<: f, IFunctor f, IFoldable f, ITraversable f, HasDual f f, MaybeQuantified' f f) => Prenex f
- prenex :: forall f. Prenex f => IFix f BooleanSort -> IFix f BooleanSort
- class (VarF :<: f, Bind f f, Bind' f f, MaybeQuantified'' f f, IFoldable f, ITraversable f) => Flatten f
- flatten :: forall f. Flatten f => IFix f BooleanSort -> IFix f BooleanSort
- class (VarF :<: f, EqualityF :<: f, Bind f f, Bind' f f, MaybeQuantified'' f f, Forall f f, Axiomatized f f, IFoldable f, ITraversable f) => Unstore f
- unstore :: forall f. Unstore f => IFix f BooleanSort -> IFix f BooleanSort
Documentation
module Data.Expression.Arithmetic
module Data.Expression.Array
module Data.Expression.Equality
module Data.Expression.IfThenElse
module Data.Expression.Parser
module Data.Expression.Sort
type QFLiaF = ArithmeticF :+: (IfThenElseF :+: QFLogicF) Source #
A functor representing the language of quantifier-free linear integer arithmetic theory in first order logic (integer constants, integer variables, addition, multiplication, divisibility, ordering)
type LiaF = ExistentialF BooleanSort :+: (ExistentialF IntegralSort :+: (UniversalF BooleanSort :+: (UniversalF IntegralSort :+: QFLiaF))) Source #
A functor much like QFLiaF
with quantifiers over booleans and integers
type ALiaF = ExistentialF BooleanSort :+: (ExistentialF IntegralSort :+: (UniversalF BooleanSort :+: (UniversalF IntegralSort :+: QFALiaF))) Source #
A functor much like QFALiaF
with quantifiers over booleans and integers
A language consisting solely of variables (useful for listing variables outside of any particular context, such as bound variables of quantified formula)
class BoundedLattice a => ComplementedLattice a where Source #
Bounded lattices that support complementing elements
complement . complement = id
complement :: a -> a Source #
type VariableName = String Source #
Type of names assigned to variables
A functor representing a sorted variable, each variable is identified by its name and sort
Var :: VariableName -> Sing s -> VarF a s |
data ConjunctionF a s where Source #
A functor representing a logical connective for conjunction
And :: [a BooleanSort] -> ConjunctionF a BooleanSort |
data DisjunctionF a s where Source #
A functor representing a logical connective for disjunction
Or :: [a BooleanSort] -> DisjunctionF a BooleanSort |
data NegationF a s where Source #
A functor representing a logical connective for negation
Not :: a BooleanSort -> NegationF a BooleanSort |
data UniversalF v a s where Source #
A functor representing a mono-sorted universal quantifier binding a number of variables within a formula
Forall :: [Var v] -> a BooleanSort -> UniversalF v a BooleanSort |
IShow Sort Sort (UniversalF v) Source # | |
IFoldable Sort (UniversalF v) Source # | |
IEq1 Sort (UniversalF v) Source # | |
IFunctor Sort (UniversalF v) Source # | |
ITraversable Sort (UniversalF v) Source # | |
MaybeQuantified Sort (UniversalF v) Source # | |
JoinSemiLattice (ALia BooleanSort) Source # | |
JoinSemiLattice (Lia BooleanSort) Source # | |
MeetSemiLattice (ALia BooleanSort) Source # | |
MeetSemiLattice (Lia BooleanSort) Source # | |
Lattice (ALia BooleanSort) Source # | |
Lattice (Lia BooleanSort) Source # | |
BoundedJoinSemiLattice (ALia BooleanSort) Source # | |
BoundedJoinSemiLattice (Lia BooleanSort) Source # | |
BoundedMeetSemiLattice (ALia BooleanSort) Source # | |
BoundedMeetSemiLattice (Lia BooleanSort) Source # | |
BoundedLattice (ALia BooleanSort) Source # | |
BoundedLattice (Lia BooleanSort) Source # | |
ComplementedLattice (ALia BooleanSort) Source # | |
ComplementedLattice (Lia BooleanSort) Source # | |
((:<:) Sort (UniversalF v) f, SingI Sort v) => Parseable ((Sort -> *) -> Sort -> *) (UniversalF v) f Source # | |
data ExistentialF v a s where Source #
A functor representing a mono-sorted existential quantifier binding a number of variables within a formula
Exists :: [Var v] -> a BooleanSort -> ExistentialF v a BooleanSort |
IShow Sort Sort (ExistentialF v) Source # | |
IFoldable Sort (ExistentialF v) Source # | |
IEq1 Sort (ExistentialF v) Source # | |
IFunctor Sort (ExistentialF v) Source # | |
ITraversable Sort (ExistentialF v) Source # | |
MaybeQuantified Sort (ExistentialF v) Source # | |
JoinSemiLattice (ALia BooleanSort) Source # | |
JoinSemiLattice (Lia BooleanSort) Source # | |
MeetSemiLattice (ALia BooleanSort) Source # | |
MeetSemiLattice (Lia BooleanSort) Source # | |
Lattice (ALia BooleanSort) Source # | |
Lattice (Lia BooleanSort) Source # | |
BoundedJoinSemiLattice (ALia BooleanSort) Source # | |
BoundedJoinSemiLattice (Lia BooleanSort) Source # | |
BoundedMeetSemiLattice (ALia BooleanSort) Source # | |
BoundedMeetSemiLattice (Lia BooleanSort) Source # | |
BoundedLattice (ALia BooleanSort) Source # | |
BoundedLattice (Lia BooleanSort) Source # | |
ComplementedLattice (ALia BooleanSort) Source # | |
ComplementedLattice (Lia BooleanSort) Source # | |
((:<:) Sort (ExistentialF v) f, SingI Sort v) => Parseable ((Sort -> *) -> Sort -> *) (ExistentialF v) f Source # | |
newtype Substitution f Source #
Substitution that given an expression produces replacement if the expression is to be replaced or nothing otherwise.
Substitution | |
|
Monoid (Substitution f) Source # | |
substitute :: (IFunctor f, IEq1 f) => IFix f s -> Substitution f -> IFix f s Source #
Executes a substitution.
for :: forall f s. (IFunctor f, IEq1 f) => IFix f s -> IFix f s -> Substitution f Source #
A simple constructor of substitutions that replaces the latter expression with the former.
var :: forall f s. (VarF :<: f, SingI s) => VariableName -> IFix f s Source #
A smart constructor for variables of any sort in any language Takes the variable name and infers the target language and sort from context.
var "a" :: Lia 'IntegralSort
true :: ConjunctionF :<: f => IFix f BooleanSort Source #
Logical tautology
false :: DisjunctionF :<: f => IFix f BooleanSort Source #
Logical contradiction
and :: ConjunctionF :<: f => [IFix f BooleanSort] -> IFix f BooleanSort Source #
A smart constructor for variadic conjunction
or :: DisjunctionF :<: f => [IFix f BooleanSort] -> IFix f BooleanSort Source #
A smart constructor for variadic disjunction
not :: NegationF :<: f => IFix f BooleanSort -> IFix f BooleanSort Source #
A smart constructor for negation
forall :: UniversalF v :<: f => [Var v] -> IFix f BooleanSort -> IFix f BooleanSort Source #
A smart constructor for universally quantified formulae
exists :: ExistentialF v :<: f => [Var v] -> IFix f BooleanSort -> IFix f BooleanSort Source #
A smart constructor for existentially quantified formulae
(.&.) :: ConjunctionF :<: f => IFix f BooleanSort -> IFix f BooleanSort -> IFix f BooleanSort infixr 6 Source #
A smart constructor for binary conjunction
(.|.) :: DisjunctionF :<: f => IFix f BooleanSort -> IFix f BooleanSort -> IFix f BooleanSort infixr 5 Source #
A smart constructor for binary disjunction
(.->.) :: (DisjunctionF :<: f, NegationF :<: f) => IFix f BooleanSort -> IFix f BooleanSort -> IFix f BooleanSort infixr 4 Source #
A smart constructor for implication (an abbreviation for not a .|. b
)
(.<-.) :: (DisjunctionF :<: f, NegationF :<: f) => IFix f BooleanSort -> IFix f BooleanSort -> IFix f BooleanSort infixl 4 Source #
A smart constructor for reversed implication (an abbreviation for a .|. not b
)
(.<->.) :: (ConjunctionF :<: f, DisjunctionF :<: f, NegationF :<: f) => IFix f BooleanSort -> IFix f BooleanSort -> IFix f BooleanSort infix 3 Source #
A smart constructor for if-and-only-if connective
(./=.) :: forall f s. (NegationF :<: f, EqualityF :<: f, SingI s) => IFix f s -> IFix f s -> IFix f BooleanSort infix 7 Source #
A smart constructor for disequality
literals :: (ConjunctionF :<: f, DisjunctionF :<: f) => IFix f BooleanSort -> [IFix f BooleanSort] Source #
literals
decomposes a boolean combination (formed with conjunctions and disjunctions, preferably in negation normal form) into its constituents.
conjuncts :: ConjunctionF :<: f => IFix f BooleanSort -> [IFix f BooleanSort] Source #
conjuncts
decomposes a conjunction into conjuncts.
disjuncts :: DisjunctionF :<: f => IFix f BooleanSort -> [IFix f BooleanSort] Source #
disjuncts
decomposes a disjunction into disjuncts.
vars :: (VarF :<: f, IFoldable f, IFunctor f) => IFix f s -> [DynamicallySorted VarF] Source #
Collects a list of all variables occurring in an expression (bound or free).
freevars :: (IFunctor f, MaybeQuantified f) => IFix f s -> [DynamicallySorted VarF] Source #
Collects a list of all free variables occurring in an expression.
class MaybeQuantified f Source #
isQuantified', freevars'
(IFunctor k f, IFoldable k f) => MaybeQuantified k f Source # | |
MaybeQuantified Sort (ExistentialF v) Source # | |
MaybeQuantified Sort (UniversalF v) Source # | |
MaybeQuantified Sort (VarF (Sort -> *)) Source # | |
(MaybeQuantified k f, MaybeQuantified k g) => MaybeQuantified k ((:+:) k (k -> *) f g) Source # | |
isQuantified :: MaybeQuantified f => IFix f s -> Bool Source #
Test whether an expression contains a quantifier.
isQuantifierFree :: MaybeQuantified f => IFix f s -> Bool Source #
Tests whether an expression is free of any quantifier.
nnf :: forall f. NNF f => IFix f BooleanSort -> IFix f BooleanSort Source #
Propagates negation toward boolean atoms (across conjunction, disjunction, quantifiers).
class (VarF :<: f, NegationF :<: f, IFunctor f, IFoldable f, ITraversable f, HasDual f f, MaybeQuantified' f f) => Prenex f Source #
prenex :: forall f. Prenex f => IFix f BooleanSort -> IFix f BooleanSort Source #
Puts an expression into prenex form (quantifier prefix and a quantifier-free formula).
class (VarF :<: f, Bind f f, Bind' f f, MaybeQuantified'' f f, IFoldable f, ITraversable f) => Flatten f Source #
flatten :: forall f. Flatten f => IFix f BooleanSort -> IFix f BooleanSort Source #
class (VarF :<: f, EqualityF :<: f, Bind f f, Bind' f f, MaybeQuantified'' f f, Forall f f, Axiomatized f f, IFoldable f, ITraversable f) => Unstore f Source #
unstore :: forall f. Unstore f => IFix f BooleanSort -> IFix f BooleanSort Source #
Replaces store
with an instance of its axiomatization.