Syntax-guided synthesis, sort-erased #
Where checkSat asks whether constraints can be satisfied, checkSynth asks for a function that
satisfies them for every input. The shape of that function is what a Grammar restricts.
The pieces fit together in one order: set the sygus option (s.setOption "sygus" "true"),
declare the universally quantified variables with declareSygusVar, declare the functions to
synthesize with synthFun, constrain them with addSygusConstraint, then checkSynth and read
each function back with getSynthSolution. findSynth is the other entry point — it enumerates
terms of interest rather than solving a conjecture.
Synthesis-mode monadic environments #
A synthesis check splits the world in three, as a check-sat does: a solution can be read only
where one was found. As for the sat monads, only checkSynth enters these, and each is indexed by
the solver that answered, so a solution cannot be read off another solver.
Equations
- One or more equations did not get rendered due to their size.
Code running where the solver last found a synthesis solution.
Equations
- s✝.EnvSolved = s✝.EnvSolvedT BaseIO
Instances For
Equations
- Cvc.Untyped.Solver.EnvSolvedT.instMonadExceptError = { throw := fun {α : Type} => Cvc.Untyped.Solver.EnvSolvedT.throw, tryCatch := fun {α : Type} => Cvc.Untyped.Solver.EnvSolvedT.tryCatch }
Fails with e.
Equations
- Cvc.Untyped.Solver.EnvSolvedT.throw e✝ = { toEnv := throw e✝ }
Instances For
Equations
Returns a.
Equations
- Cvc.Untyped.Solver.EnvSolvedT.pure a✝ = { toEnv := pure a✝ }
Instances For
Equations
- Cvc.Untyped.Solver.EnvSolvedT.instMonadLiftIOOfMonadLiftTBaseIO = { monadLift := fun {α : Type} => Cvc.Untyped.Solver.EnvSolvedT.liftIO✝ }
Runs a, then f on its result.
Equations
- a✝.bind f✝ = { toEnv := (Cvc.Untyped.Solver.EnvSolvedT.toEnv✝ a✝).bind fun (a : α✝) => Cvc.Untyped.Solver.EnvSolvedT.toEnv✝ (f✝ a) }
Instances For
Runs code, handing any error it fails with to errorDo.
Equations
- code✝.tryCatch errorDo✝ = { toEnv := (Cvc.Untyped.Solver.EnvSolvedT.toEnv✝ code✝).tryCatch fun (e : Cvc.Error) => Cvc.Untyped.Solver.EnvSolvedT.toEnv✝ (errorDo✝ e) }
Instances For
Equations
- Cvc.Untyped.Solver.EnvSolvedT.instMonadLift = { monadLift := fun {α : Type} => Cvc.Untyped.Solver.EnvSolvedT.transformLift✝ }
Returns a.
Equations
- Cvc.Untyped.Solver.EnvUnsolvableT.pure a✝ = { toEnv := pure a✝ }
Instances For
Equations
Equations
- Cvc.Untyped.Solver.EnvUnsolvableT.instMonadLift = { monadLift := fun {α : Type} => Cvc.Untyped.Solver.EnvUnsolvableT.transformLift✝ }
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Runs code, handing any error it fails with to errorDo.
Equations
- code✝.tryCatch errorDo✝ = { toEnv := (Cvc.Untyped.Solver.EnvUnsolvableT.toEnv✝ code✝).tryCatch fun (e : Cvc.Error) => Cvc.Untyped.Solver.EnvUnsolvableT.toEnv✝ (errorDo✝ e) }
Instances For
Fails with e.
Equations
- Cvc.Untyped.Solver.EnvUnsolvableT.throw e✝ = { toEnv := throw e✝ }
Instances For
Runs a, then f on its result.
Equations
- a✝.bind f✝ = { toEnv := (Cvc.Untyped.Solver.EnvUnsolvableT.toEnv✝ a✝).bind fun (a : α✝) => Cvc.Untyped.Solver.EnvUnsolvableT.toEnv✝ (f✝ a) }
Instances For
Equations
- Cvc.Untyped.Solver.EnvUnsolvableT.instMonadLiftIOOfMonadLiftTBaseIO = { monadLift := fun {α : Type} => Cvc.Untyped.Solver.EnvUnsolvableT.liftIO✝ }
Code running where the solver last showed the synthesis conjecture has no solution.
Equations
- s✝.EnvUnsolvable = s✝.EnvUnsolvableT BaseIO
Instances For
Equations
- Cvc.Untyped.Solver.EnvSynthUnknownT.instMonadLift = { monadLift := fun {α : Type} => Cvc.Untyped.Solver.EnvSynthUnknownT.transformLift✝ }
Equations
- One or more equations did not get rendered due to their size.
Runs a, then f on its result.
Equations
- a✝.bind f✝ = { toEnv := (Cvc.Untyped.Solver.EnvSynthUnknownT.toEnv✝ a✝).bind fun (a : α✝) => Cvc.Untyped.Solver.EnvSynthUnknownT.toEnv✝ (f✝ a) }
Instances For
Code running where the solver last gave up on a synthesis conjecture.
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Runs code, handing any error it fails with to errorDo.
Equations
- code✝.tryCatch errorDo✝ = { toEnv := (Cvc.Untyped.Solver.EnvSynthUnknownT.toEnv✝ code✝).tryCatch fun (e : Cvc.Error) => Cvc.Untyped.Solver.EnvSynthUnknownT.toEnv✝ (errorDo✝ e) }
Instances For
Equations
Fails with e.
Equations
- Cvc.Untyped.Solver.EnvSynthUnknownT.throw e✝ = { toEnv := throw e✝ }
Instances For
Returns a.
Equations
- Cvc.Untyped.Solver.EnvSynthUnknownT.pure a✝ = { toEnv := pure a✝ }
Instances For
Equations
- Cvc.Untyped.Solver.EnvSynthUnknownT.instMonadLiftIOOfMonadLiftTBaseIO = { monadLift := fun {α : Type} => Cvc.Untyped.Solver.EnvSynthUnknownT.liftIO✝ }
What a synthesis check answered #
The outcome of a synthesis check.
Equations
Instances For
A string representation of this synthesis result.
Equations
Instances For
Equations
True if the synthesis query has a solution.
Equations
Instances For
True if the synthesis query has no solution. In this case, it was determined that there was no solution.
Equations
Instances For
True if the result of the synthesis query could not be determined.
Equations
Instances For
Whether a solution was found, or none if the solver could not tell.
The three-way answer of Result.isSat?, at synthesis: some true if a solution exists and was
found, some false if the conjecture has none, none if the solver gave up.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Whether a solution was found, failing if the solver gave up.
Equations
Instances For
Driving synthesis #
Declares a universally quantified variable of the given sort.
Equations
- s.declareSygusVar symbol srt = Cvc.runUnsafe'✝ ((Cvc.Untyped.Solver.toUnsafe✝ s).declareSygusVar symbol (Cvc.Srt.toUnsafe✝ srt))
Instances For
Declares a function to synthesize.
boundVars are the function's parameters and srt its codomain. A grammar restricts the shape
of the candidates; without one, any term of the right sort is allowed. The grammar must have been
built over these very parameters.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Adds a formula the synthesized functions must satisfy.
Equations
Instances For
The constraints added so far.
Equations
Instances For
Adds a formula the synthesized functions may assume.
Equations
Instances For
The assumptions added so far.
Equations
Instances For
Constrains inv to be an inductive invariant of the transition system.
pre must imply inv, inv must be preserved by trans, and inv must imply post.
Equations
- s.addSygusInvConstraint inv pre trans post = Cvc.runUnsafe'✝ ((Cvc.Untyped.Solver.toUnsafe✝ s).addSygusInvConstraint inv pre trans post)
Instances For
Rejecting an unexpected answer #
What a synthesis branch falls back on when the caller did not expect that answer.
Fails because a solution was unexpected.
Equations
- s.unexpectedSolved dumpConstraints = liftM (Cvc.Untyped.Solver.unexpectedSynth✝ s "solved" dumpConstraints)
Instances For
Fails because having no solution was unexpected.
Equations
- s.unexpectedUnsolvable dumpConstraints = liftM (Cvc.Untyped.Solver.unexpectedSynth✝ s "unsolvable" dumpConstraints)
Instances For
Fails because the solver giving up was unexpected.
Equations
- s.unexpectedSynthUnknown dumpConstraints = liftM (Cvc.Untyped.Solver.unexpectedSynth✝ s "unknown" dumpConstraints)
Instances For
Checking a synthesis conjecture #
Tries to solve the synthesis conjecture, as a raw result.
Equations
Instances For
Tries to find another solution, as a raw result.
Equations
Instances For
Tries to solve the synthesis conjecture, and runs the branch matching the answer.
A branch left out fails if its answer comes; getSynthSolution is available in ifSolved.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Tries to find another solution to the synthesis conjecture, with checkSynth's branches.
Only possible where a solution was already found.
Equations
- One or more equations did not get rendered due to their size.
Instances For
checkSynth, whose solved and unsolvable branches default to none.
An unknown answer still fails, as with checkSat?.
Equations
- s.checkSynth? ifSolved ifUnsolvable ifUnknown = s.checkSynth ifSolved ifUnsolvable ifUnknown
Instances For
Where a solution was found #
The solution found for fn, a function synthFun declared.
Equations
- s.getSynthSolution fn = liftM (Cvc.runUnsafe'✝ ((Cvc.Untyped.Solver.toUnsafe✝ s).getSynthSolution fn))
Instances For
The solution found for fn, a function synthFun declared.
Equations
- s.getSynthSolutions fns = liftM (Cvc.runUnsafe'✝ ((Cvc.Untyped.Solver.toUnsafe✝ s).getSynthSolutions fns))
Instances For
Enumerates a term of interest, rather than solving a conjecture, none if cvc5 finds none.
A grammar restricts what may be enumerated; without one, the last synthFun's grammar is used,
and cvc5 refuses if it had none.
Equations
- One or more equations did not get rendered due to their size.
Instances For
findSynth, failing rather than answering none.
Equations
- s.findSynth! target grammar = s.findSynth target grammar >>= Cvc.someOrThrowUser "cvc5 found no term of interest"
Instances For
Enumerates the next term of interest, none if cvc5 finds none.
Continues the enumeration the last findSynth or findSynthNext started.
Equations
- s.findSynthNext = Cvc.runUnsafe'✝ do let t ← (Cvc.Untyped.Solver.toUnsafe✝ s).findSynthNext pure (if t.isNull = true then none else some t)
Instances For
findSynthNext, failing rather than answering none.
Equations
- s.findSynthNext! = s.findSynthNext >>= Cvc.someOrThrowUser "cvc5 found no further term of interest"