Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Under development (as of 20160218).
Solver is: - Monomorphic, i.e. the solver is polymorph but therefore can only work on 1 type of constraints, rules, etc. - Knows about variables for which substitutions can be found, substitutions are part of found solutions. - Backtracking (on variable bindings/substitutions), multiple solution alternatives are explored. - Found rules are applied in an order described by priorities associated with rules. Priorities can be dynamic, i.e. depend on terms in rules.
See
"A Flexible Search Framework for CHR", Leslie De Koninck, Tom Schrijvers, and Bart Demoen. http:/link.springer.com10.1007/978-3-540-92243-8_2
Synopsis
- data Verbosity
- data CHRGlobState cnstr guard bprio prio subst env m = CHRGlobState {
- _chrgstStore :: !(CHRStore cnstr guard bprio prio)
- _chrgstNextFreeRuleInx :: !CHRInx
- _chrgstScheduleQueue :: !(MinPQueue (CHRPrioEvaluatableVal bprio) (CHRMonoBacktrackPrioT cnstr guard bprio prio subst env m (SolverResult subst)))
- _chrgstTrace :: !(SolveTrace' cnstr (StoredCHR cnstr guard bprio prio) subst)
- _chrgstStatNrSolveSteps :: !Int
- _chrgstVarToNmMp :: !VarToNmMp
- emptyCHRGlobState :: TTCtxt (TrTrKey c) => CHRGlobState c g b p s e m
- chrgstVarToNmMp :: forall cnstr guard bprio prio subst env m. Lens' (CHRGlobState cnstr guard bprio prio subst env m) VarToNmMp
- chrgstStatNrSolveSteps :: forall cnstr guard bprio prio subst env m. Lens' (CHRGlobState cnstr guard bprio prio subst env m) Int
- data CHRBackState cnstr bprio subst env = CHRBackState {
- _chrbstBacktrackPrio :: !(CHRPrioEvaluatableVal bprio)
- _chrbstRuleWorkQueue :: !WorkQueue
- _chrbstSolveQueue :: !WorkQueue
- _chrbstResidualQueue :: [WorkInx]
- _chrbstWorkStore :: !(WorkStore cnstr)
- _chrbstMatchedCombis :: !(Set MatchedCombi)
- _chrbstFreshVar :: !Int
- _chrbstSolveSubst :: !subst
- _chrbstWaitForVar :: !(Map (VarLookupKey subst) [WaitForVar subst])
- _chrbstReductionSteps :: ![SolverReductionStep]
- emptyCHRBackState :: (TTCtxt (TrTrKey c), CHREmptySubstitution s, Bounded (CHRPrioEvaluatableVal bp)) => CHRBackState c bp s e
- emptyCHRStore :: TTCtxt (TrTrKey cnstr) => CHRStore cnstr guard bprio prio
- type CHRMonoBacktrackPrioT cnstr guard bprio prio subst env m = LogicStateT (CHRGlobState cnstr guard bprio prio subst env m) (CHRBackState cnstr bprio subst env) m
- type MonoBacktrackPrio cnstr guard bprio prio subst env m = (IsCHRSolvable env cnstr guard bprio prio subst, Monad m, Lookup subst (VarLookupKey subst) (VarLookupVal subst), LookupApply subst subst, Fresh Int (ExtrValVarKey (VarLookupVal subst)), ExtrValVarKey (VarLookupVal subst) ~ VarLookupKey subst, VarTerm (VarLookupVal subst))
- runCHRMonoBacktrackPrioT :: MonoBacktrackPrio cnstr guard bprio prio subst env m => CHRGlobState cnstr guard bprio prio subst env m -> CHRBackState cnstr bprio subst env -> CHRMonoBacktrackPrioT cnstr guard bprio prio subst env m (SolverResult subst) -> m ([SolverResult subst], (CHRGlobState cnstr guard bprio prio subst env m, CHRBackState cnstr bprio subst env))
- addRule :: MonoBacktrackPrio c g bp p s e m => Rule c g bp p -> CHRMonoBacktrackPrioT c g bp p s e m ()
- addConstraintAsWork :: MonoBacktrackPrio c g bp p s e m => c -> CHRMonoBacktrackPrioT c g bp p s e m (ConstraintSolvesVia, WorkInx)
- data SolverResult subst = SolverResult {
- slvresSubst :: !subst
- slvresResidualCnstr :: ![WorkInx]
- slvresWorkCnstr :: ![WorkInx]
- slvresWaitVarCnstr :: ![WorkInx]
- slvresReductionSteps :: ![SolverReductionStep]
- ppSolverResult :: (MonoBacktrackPrio c g bp p s e m, VarUpdatable s s, PP s) => Verbosity -> SolverResult s -> CHRMonoBacktrackPrioT c g bp p s e m PP_Doc
- data CHRSolveOpts = CHRSolveOpts {}
- defaultCHRSolveOpts :: CHRSolveOpts
- data StoredCHR c g bp p
- storedChrRule' :: StoredCHR c g bp p -> Rule c g bp p
- chrSolve :: forall c g bp p s e m. (MonoBacktrackPrio c g bp p s e m, PP s) => CHRSolveOpts -> e -> CHRMonoBacktrackPrioT c g bp p s e m (SolverResult s)
- slvFreshSubst :: forall c g bp p s e m x. (MonoBacktrackPrio c g bp p s e m, ExtrValVarKey x ~ ExtrValVarKey (VarLookupVal s), VarExtractable x) => Set (ExtrValVarKey x) -> x -> CHRMonoBacktrackPrioT c g bp p s e m s
- getSolveTrace :: (PP c, PP g, PP bp, MonoBacktrackPrio c g bp p s e m) => CHRMonoBacktrackPrioT c g bp p s e m PP_Doc
- type IsCHRSolvable env c g bp p s = (IsCHRConstraint env c s, IsCHRGuard env g s, IsCHRBacktrackPrio env bp s, IsCHRPrio env p s, PP (VarLookupKey s))
Documentation
Instances
Enum Verbosity Source # | |
Defined in CHR.Solve.MonoBacktrackPrio succ :: Verbosity -> Verbosity # pred :: Verbosity -> Verbosity # fromEnum :: Verbosity -> Int # enumFrom :: Verbosity -> [Verbosity] # enumFromThen :: Verbosity -> Verbosity -> [Verbosity] # enumFromTo :: Verbosity -> Verbosity -> [Verbosity] # enumFromThenTo :: Verbosity -> Verbosity -> Verbosity -> [Verbosity] # | |
Show Verbosity Source # | |
Eq Verbosity Source # | |
Ord Verbosity Source # | |
Defined in CHR.Solve.MonoBacktrackPrio |
data CHRGlobState cnstr guard bprio prio subst env m Source #
Global state
CHRGlobState | |
|
emptyCHRGlobState :: TTCtxt (TrTrKey c) => CHRGlobState c g b p s e m Source #
chrgstVarToNmMp :: forall cnstr guard bprio prio subst env m. Lens' (CHRGlobState cnstr guard bprio prio subst env m) VarToNmMp Source #
chrgstStatNrSolveSteps :: forall cnstr guard bprio prio subst env m. Lens' (CHRGlobState cnstr guard bprio prio subst env m) Int Source #
data CHRBackState cnstr bprio subst env Source #
Backtrackable state
CHRBackState | |
|
emptyCHRBackState :: (TTCtxt (TrTrKey c), CHREmptySubstitution s, Bounded (CHRPrioEvaluatableVal bp)) => CHRBackState c bp s e Source #
emptyCHRStore :: TTCtxt (TrTrKey cnstr) => CHRStore cnstr guard bprio prio Source #
type CHRMonoBacktrackPrioT cnstr guard bprio prio subst env m = LogicStateT (CHRGlobState cnstr guard bprio prio subst env m) (CHRBackState cnstr bprio subst env) m Source #
Monad for CHR, taking from LogicStateT
the state and backtracking behavior
type MonoBacktrackPrio cnstr guard bprio prio subst env m = (IsCHRSolvable env cnstr guard bprio prio subst, Monad m, Lookup subst (VarLookupKey subst) (VarLookupVal subst), LookupApply subst subst, Fresh Int (ExtrValVarKey (VarLookupVal subst)), ExtrValVarKey (VarLookupVal subst) ~ VarLookupKey subst, VarTerm (VarLookupVal subst)) Source #
All required behavior, as alias
runCHRMonoBacktrackPrioT :: MonoBacktrackPrio cnstr guard bprio prio subst env m => CHRGlobState cnstr guard bprio prio subst env m -> CHRBackState cnstr bprio subst env -> CHRMonoBacktrackPrioT cnstr guard bprio prio subst env m (SolverResult subst) -> m ([SolverResult subst], (CHRGlobState cnstr guard bprio prio subst env m, CHRBackState cnstr bprio subst env)) Source #
Run and observe results
addRule :: MonoBacktrackPrio c g bp p s e m => Rule c g bp p -> CHRMonoBacktrackPrioT c g bp p s e m () Source #
Add a rule as a CHR
addConstraintAsWork :: MonoBacktrackPrio c g bp p s e m => c -> CHRMonoBacktrackPrioT c g bp p s e m (ConstraintSolvesVia, WorkInx) Source #
Add a constraint to be solved or residualised
data SolverResult subst Source #
Solver solution
SolverResult | |
|
ppSolverResult :: (MonoBacktrackPrio c g bp p s e m, VarUpdatable s s, PP s) => Verbosity -> SolverResult s -> CHRMonoBacktrackPrioT c g bp p s e m PP_Doc Source #
PP result
data CHRSolveOpts Source #
Solve specific options
CHRSolveOpts | |
|
data StoredCHR c g bp p Source #
A CHR as stored in a CHRStore, requiring additional info for efficiency
storedChrRule' :: StoredCHR c g bp p -> Rule c g bp p Source #
chrSolve :: forall c g bp p s e m. (MonoBacktrackPrio c g bp p s e m, PP s) => CHRSolveOpts -> e -> CHRMonoBacktrackPrioT c g bp p s e m (SolverResult s) Source #
(Under dev) solve
slvFreshSubst :: forall c g bp p s e m x. (MonoBacktrackPrio c g bp p s e m, ExtrValVarKey x ~ ExtrValVarKey (VarLookupVal s), VarExtractable x) => Set (ExtrValVarKey x) -> x -> CHRMonoBacktrackPrioT c g bp p s e m s Source #
Fresh variables in the form of a subst
getSolveTrace :: (PP c, PP g, PP bp, MonoBacktrackPrio c g bp p s e m) => CHRMonoBacktrackPrioT c g bp p s e m PP_Doc Source #
type IsCHRSolvable env c g bp p s = (IsCHRConstraint env c s, IsCHRGuard env g s, IsCHRBacktrackPrio env bp s, IsCHRPrio env p s, PP (VarLookupKey s)) Source #
Alias API for solving requirements