Documentation

Cvc.Untyped.Synth

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.

structure Cvc.Untyped.Solver.EnvSolvedT [Ω] (solver : Solver) (m : Type → Type) (α : Type) :

Code running where the solver last found a synthesis solution.

Instances For
    @[instance_reducible]
    instance Cvc.Untyped.Solver.EnvSolvedT.instMonad [Ω] {m✝ : Type → Type} {s✝ : Solver} [Monad m✝] :
    Monad (s✝.EnvSolvedT m✝)
    Equations
    • One or more equations did not get rendered due to their size.
    @[reducible, inline]

    Code running where the solver last found a synthesis solution.

    Equations
    Instances For
      def Cvc.Untyped.Solver.EnvSolvedT.throw [Ω] {α✝ : Type} {m✝ : Type → Type} [Monad m✝] {s✝ : Solver} :
      Error → s✝.EnvSolvedT m✝ α✝

      Fails with e.

      Equations
      Instances For
        def Cvc.Untyped.Solver.EnvSolvedT.pure [Ω] {α✝ : Type} {m✝ : Type → Type} [Monad m✝] {s✝ : Solver} :
        α✝ → s✝.EnvSolvedT m✝ α✝

        Returns a.

        Equations
        Instances For
          def Cvc.Untyped.Solver.EnvSolvedT.bind [Ω] {α✝ β✝ : Type} {m✝ : Type → Type} [Monad m✝] {s✝ : Solver} :
          s✝.EnvSolvedT m✝ α✝ → (α✝ → s✝.EnvSolvedT m✝ β✝) → s✝.EnvSolvedT m✝ β✝

          Runs a, then f on its result.

          Equations
          Instances For
            def Cvc.Untyped.Solver.EnvSolvedT.tryCatch [Ω] {α✝ : Type} {m✝ : Type → Type} [Monad m✝] {s✝ : Solver} :
            s✝.EnvSolvedT m✝ α✝ → (Error → s✝.EnvSolvedT m✝ α✝) → s✝.EnvSolvedT m✝ α✝

            Runs code, handing any error it fails with to errorDo.

            Equations
            Instances For
              @[instance_reducible]
              instance Cvc.Untyped.Solver.EnvSolvedT.instMonadLift [Ω] {m✝ : Type → Type} [Monad m✝] {s✝ : Solver} :
              MonadLift m✝ (s✝.EnvSolvedT m✝)
              Equations
              structure Cvc.Untyped.Solver.EnvUnsolvableT [Ω] (solver : Solver) (m : Type → Type) (α : Type) :

              Code running where the solver last showed the synthesis conjecture has no solution.

              Instances For
                def Cvc.Untyped.Solver.EnvUnsolvableT.pure [Ω] {α✝ : Type} {m✝ : Type → Type} [Monad m✝] {s✝ : Solver} :
                α✝ → s✝.EnvUnsolvableT m✝ α✝

                Returns a.

                Equations
                Instances For
                  @[instance_reducible]
                  Equations
                  • One or more equations did not get rendered due to their size.
                  @[instance_reducible]
                  instance Cvc.Untyped.Solver.EnvUnsolvableT.instMonad [Ω] {m✝ : Type → Type} {s✝ : Solver} [Monad m✝] :
                  Monad (s✝.EnvUnsolvableT m✝)
                  Equations
                  • One or more equations did not get rendered due to their size.
                  def Cvc.Untyped.Solver.EnvUnsolvableT.tryCatch [Ω] {α✝ : Type} {m✝ : Type → Type} [Monad m✝] {s✝ : Solver} :
                  s✝.EnvUnsolvableT m✝ α✝ → (Error → s✝.EnvUnsolvableT m✝ α✝) → s✝.EnvUnsolvableT m✝ α✝

                  Runs code, handing any error it fails with to errorDo.

                  Equations
                  Instances For
                    def Cvc.Untyped.Solver.EnvUnsolvableT.throw [Ω] {α✝ : Type} {m✝ : Type → Type} [Monad m✝] {s✝ : Solver} :
                    Error → s✝.EnvUnsolvableT m✝ α✝

                    Fails with e.

                    Equations
                    Instances For
                      def Cvc.Untyped.Solver.EnvUnsolvableT.bind [Ω] {α✝ β✝ : Type} {m✝ : Type → Type} [Monad m✝] {s✝ : Solver} :
                      s✝.EnvUnsolvableT m✝ α✝ → (α✝ → s✝.EnvUnsolvableT m✝ β✝) → s✝.EnvUnsolvableT m✝ β✝

                      Runs a, then f on its result.

                      Equations
                      Instances For
                        @[reducible, inline]

                        Code running where the solver last showed the synthesis conjecture has no solution.

                        Equations
                        Instances For
                          structure Cvc.Untyped.Solver.EnvSynthUnknownT [Ω] (solver : Solver) (m : Type → Type) (α : Type) :

                          Code running where the solver last gave up on a synthesis conjecture.

                          Instances For
                            @[instance_reducible]
                            instance Cvc.Untyped.Solver.EnvSynthUnknownT.instMonad [Ω] {m✝ : Type → Type} {s✝ : Solver} [Monad m✝] :
                            Equations
                            • One or more equations did not get rendered due to their size.
                            def Cvc.Untyped.Solver.EnvSynthUnknownT.bind [Ω] {α✝ β✝ : Type} {m✝ : Type → Type} [Monad m✝] {s✝ : Solver} :
                            s✝.EnvSynthUnknownT m✝ α✝ → (α✝ → s✝.EnvSynthUnknownT m✝ β✝) → s✝.EnvSynthUnknownT m✝ β✝

                            Runs a, then f on its result.

                            Equations
                            Instances For
                              @[reducible, inline]

                              Code running where the solver last gave up on a synthesis conjecture.

                              Equations
                              Instances For
                                @[instance_reducible]
                                Equations
                                • One or more equations did not get rendered due to their size.
                                def Cvc.Untyped.Solver.EnvSynthUnknownT.tryCatch [Ω] {α✝ : Type} {m✝ : Type → Type} [Monad m✝] {s✝ : Solver} :
                                s✝.EnvSynthUnknownT m✝ α✝ → (Error → s✝.EnvSynthUnknownT m✝ α✝) → s✝.EnvSynthUnknownT m✝ α✝

                                Runs code, handing any error it fails with to errorDo.

                                Equations
                                Instances For
                                  def Cvc.Untyped.Solver.EnvSynthUnknownT.throw [Ω] {α✝ : Type} {m✝ : Type → Type} [Monad m✝] {s✝ : Solver} :
                                  Error → s✝.EnvSynthUnknownT m✝ α✝

                                  Fails with e.

                                  Equations
                                  Instances For
                                    def Cvc.Untyped.Solver.EnvSynthUnknownT.pure [Ω] {α✝ : Type} {m✝ : Type → Type} [Monad m✝] {s✝ : Solver} :
                                    α✝ → s✝.EnvSynthUnknownT m✝ α✝

                                    Returns a.

                                    Equations
                                    Instances For

                                      What a synthesis check answered #

                                      The outcome of a synthesis check.

                                      Equations
                                      Instances For

                                        A string representation of this synthesis result.

                                        Equations
                                        Instances For

                                          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
                                                    Instances For
                                                      def Cvc.Untyped.Solver.synthFun [Ω] (s : Solver) (symbol : String) (boundVars : BVars) (srt : Srt) (grammar : Option Grammar := none) :

                                                      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

                                                          Adds a formula the synthesized functions may assume.

                                                          Equations
                                                          Instances For
                                                            def Cvc.Untyped.Solver.addSygusInvConstraint [Ω] (s : Solver) (inv pre trans post : Term) :

                                                            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
                                                            Instances For

                                                              Rejecting an unexpected answer #

                                                              What a synthesis branch falls back on when the caller did not expect that answer.

                                                              def Cvc.Untyped.Solver.unexpectedSolved [Ω] (s : Solver) (dumpConstraints : Bool := false) {α : Type} :

                                                              Fails because a solution was unexpected.

                                                              Equations
                                                              Instances For
                                                                def Cvc.Untyped.Solver.unexpectedUnsolvable [Ω] (s : Solver) (dumpConstraints : Bool := false) {α : Type} :

                                                                Fails because having no solution was unexpected.

                                                                Equations
                                                                Instances For
                                                                  def Cvc.Untyped.Solver.unexpectedSynthUnknown [Ω] (s : Solver) (dumpConstraints : Bool := false) {α : Type} :

                                                                  Fails because the solver giving up was unexpected.

                                                                  Equations
                                                                  Instances For

                                                                    Checking a synthesis conjecture #

                                                                    def Cvc.Untyped.Solver.checkSynth {m : Type → Type} [Ω] [Monad m] [MonadLiftT BaseIO m] (s : Solver) {α : Type} (ifSolved : s.EnvSolvedT m α := liftM (s.unexpectedSolved false)) (ifUnsolvable : s.EnvUnsolvableT m α := liftM (s.unexpectedUnsolvable false)) (ifUnknown : s.EnvSynthUnknownT m α := liftM (s.unexpectedSynthUnknown false)) :
                                                                    EnvT m α

                                                                    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
                                                                      def Cvc.Untyped.Solver.checkSynthNext {m : Type → Type} [Ω] [Monad m] [MonadLiftT BaseIO m] (s : Solver) {α : Type} (ifSolved : s.EnvSolvedT m α := liftM (s.unexpectedSolved false)) (ifUnsolvable : s.EnvUnsolvableT m α := liftM (s.unexpectedUnsolvable false)) (ifUnknown : s.EnvSynthUnknownT m α := liftM (s.unexpectedSynthUnknown false)) :
                                                                      s.EnvSolvedT m α

                                                                      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
                                                                        def Cvc.Untyped.Solver.checkSynth? {m : Type → Type} [Ω] [Monad m] [MonadLiftT BaseIO m] {α : Type} (s : Solver) (ifSolved : s.EnvSolvedT m (Option α) := pure none) (ifUnsolvable : s.EnvUnsolvableT m (Option α) := pure none) (ifUnknown : s.EnvSynthUnknownT m (Option α) := liftM (s.unexpectedSynthUnknown false)) :
                                                                        EnvT m (Option α)

                                                                        checkSynth, whose solved and unsolvable branches default to none.

                                                                        An unknown answer still fails, as with checkSat?.

                                                                        Equations
                                                                        Instances For

                                                                          Where a solution was found #

                                                                          The solution found for fn, a function synthFun declared.

                                                                          Equations
                                                                          Instances For

                                                                            The solution found for fn, a function synthFun declared.

                                                                            Equations
                                                                            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
                                                                                Instances For

                                                                                  Enumerates the next term of interest, none if cvc5 finds none.

                                                                                  Continues the enumeration the last findSynth or findSynthNext started.

                                                                                  Equations
                                                                                  Instances For

                                                                                    findSynthNext, failing rather than answering none.

                                                                                    Equations
                                                                                    Instances For

                                                                                      Declares some identifiers as sygus-variables in solver.

                                                                                      Equations
                                                                                      • One or more equations did not get rendered due to their size.
                                                                                      Instances For
                                                                                        def Cvc.Untyped.Symbols.Sig.Idents.declareSygusAtIn {S : Sig} [Symbols S] [Ω] (k : Nat) (solver : Solver) (idents : S.Idents) :
                                                                                        Env (S.TermsAt k)

                                                                                        Declares some identifiers as sygus-variables in solver, named for step k.

                                                                                        Equations
                                                                                        • One or more equations did not get rendered due to their size.
                                                                                        Instances For