Copyright | (c) Sirui Lu 2021-2023 |
---|---|
License | BSD-3-Clause (see the LICENSE file) |
Maintainer | siruilu@cs.washington.edu |
Stability | Experimental |
Portability | GHC only |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
Grisette.Internal.Core.Data.Class.CEGISSolver
Description
Synopsis
- data VerifierResult cex exception
- = CEGISVerifierFoundCex cex
- | CEGISVerifierNoCex Bool
- | CEGISVerifierException exception
- type SynthesisConstraintFun cex = cex -> IO SymBool
- type VerifierFun cex exception = Model -> IO (VerifierResult cex exception)
- data CEGISResult exception
- = CEGISSuccess Model
- | CEGISVerifierFailure exception
- | CEGISSolverFailure SolvingFailure
- solverGenericCEGIS :: Solver handle => handle -> Bool -> SymBool -> SynthesisConstraintFun input -> [VerifierFun input exception] -> IO ([input], CEGISResult exception)
- solverGenericCEGISWithRefinement :: Solver handle => handle -> Bool -> SymBool -> SynthesisConstraintFun input -> Maybe RefinementConditionFun -> [VerifierFun input exception] -> IO ([input], CEGISResult exception)
- genericCEGIS :: ConfigurableSolver config handle => config -> Bool -> SymBool -> SynthesisConstraintFun input -> [VerifierFun input exception] -> IO ([input], CEGISResult exception)
- genericCEGISWithRefinement :: ConfigurableSolver config handle => config -> Bool -> SymBool -> SynthesisConstraintFun input -> Maybe RefinementConditionFun -> [VerifierFun input exception] -> IO ([input], CEGISResult exception)
- data CEGISCondition = CEGISCondition SymBool SymBool
- cegisPostCond :: SymBool -> CEGISCondition
- cegisPrePost :: SymBool -> SymBool -> CEGISCondition
- solverCegisMultiInputs :: (EvalSym input, ExtractSym input, Solver handle) => handle -> handle -> [input] -> (input -> CEGISCondition) -> IO ([input], CEGISResult SolvingFailure)
- solverCegis :: (Solver handle, EvalSym inputs, ExtractSym inputs, SymEq inputs) => handle -> handle -> inputs -> (inputs -> CEGISCondition) -> IO ([inputs], CEGISResult SolvingFailure)
- solverCegisExcept :: forall t (u :: Type -> Type) e v inputs handle. (UnionWithExcept t u e v, PlainUnion u, Functor u, EvalSym inputs, ExtractSym inputs, Solver handle, SymEq inputs) => handle -> handle -> inputs -> (Either e v -> CEGISCondition) -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure)
- solverCegisExceptStdVC :: forall t (u :: Type -> Type) inputs handle. (UnionWithExcept t u VerificationConditions (), PlainUnion u, Monad u, EvalSym inputs, ExtractSym inputs, Solver handle, SymEq inputs) => handle -> handle -> inputs -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure)
- solverCegisExceptVC :: (UnionWithExcept t u e v, PlainUnion u, Monad u, EvalSym inputs, ExtractSym inputs, Solver handle, SymEq inputs) => handle -> handle -> inputs -> (Either e v -> u (Either VerificationConditions ())) -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure)
- solverCegisExceptMultiInputs :: forall handle inputs t (u :: Type -> Type) e v. (Solver handle, EvalSym inputs, ExtractSym inputs, UnionWithExcept t u e v, PlainUnion u, Monad u) => handle -> handle -> [inputs] -> (Either e v -> CEGISCondition) -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure)
- solverCegisExceptStdVCMultiInputs :: forall handle inputs t (u :: Type -> Type). (Solver handle, EvalSym inputs, ExtractSym inputs, UnionWithExcept t u VerificationConditions (), PlainUnion u, Monad u) => handle -> handle -> [inputs] -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure)
- solverCegisExceptVCMultiInputs :: (Solver handle, EvalSym inputs, ExtractSym inputs, UnionWithExcept t u e v, PlainUnion u, Monad u) => handle -> handle -> [inputs] -> (Either e v -> u (Either VerificationConditions ())) -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure)
- solverCegisForAll :: (ExtractSym forallInput, Solver handle) => handle -> handle -> forallInput -> CEGISCondition -> IO ([Model], CEGISResult SolvingFailure)
- solverCegisForAllExcept :: forall t (u :: Type -> Type) e v inputs handle. (UnionWithExcept t u e v, PlainUnion u, Functor u, EvalSym inputs, ExtractSym inputs, Solver handle, SymEq inputs) => handle -> handle -> inputs -> (Either e v -> CEGISCondition) -> t -> IO ([Model], CEGISResult SolvingFailure)
- solverCegisForAllExceptStdVC :: forall t (u :: Type -> Type) inputs handle. (UnionWithExcept t u VerificationConditions (), PlainUnion u, Monad u, EvalSym inputs, ExtractSym inputs, Solver handle, SymEq inputs) => handle -> handle -> inputs -> t -> IO ([Model], CEGISResult SolvingFailure)
- solverCegisForAllExceptVC :: (UnionWithExcept t u e v, PlainUnion u, Monad u, EvalSym inputs, ExtractSym inputs, Solver handle, SymEq inputs) => handle -> handle -> inputs -> (Either e v -> u (Either VerificationConditions ())) -> t -> IO ([Model], CEGISResult SolvingFailure)
- cegisMultiInputs :: (EvalSym input, ExtractSym input, ConfigurableSolver config handle) => config -> [input] -> (input -> CEGISCondition) -> IO ([input], CEGISResult SolvingFailure)
- cegis :: (ConfigurableSolver config handle, EvalSym inputs, ExtractSym inputs, SymEq inputs) => config -> inputs -> (inputs -> CEGISCondition) -> IO ([inputs], CEGISResult SolvingFailure)
- cegisExcept :: forall t (u :: Type -> Type) e v inputs config handle. (UnionWithExcept t u e v, PlainUnion u, Functor u, EvalSym inputs, ExtractSym inputs, ConfigurableSolver config handle, SymEq inputs) => config -> inputs -> (Either e v -> CEGISCondition) -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure)
- cegisExceptStdVC :: forall t (u :: Type -> Type) inputs config handle. (UnionWithExcept t u VerificationConditions (), PlainUnion u, Monad u, EvalSym inputs, ExtractSym inputs, ConfigurableSolver config handle, SymEq inputs) => config -> inputs -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure)
- cegisExceptVC :: (UnionWithExcept t u e v, PlainUnion u, Monad u, EvalSym inputs, ExtractSym inputs, ConfigurableSolver config handle, SymEq inputs) => config -> inputs -> (Either e v -> u (Either VerificationConditions ())) -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure)
- cegisExceptMultiInputs :: forall config handle inputs t (u :: Type -> Type) e v. (ConfigurableSolver config handle, EvalSym inputs, ExtractSym inputs, UnionWithExcept t u e v, PlainUnion u, Monad u) => config -> [inputs] -> (Either e v -> CEGISCondition) -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure)
- cegisExceptStdVCMultiInputs :: forall config handle inputs t (u :: Type -> Type). (ConfigurableSolver config handle, EvalSym inputs, ExtractSym inputs, UnionWithExcept t u VerificationConditions (), PlainUnion u, Monad u) => config -> [inputs] -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure)
- cegisExceptVCMultiInputs :: (ConfigurableSolver config handle, EvalSym inputs, ExtractSym inputs, UnionWithExcept t u e v, PlainUnion u, Monad u) => config -> [inputs] -> (Either e v -> u (Either VerificationConditions ())) -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure)
- cegisForAll :: (ExtractSym forallInput, ConfigurableSolver config handle) => config -> forallInput -> CEGISCondition -> IO ([Model], CEGISResult SolvingFailure)
- cegisForAllExcept :: forall t (u :: Type -> Type) e v inputs config handle. (UnionWithExcept t u e v, PlainUnion u, Functor u, EvalSym inputs, ExtractSym inputs, ConfigurableSolver config handle, SymEq inputs) => config -> inputs -> (Either e v -> CEGISCondition) -> t -> IO ([Model], CEGISResult SolvingFailure)
- cegisForAllExceptStdVC :: forall t (u :: Type -> Type) inputs config handle. (UnionWithExcept t u VerificationConditions (), PlainUnion u, Monad u, EvalSym inputs, ExtractSym inputs, ConfigurableSolver config handle, SymEq inputs) => config -> inputs -> t -> IO ([Model], CEGISResult SolvingFailure)
- cegisForAllExceptVC :: (UnionWithExcept t u e v, PlainUnion u, Monad u, EvalSym inputs, ExtractSym inputs, ConfigurableSolver config handle, SymEq inputs) => config -> inputs -> (Either e v -> u (Either VerificationConditions ())) -> t -> IO ([Model], CEGISResult SolvingFailure)
Note for the examples
The examples assumes that the z3
solver is available in PATH
.
Generic CEGIS interface
data VerifierResult cex exception Source #
The response from a verifier.
Constructors
CEGISVerifierFoundCex cex | |
CEGISVerifierNoCex Bool | True indicates that the verifier is sure that there is no counter-example, while False indicates that the verifier is not sure, but it cannot find a counter-example. |
CEGISVerifierException exception |
Instances
type SynthesisConstraintFun cex = cex -> IO SymBool Source #
Build the synthesizer constraint from the verfication result. The first argument will be guaranteed to be distinct during each invocation of the function in the CEGIS algorithm, so it can be used to instantiate the identifiers for fresh variables.
type VerifierFun cex exception = Model -> IO (VerifierResult cex exception) Source #
The verifier.
data CEGISResult exception Source #
The result of the CEGIS procedure.
Constructors
CEGISSuccess Model | |
CEGISVerifierFailure exception | |
CEGISSolverFailure SolvingFailure |
Instances
Lift exception => Lift (CEGISResult exception :: Type) Source # | |||||
Defined in Grisette.Internal.Core.Data.Class.CEGISSolver Methods lift :: Quote m => CEGISResult exception -> m Exp # liftTyped :: forall (m :: Type -> Type). Quote m => CEGISResult exception -> Code m (CEGISResult exception) # | |||||
Serial exception => Binary (CEGISResult exception) Source # | |||||
Defined in Grisette.Internal.Core.Data.Class.CEGISSolver Methods put :: CEGISResult exception -> Put # get :: Get (CEGISResult exception) # putList :: [CEGISResult exception] -> Put # | |||||
Serial exception => Serial (CEGISResult exception) Source # | |||||
Defined in Grisette.Internal.Core.Data.Class.CEGISSolver Methods serialize :: MonadPut m => CEGISResult exception -> m () # deserialize :: MonadGet m => m (CEGISResult exception) # | |||||
Serial exception => Serialize (CEGISResult exception) Source # | |||||
NFData exception => NFData (CEGISResult exception) Source # | |||||
Defined in Grisette.Internal.Core.Data.Class.CEGISSolver Methods rnf :: CEGISResult exception -> () # | |||||
Generic (CEGISResult exception) Source # | |||||
Defined in Grisette.Internal.Core.Data.Class.CEGISSolver Associated Types
Methods from :: CEGISResult exception -> Rep (CEGISResult exception) x # to :: Rep (CEGISResult exception) x -> CEGISResult exception # | |||||
Show exception => Show (CEGISResult exception) Source # | |||||
Defined in Grisette.Internal.Core.Data.Class.CEGISSolver Methods showsPrec :: Int -> CEGISResult exception -> ShowS # show :: CEGISResult exception -> String # showList :: [CEGISResult exception] -> ShowS # | |||||
Eq exception => Eq (CEGISResult exception) Source # | |||||
Defined in Grisette.Internal.Core.Data.Class.CEGISSolver Methods (==) :: CEGISResult exception -> CEGISResult exception -> Bool # (/=) :: CEGISResult exception -> CEGISResult exception -> Bool # | |||||
Hashable exception => Hashable (CEGISResult exception) Source # | |||||
type Rep (CEGISResult exception) Source # | |||||
Defined in Grisette.Internal.Core.Data.Class.CEGISSolver type Rep (CEGISResult exception) = D1 ('MetaData "CEGISResult" "Grisette.Internal.Core.Data.Class.CEGISSolver" "grisette-0.11.0.0-HndeEPlDvvDHSETLw6O8c" 'False) (C1 ('MetaCons "CEGISSuccess" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Model)) :+: (C1 ('MetaCons "CEGISVerifierFailure" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 exception)) :+: C1 ('MetaCons "CEGISSolverFailure" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SolvingFailure)))) |
Arguments
:: Solver handle | |
=> handle | Configuration of the solver. |
-> Bool | Whether we should rerun the passed verifiers if any other verifier found a counter-example. |
-> SymBool | The initial synthesis constraint. |
-> SynthesisConstraintFun input | Synthesis constraint from counter-examples |
-> [VerifierFun input exception] | The verifier functions. |
-> IO ([input], CEGISResult exception) |
Generic CEGIS procedure. See genericCEGIS
for more details.
The difference from genericCEGIS
is that this function accepts a solver
handle for the synthesizer, instead of a solver configuration.
solverGenericCEGISWithRefinement Source #
Arguments
:: Solver handle | |
=> handle | Configuration of the solver. |
-> Bool | Whether we should rerun the passed verifiers if any other verifier found a counter-example. |
-> SymBool | The initial synthesis constraint. |
-> SynthesisConstraintFun input | Synthesis constraint from counter-examples |
-> Maybe RefinementConditionFun | Refinement condition generator. |
-> [VerifierFun input exception] | The verifier functions. |
-> IO ([input], CEGISResult exception) |
Generic CEGIS procedure with refinement. See genericCEGISWithRefinement
for more details.
The difference from genericCEGISWithRefinement
is that this function
accepts a solver handle for the synthesizer, instead of a solver
configuration.
Arguments
:: ConfigurableSolver config handle | |
=> config | Configuration of the solver. |
-> Bool | Whether we should rerun the passed verifiers if any other verifier found a counter-example. |
-> SymBool | The initial synthesis constraint. |
-> SynthesisConstraintFun input | Synthesis constraint from counter-examples |
-> [VerifierFun input exception] | The verifier functions. |
-> IO ([input], CEGISResult exception) |
Generic CEGIS procedure.
The CEGIS procedure will try to find a model that satisfies the initial synthesis constraint, and satisfies all the inputs generated by the verifier.
genericCEGISWithRefinement Source #
Arguments
:: ConfigurableSolver config handle | |
=> config | Configuration of the solver. |
-> Bool | Whether we should rerun the passed verifiers if any other verifier found a counter-example. |
-> SymBool | The initial synthesis constraint. |
-> SynthesisConstraintFun input | Synthesis constraint from counter-examples |
-> Maybe RefinementConditionFun | Refinement condition generator. |
-> [VerifierFun input exception] | The verifier functions. |
-> IO ([input], CEGISResult exception) |
Generic CEGIS procedure.
The CEGIS procedure will try to find a model that satisfies the initial synthesis constraint, and satisfies all the inputs generated by the verifier.
CEGIS interfaces with pre/post conditions
data CEGISCondition Source #
The condition for CEGIS to solve.
The first argument is the pre-condition, and the second argument is the post-condition.
The CEGIS procedures would try to find a model for the formula
\[ \forall P. (\exists I. \mathrm{pre}(P, I)) \wedge (\forall I. \mathrm{pre}(P, I)\implies \mathrm{post}(P, I)) \]
In program synthesis tasks, \(P\) is the symbolic constants in the symbolic program, and \(I\) is the input. The pre-condition is used to restrict the search space of the program. The procedure would only return programs that meets the pre-conditions on every possible inputs, and there are at least one possible input. The post-condition is used to specify the desired program behaviors.
Constructors
CEGISCondition SymBool SymBool |
Instances
Generic CEGISCondition Source # | |||||
Defined in Grisette.Internal.Core.Data.Class.CEGISSolver Associated Types
Methods from :: CEGISCondition -> Rep CEGISCondition x # to :: Rep CEGISCondition x -> CEGISCondition # | |||||
EvalSym CEGISCondition Source # | |||||
Defined in Grisette.Internal.Core.Data.Class.CEGISSolver Methods evalSym :: Bool -> Model -> CEGISCondition -> CEGISCondition Source # | |||||
Mergeable CEGISCondition Source # | |||||
Defined in Grisette.Internal.Core.Data.Class.CEGISSolver Methods rootStrategy :: MergingStrategy CEGISCondition Source # sortIndices :: CEGISCondition -> [DynamicSortedIdx] Source # | |||||
SimpleMergeable CEGISCondition Source # | |||||
Defined in Grisette.Internal.Core.Data.Class.CEGISSolver Methods mrgIte :: SymBool -> CEGISCondition -> CEGISCondition -> CEGISCondition Source # | |||||
type Rep CEGISCondition Source # | |||||
Defined in Grisette.Internal.Core.Data.Class.CEGISSolver type Rep CEGISCondition = D1 ('MetaData "CEGISCondition" "Grisette.Internal.Core.Data.Class.CEGISSolver" "grisette-0.11.0.0-HndeEPlDvvDHSETLw6O8c" 'False) (C1 ('MetaCons "CEGISCondition" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SymBool) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SymBool))) |
cegisPostCond :: SymBool -> CEGISCondition Source #
Construct a CEGIS condition with only a post-condition. The pre-condition would be set to true, meaning that all programs in the program space are allowed.
cegisPrePost :: SymBool -> SymBool -> CEGISCondition Source #
Construct a CEGIS condition with both pre- and post-conditions.
solverCegisMultiInputs Source #
Arguments
:: (EvalSym input, ExtractSym input, Solver handle) | |
=> handle | |
-> handle | |
-> [input] | Initial symbolic inputs. The solver will try to find a
program that works on all the inputs representable by these inputs (see
|
-> (input -> CEGISCondition) | The condition for the solver to solve. All the symbolic constants that are not in the inputs will be considered as part of the symbolic program. |
-> IO ([input], CEGISResult SolvingFailure) | The counter-examples generated during the CEGIS loop, and the model found by the solver. |
CEGIS with multiple (possibly symbolic) inputs. See cegisMultiInputs
for
more details.
The difference from cegisMultiInputs
is that this function accepts two
solver handles, one for the synthesizer and one for the verifier.
The synthesizer solver will **not** be reset, while the verifier solver will be reset after each iteration.
Arguments
:: (Solver handle, EvalSym inputs, ExtractSym inputs, SymEq inputs) | |
=> handle | The synthesizer solver handle |
-> handle | The verifier solver handle |
-> inputs | Initial symbolic inputs. The solver will try to find a
program that works on all the inputs representable by it (see
|
-> (inputs -> CEGISCondition) | The condition for the solver to solve. All the symbolic constants that are not in the inputs will be considered as part of the symbolic program. |
-> IO ([inputs], CEGISResult SolvingFailure) | The counter-examples generated during the CEGIS loop, and the model found by the solver. |
CEGIS with a single symbolic input to represent a set of inputs. See
cegis
for more details.
The difference from cegis
is that this function accepts two solver handles,
one for the synthesizer and one for the verifier.
The synthesizer solver will **not** be reset, while the verifier solver will be reset after each iteration.
solverCegisExcept :: forall t (u :: Type -> Type) e v inputs handle. (UnionWithExcept t u e v, PlainUnion u, Functor u, EvalSym inputs, ExtractSym inputs, Solver handle, SymEq inputs) => handle -> handle -> inputs -> (Either e v -> CEGISCondition) -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure) Source #
CEGIS for symbolic programs with error handling, using a single symbolic
input to represent a set of inputs. See cegisExcept
for more details.
The difference from cegisExcept
is that this function accepts two solver
handles, one for the synthesizer and one for the verifier.
The synthesizer solver will **not** be reset, while the verifier solver will be reset after each iteration.
solverCegisExceptStdVC :: forall t (u :: Type -> Type) inputs handle. (UnionWithExcept t u VerificationConditions (), PlainUnion u, Monad u, EvalSym inputs, ExtractSym inputs, Solver handle, SymEq inputs) => handle -> handle -> inputs -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure) Source #
CEGIS for symbolic programs with error handling, using a single symbolic
input to represent a set of inputs. See cegisExceptStdVC
for more details.
The difference from cegisExceptStdVC
is that this function accepts two
solver handles, one for the synthesizer and one for the verifier.
The synthesizer solver will **not** be reset, while the verifier solver will be reset after each iteration.
solverCegisExceptVC :: (UnionWithExcept t u e v, PlainUnion u, Monad u, EvalSym inputs, ExtractSym inputs, Solver handle, SymEq inputs) => handle -> handle -> inputs -> (Either e v -> u (Either VerificationConditions ())) -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure) Source #
CEGIS for symbolic programs with error handling, using a single symbolic input to represent a set of inputs.
The errors should be translated to assertion or assumption violations.
The difference from cegisExceptVC
is that this function accepts two solver
handles, one for the synthesizer and one for the verifier.
The synthesizer solver will **not** be reset, while the verifier solver will be reset after each iteration.
solverCegisExceptMultiInputs :: forall handle inputs t (u :: Type -> Type) e v. (Solver handle, EvalSym inputs, ExtractSym inputs, UnionWithExcept t u e v, PlainUnion u, Monad u) => handle -> handle -> [inputs] -> (Either e v -> CEGISCondition) -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure) Source #
CEGIS for symbolic programs with error handling, using multiple (possibly symbolic) inputs to represent a set of inputs.
The difference from cegisExceptMultiInputs
is that this function accepts
two solver handles, one for the synthesizer and one for the verifier.
The synthesizer solver will **not** be reset, while the verifier solver will be reset after each iteration.
solverCegisExceptStdVCMultiInputs :: forall handle inputs t (u :: Type -> Type). (Solver handle, EvalSym inputs, ExtractSym inputs, UnionWithExcept t u VerificationConditions (), PlainUnion u, Monad u) => handle -> handle -> [inputs] -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure) Source #
CEGIS for symbolic programs with error handling, using multiple (possibly
symbolic) inputs to represent a set of inputs. See
cegisExceptStdVCMultiInputs
for more details.
The difference from cegisExceptStdVCMultiInputs
is that this function
accepts two solver handles, one for the synthesizer and one for the verifier.
The synthesizer solver will **not** be reset, while the verifier solver will be reset after each iteration.
solverCegisExceptVCMultiInputs :: (Solver handle, EvalSym inputs, ExtractSym inputs, UnionWithExcept t u e v, PlainUnion u, Monad u) => handle -> handle -> [inputs] -> (Either e v -> u (Either VerificationConditions ())) -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure) Source #
CEGIS for symbolic programs with error handling, using multiple (possibly symbolic) inputs to represent a set of inputs.
The errors should be translated to assertion or assumption violations.
The difference from cegisExceptVCMultiInputs
is that this function accepts
two solver handles, one for the synthesizer and one for the verifier.
The synthesizer solver will **not** be reset, while the verifier solver will be reset after each iteration.
Arguments
:: (ExtractSym forallInput, Solver handle) | |
=> handle | |
-> handle | |
-> forallInput | A symbolic value. All the symbolic constants in the value are treated as for-all variables. |
-> CEGISCondition | |
-> IO ([Model], CEGISResult SolvingFailure) | First output are the counter-examples for all the for-all variables, and the second output is the model for all other variables if CEGIS succeeds. |
CEGIS with a single symbolic input to represent a set of inputs. See
cegisForAll
for more details.
The difference from cegisForAll
is that this function accepts two solver
handles, one for the synthesizer and one for the verifier.
The synthesizer solver will **not** be reset, while the verifier solver will be reset after each iteration.
solverCegisForAllExcept :: forall t (u :: Type -> Type) e v inputs handle. (UnionWithExcept t u e v, PlainUnion u, Functor u, EvalSym inputs, ExtractSym inputs, Solver handle, SymEq inputs) => handle -> handle -> inputs -> (Either e v -> CEGISCondition) -> t -> IO ([Model], CEGISResult SolvingFailure) Source #
CEGIS for symbolic programs with error handling, with a forall variable.
See cegisForAllExcept
, cegisForAll
and cegisExcept
.
The difference from cegisForAllExcept
is that this function accepts two
solver handles, one for the synthesizer and one for the verifier.
The synthesizer solver will **not** be reset, while the verifier solver will be reset after each iteration.
solverCegisForAllExceptStdVC :: forall t (u :: Type -> Type) inputs handle. (UnionWithExcept t u VerificationConditions (), PlainUnion u, Monad u, EvalSym inputs, ExtractSym inputs, Solver handle, SymEq inputs) => handle -> handle -> inputs -> t -> IO ([Model], CEGISResult SolvingFailure) Source #
CEGIS for symbolic programs with error handling, with a forall variable.
See cegisForAllExceptStdVC
cegisForAll
and cegisExceptStdVC
.
The difference from cegisForAllExceptStdVC
is that this function accepts
two solver handles, one for the synthesizer and one for the verifier.
The synthesizer solver will **not** be reset, while the verifier solver will be reset after each iteration.
solverCegisForAllExceptVC :: (UnionWithExcept t u e v, PlainUnion u, Monad u, EvalSym inputs, ExtractSym inputs, Solver handle, SymEq inputs) => handle -> handle -> inputs -> (Either e v -> u (Either VerificationConditions ())) -> t -> IO ([Model], CEGISResult SolvingFailure) Source #
CEGIS for symbolic programs with error handling, with a forall variable.
See cegisForAllExceptVC
cegisForAll
and cegisExceptVC
.
The difference from cegisForAllExceptVC
is that this function accepts two
solver handles, one for the synthesizer and one for the verifier.
The synthesizer solver will **not** be reset, while the verifier solver will be reset after each iteration.
Arguments
:: (EvalSym input, ExtractSym input, ConfigurableSolver config handle) | |
=> config | The configuration of the solver |
-> [input] | Initial symbolic inputs. The solver will try to find a
program that works on all the inputs representable by these inputs (see
|
-> (input -> CEGISCondition) | The condition for the solver to solve. All the symbolic constants that are not in the inputs will be considered as part of the symbolic program. |
-> IO ([input], CEGISResult SolvingFailure) | The counter-examples generated during the CEGIS loop, and the model found by the solver. |
CEGIS with multiple (possibly symbolic) inputs. Solves the following formula
(see CEGISCondition
for details).
\[ \forall P. (\exists I\in\mathrm{inputs}. \mathrm{pre}(P, I)) \wedge (\forall I\in\mathrm{inputs}. \mathrm{pre}(P, I)\implies \mathrm{post}(P, I)) \]
For simpler queries, where the inputs are representable by a single
symbolic value, you may want to use cegis
or cegisExcept
instead.
We have an example for the cegis
call.
Arguments
:: (ConfigurableSolver config handle, EvalSym inputs, ExtractSym inputs, SymEq inputs) | |
=> config | The configuration of the solver |
-> inputs | Initial symbolic inputs. The solver will try to find a
program that works on all the inputs representable by it (see
|
-> (inputs -> CEGISCondition) | The condition for the solver to solve. All the symbolic constants that are not in the inputs will be considered as part of the symbolic program. |
-> IO ([inputs], CEGISResult SolvingFailure) | The counter-examples generated during the CEGIS loop, and the model found by the solver. |
CEGIS with a single symbolic input to represent a set of inputs.
The following example tries to find the value of c
such that for all
positive x
, x * c && c -2
. The c .> -2
clause is used to make
the solution unique.
>>>
let [x,c] = ["x","c"] :: [SymInteger]
>>>
cegis z3 x (\x -> cegisPrePost (x .> 0) (x * c .< 0 .&& c .> -2))
(...,CEGISSuccess (Model {c -> -1 :: Integer}))
cegisExcept :: forall t (u :: Type -> Type) e v inputs config handle. (UnionWithExcept t u e v, PlainUnion u, Functor u, EvalSym inputs, ExtractSym inputs, ConfigurableSolver config handle, SymEq inputs) => config -> inputs -> (Either e v -> CEGISCondition) -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure) Source #
CEGIS for symbolic programs with error handling, using a single symbolic input to represent a set of inputs.
cegisExcept
is particularly useful when custom error types are used.
With cegisExcept
, you define how the errors are interpreted to the
CEGIS conditions after the symbolic evaluation. This could increase the
readability and modularity of the code.
The following example tries to find the value of c
such that for all
positive x
, x * c && c -2
. The c .> -2
assertion is used to make
the solution unique.
>>>
let [x,c] = ["x","c"] :: [SymInteger]
>>>
import Control.Monad.Except
>>>
:{
res :: SymInteger -> ExceptT VerificationConditions Union () res x = do symAssume $ x .> 0 symAssert $ x * c .< 0 symAssert $ c .> -2 :}
>>>
:{
translation (Left AssumptionViolation) = cegisPrePost (con False) (con True) translation (Left AssertionViolation) = cegisPostCond (con False) translation _ = cegisPostCond (con True) :}
>>>
cegisExcept z3 x translation res
([...],CEGISSuccess (Model {c -> -1 :: Integer}))
cegisExceptStdVC :: forall t (u :: Type -> Type) inputs config handle. (UnionWithExcept t u VerificationConditions (), PlainUnion u, Monad u, EvalSym inputs, ExtractSym inputs, ConfigurableSolver config handle, SymEq inputs) => config -> inputs -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure) Source #
CEGIS for symbolic programs with error handling, using a single symbolic
input to represent a set of inputs. This function saves the efforts to
implement the translation function for the standard error type
VerificationConditions
, and the standard result type ()
.
This function translates assumption violations to failed pre-conditions,
and translates assertion violations to failed post-conditions.
The ()
result will not fail any conditions.
The following example tries to find the value of c
such that for all
positive x
, x * c && c -2
. The c .> -2
assertion is used to make
the solution unique.
>>>
let [x,c] = ["x","c"] :: [SymInteger]
>>>
import Control.Monad.Except
>>>
:{
res :: SymInteger -> ExceptT VerificationConditions Union () res x = do symAssume $ x .> 0 symAssert $ x * c .< 0 symAssert $ c .> -2 :}
>>>
cegisExceptStdVC z3 x res
([...],CEGISSuccess (Model {c -> -1 :: Integer}))
cegisExceptVC :: (UnionWithExcept t u e v, PlainUnion u, Monad u, EvalSym inputs, ExtractSym inputs, ConfigurableSolver config handle, SymEq inputs) => config -> inputs -> (Either e v -> u (Either VerificationConditions ())) -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure) Source #
CEGIS for symbolic programs with error handling, using a single symbolic input to represent a set of inputs.
The errors should be translated to assertion or assumption violations.
cegisExceptMultiInputs :: forall config handle inputs t (u :: Type -> Type) e v. (ConfigurableSolver config handle, EvalSym inputs, ExtractSym inputs, UnionWithExcept t u e v, PlainUnion u, Monad u) => config -> [inputs] -> (Either e v -> CEGISCondition) -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure) Source #
CEGIS for symbolic programs with error handling, using multiple (possibly symbolic) inputs to represent a set of inputs.
cegisExceptStdVCMultiInputs :: forall config handle inputs t (u :: Type -> Type). (ConfigurableSolver config handle, EvalSym inputs, ExtractSym inputs, UnionWithExcept t u VerificationConditions (), PlainUnion u, Monad u) => config -> [inputs] -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure) Source #
CEGIS for symbolic programs with error handling, using multiple (possibly
symbolic) inputs to represent a set of inputs. This function saves the
efforts to implement the translation function for the standard error type
VerificationConditions
, and the standard result type ()
.
This function translates assumption violations to failed pre-conditions,
and translates assertion violations to failed post-conditions.
The ()
result will not fail any conditions.
cegisExceptVCMultiInputs :: (ConfigurableSolver config handle, EvalSym inputs, ExtractSym inputs, UnionWithExcept t u e v, PlainUnion u, Monad u) => config -> [inputs] -> (Either e v -> u (Either VerificationConditions ())) -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure) Source #
CEGIS for symbolic programs with error handling, using multiple (possibly symbolic) inputs to represent a set of inputs.
The errors should be translated to assertion or assumption violations.
Arguments
:: (ExtractSym forallInput, ConfigurableSolver config handle) | |
=> config | |
-> forallInput | A symbolic value. All the symbolic constants in the value are treated as for-all variables. |
-> CEGISCondition | |
-> IO ([Model], CEGISResult SolvingFailure) | First output are the counter-examples for all the for-all variables, and the second output is the model for all other variables if CEGIS succeeds. |
CEGIS with a single symbolic input to represent a set of inputs.
The following example tries to find the value of c
such that for all
positive x
, x * c && c -2
. The c .> -2
clause is used to make
the solution unique.
>>>
let [x,c] = ["x","c"] :: [SymInteger]
>>>
cegisForAll z3 x $ cegisPrePost (x .> 0) (x * c .< 0 .&& c .> -2)
(...,CEGISSuccess (Model {c -> -1 :: Integer}))
cegisForAllExcept :: forall t (u :: Type -> Type) e v inputs config handle. (UnionWithExcept t u e v, PlainUnion u, Functor u, EvalSym inputs, ExtractSym inputs, ConfigurableSolver config handle, SymEq inputs) => config -> inputs -> (Either e v -> CEGISCondition) -> t -> IO ([Model], CEGISResult SolvingFailure) Source #
CEGIS for symbolic programs with error handling, with a forall variable.
See cegisForAll
and cegisExcept
.
cegisForAllExceptStdVC :: forall t (u :: Type -> Type) inputs config handle. (UnionWithExcept t u VerificationConditions (), PlainUnion u, Monad u, EvalSym inputs, ExtractSym inputs, ConfigurableSolver config handle, SymEq inputs) => config -> inputs -> t -> IO ([Model], CEGISResult SolvingFailure) Source #
CEGIS for symbolic programs with error handling, with a forall variable.
See cegisForAll
and cegisExceptStdVC
.
cegisForAllExceptVC :: (UnionWithExcept t u e v, PlainUnion u, Monad u, EvalSym inputs, ExtractSym inputs, ConfigurableSolver config handle, SymEq inputs) => config -> inputs -> (Either e v -> u (Either VerificationConditions ())) -> t -> IO ([Model], CEGISResult SolvingFailure) Source #
CEGIS for symbolic programs with error handling, with a forall variable.
See cegisForAll
and cegisExceptVC
.