Safe Haskell | None |
---|---|
Language | Haskell2010 |
Atomic constraints and sets of atomic constraints, represented as antichains. Saturation and restriction.
Synopsis
- data CInfo = CInfo {}
- type Atomic = Constraint 'L 'R
- data Constraint l r = Constraint {}
- modInfo :: Atomic -> Module
- spanInfo :: Atomic -> SrcSpan
- isTriviallyUnsat :: Atomic -> Bool
- headVar :: Atomic -> Maybe (Int, Name)
- bodyVars :: Atomic -> Set (Int, Name)
- impliedBy :: Atomic -> Atomic -> Bool
- tautology :: Atomic -> Bool
- resolve :: CInfo -> Atomic -> Atomic -> Maybe Atomic
- data ConstraintSetF a = ConstraintSetF {}
- type ConstraintSet = ConstraintSetF Atomic
- fromList :: [Atomic] -> ConstraintSet
- empty :: ConstraintSet
- unsats :: ConstraintSet -> ConstraintSet
- size :: ConstraintSet -> Int
- unsafeInsert :: Atomic -> ConstraintSet -> ConstraintSet
- insert' :: Atomic -> ConstraintSet -> Maybe ConstraintSet
- insert :: Atomic -> ConstraintSet -> ConstraintSet
- guardWith :: Guard -> ConstraintSet -> ConstraintSet
- saturate :: CInfo -> IntSet -> ConstraintSet -> ConstraintSet
- eligible :: IntSet -> Atomic -> Bool
- cexs :: CInfo -> ConstraintSet -> ConstraintSet
- fix :: CInfo -> IntSet -> State (ConstraintSet, ConstraintSet) ()
- saturate1 :: CInfo -> IntSet -> State (ConstraintSet, ConstraintSet) ()
Documentation
Type type of auxilliary information attached to
constraints c
:
prov c
is the module in which the constraint was createdspan c
is the originating location of the rhs of the constraint
INV: CInfo does not determine equality of constraints.
type Atomic = Constraint 'L 'R Source #
The type of constraints c
of shape guard c
? left c
⊆ right c
that originated from the
source at srcSpan c
.
data Constraint l r Source #
Instances
isTriviallyUnsat :: Atomic -> Bool Source #
Given an atomic constraint a
, isTriviallyUnsat a
just if a
is of the form G ? k in {}.
impliedBy :: Atomic -> Atomic -> Bool Source #
Given two atomic constraints a
and b
, a
just
if impliedBy
ba
and b
have the same body and the guard of a
is implied
by the guard of b
.
tautology :: Atomic -> Bool Source #
Given an atomic constraint a
, tautology a
just if a
is satisfied in
every assignment.
resolve :: CInfo -> Atomic -> Atomic -> Maybe Atomic Source #
When m
is the current module:
Given atomic constraints a
and b
, resolve m a b
is:
Nothing
if the resolvant ofa
andb
is a tautologyJust r
otherwise, wherer
is the resolvant as an atomic constraint
data ConstraintSetF a Source #
Instances
Semigroup ConstraintSet Source # | |
Defined in Intensional.Constraints (<>) :: ConstraintSet -> ConstraintSet -> ConstraintSet # sconcat :: NonEmpty ConstraintSet -> ConstraintSet # stimes :: Integral b => b -> ConstraintSet -> ConstraintSet # | |
Monoid ConstraintSet Source # | |
Defined in Intensional.Constraints mempty :: ConstraintSet # mappend :: ConstraintSet -> ConstraintSet -> ConstraintSet # mconcat :: [ConstraintSet] -> ConstraintSet # | |
Binary ConstraintSet Source # | |
Defined in Intensional.Constraints put_ :: BinHandle -> ConstraintSet -> IO () # put :: BinHandle -> ConstraintSet -> IO (Bin ConstraintSet) # get :: BinHandle -> IO ConstraintSet # | |
Outputable ConstraintSet Source # | |
Defined in Intensional.Constraints ppr :: ConstraintSet -> SDoc # pprPrec :: Rational -> ConstraintSet -> SDoc # | |
Refined ConstraintSet Source # | |
Defined in Intensional.Constraints domain :: ConstraintSet -> Domain Source # rename :: RVar -> RVar -> ConstraintSet -> ConstraintSet Source # |
type ConstraintSet = ConstraintSetF Atomic Source #
The type of sets of constraints.
We say that a set of constraints cs
is reduced just if,
for all X, d, Y, k:
definiteVV cs X d Y
, definiteKV cs X d k
and goal cs
are non-increasing lists wrt impliedBy
.
We say that a set of constraints cs
is an antichain just if
each of these lists are also non-decreasing.
Most sets of constraints we process are reduced, but we allow non-reduced constraint sets to occur as a consequence of renaming of variables.
Many sets of constraints are also antichains,
for example, when filtering a reduced constraint set one can
guarantee the new constraint set will be an antichain by using
insert
and constructing the new constraint set in the
reverse order. Constraint sets returned from saturation will
always be antichains.
fromList :: [Atomic] -> ConstraintSet Source #
Given a list of atomic constraints cs
, fromList cs
is
largest antichain contained in cs
empty :: ConstraintSet Source #
empty
is the empty constraint set
unsats :: ConstraintSet -> ConstraintSet Source #
Given a constraint set cs
, unsats cs
is the constraint set
consisting of just those trivially unsatisfiable constraints in cs
.
size :: ConstraintSet -> Int Source #
When cs
is a constraint set, size cs
is its cardinality.
unsafeInsert :: Atomic -> ConstraintSet -> ConstraintSet Source #
When a
is an atomic constraint and cs
a constraint set,
unsafeInsert a cs
is the constraint set obtained by inserting
a
into cs
.
Note: unsafeInsert a cs
may not be reduced even if cs
is.
insert' :: Atomic -> ConstraintSet -> Maybe ConstraintSet Source #
When a
is an atomic constraint and cs
is a constraint antichain
insert a cs
is:
Nothing
just ifa
is already implied by some constraint incs
.Just ds
otherwise, whereds
is the constraint antichain obtained by insertinga
intocs
. Note:ds
may be smaller thancs
.
insert :: Atomic -> ConstraintSet -> ConstraintSet Source #
When a
is an atomic constraint and cs
is a constraint set
insert a cs
is the constraint set obtained by inserting a
into cs
.
If cs
is reduced then so is insert a cs
. However, insert a cs
may not be an antichain even when cs
is.
guardWith :: Guard -> ConstraintSet -> ConstraintSet Source #
When g
is a guard and cs
a set of constraints, guardWith g cs
is
the set of constraints obtained from cs
by appending g
to every guard
of every constraint.
saturate :: CInfo -> IntSet -> ConstraintSet -> ConstraintSet Source #
When iface
is a set of interface variables and ci
is the current ctx
and cs
is a constraint set, saturate ci iface cs
is the constraint set
obtained from cs
by saturation and restriction to iface
.
eligible :: IntSet -> Atomic -> Bool Source #
Given a set of interface variables exts
and a constraint c
,
eligible exts c
just if there are no interface variables in the
head of c
and only interface variables elsewhere in c
.
(This means it is eligible to be used as the left-constraint in a resolution step.)
cexs :: CInfo -> ConstraintSet -> ConstraintSet Source #
Given some context ci
and constraints cs
attempt to build
a model of cs
. cexs ci cs
is the set of
trivially unsatisfiable constrants obtained from the candidate model.
fix :: CInfo -> IntSet -> State (ConstraintSet, ConstraintSet) () Source #
When exts
is the set of interface variables and ci
is the current
ctx fix ci exts
is the stateful computation that transforms an
initial state (ls, rs)
where ls
are all unit constraints modulo
exts
and ls
is contained in rs
, into a final state (ls', rs')
in which ls
is empty and rs'
is the saturation of rs
.
saturate1 :: CInfo -> IntSet -> State (ConstraintSet, ConstraintSet) () Source #
When exts
is a set of interface variables and ci
is the current ctx
saturate1 ci exts
is the stateful computation that takes an initial state
(ls, rs)
consisting of a pair of constraint sets with ls
being unit
clauses modulo exts
and ls
being contained in rs
to a final state
(ls', rs')
in which:
ls'
is those constraints inrs'
that are not inrs
and which are unit moduloexts
.rs'
contains all the constraints obtained fromrs
by resolving on the left with each clauses fromls
once.
Orphan instances
Foldable UniqFM Source # | |
fold :: Monoid m => UniqFM m -> m # foldMap :: Monoid m => (a -> m) -> UniqFM a -> m # foldMap' :: Monoid m => (a -> m) -> UniqFM a -> m # foldr :: (a -> b -> b) -> b -> UniqFM a -> b # foldr' :: (a -> b -> b) -> b -> UniqFM a -> b # foldl :: (b -> a -> b) -> b -> UniqFM a -> b # foldl' :: (b -> a -> b) -> b -> UniqFM a -> b # foldr1 :: (a -> a -> a) -> UniqFM a -> a # foldl1 :: (a -> a -> a) -> UniqFM a -> a # elem :: Eq a => a -> UniqFM a -> Bool # maximum :: Ord a => UniqFM a -> a # minimum :: Ord a => UniqFM a -> a # |