Documentation

Cvc.Basic.Env

Scopes and the environment monad #

cvc5 creates sorts, terms and solvers through a term manager, and objects of two managers must never meet. This library hides term managers behind the class Ω: an instance stands for "the term manager of the current scope", and nearly every type and function takes one implicitly.

Work happens in the Env monad (EnvT for another base monad), and Env.run/Env.runIO run it in a fresh scope. As with runST, nothing mentioning the scope can escape the run, and two scopes' sorts and terms cannot be mixed, nested runs included.

class Cvc.Ω :

The current scope: an instance stands for one term manager.

Only Env.run and its variants make one, so a sort, term or solver cannot leave the run it was made in, nor meet one made in another run, nested runs included.

Instances
    structure Cvc.State :

    What an Env threads: the scope's term manager and the sorts declared in it.

    Instances For
      structure Cvc.EnvT [Ω] (m : Type → Type) (α : Type) :

      The environment monad transformer.

      Instances For
        def Cvc.Env [Ω] (α : Type) :

        The environment monad.

        Equations
        Instances For
          def Cvc.EnvT.pure {m : Type → Type} [Ω] [M : Monad m] {α : Type} (a : α) :
          EnvT m α
          Equations
          Instances For
            def Cvc.EnvT.bind {m : Type → Type} [Ω] [M : Monad m] {α β : Type} (code : EnvT m α) (f : α → EnvT m β) :
            EnvT m β
            Equations
            Instances For
              @[instance_reducible]
              instance Cvc.EnvT.instMonad {m : Type → Type} [Ω] [M : Monad m] :
              Equations
              • One or more equations did not get rendered due to their size.
              def Cvc.EnvT.liftBaseIO {m : Type → Type} [Ω] [M : Monad m] {α : Type} [MonadLiftT BaseIO m] (code : BaseIO α) :
              EnvT m α
              Equations
              Instances For
                @[instance_reducible]
                Equations
                def Cvc.EnvT.liftIO {m : Type → Type} [Ω] [M : Monad m] {α : Type} [MonadLiftT BaseIO m] (code : IO α) :
                EnvT m α
                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  @[instance_reducible]
                  Equations
                  def Cvc.EnvT.liftEnv {m : Type → Type} [Ω] {α : Type} [L : MonadLiftT BaseIO m] (code : Env α) :
                  EnvT m α
                  Equations
                  Instances For
                    def Cvc.EnvT.liftResT {m : Type → Type} [Ω] {α : Type} (a? : ResT m α) :
                    EnvT m α
                    Equations
                    Instances For
                      @[instance_reducible]
                      instance Cvc.EnvT.instMonadLiftResT {m : Type → Type} [Ω] :
                      Equations
                      def Cvc.EnvT.throw {m : Type → Type} [Ω] [M : Monad m] {α : Type} (e : Error) :
                      EnvT m α
                      Equations
                      Instances For
                        def Cvc.EnvT.tryCatch {m : Type → Type} [Ω] [M : Monad m] {α : Type} (code : EnvT m α) (errorDo : Error → EnvT m α) :
                        EnvT m α
                        Equations
                        Instances For
                          @[instance_reducible]
                          Equations
                          @[instance_reducible]
                          instance Cvc.EnvT.instInhabited {m : Type → Type} [Ω] [M : Monad m] {α : Type} :
                          Equations
                          @[instance_reducible]
                          Equations
                          def Cvc.Env.liftBaseIO [Ω] {α : Type} (code : BaseIO α) :
                          Env α
                          Equations
                          Instances For
                            @[instance_reducible]
                            Equations
                            def Cvc.Env.liftIO [Ω] {α : Type} (code : IO α) :
                            Env α
                            Equations
                            Instances For
                              @[instance_reducible]
                              Equations
                              @[instance_reducible]
                              Equations
                              @[instance_reducible]
                              Equations
                              def Cvc.EnvT.run {m : Type → Type} {α : Type} [Monad m] [MonadLiftT BaseIO m] (code : [inst : Ω] → EnvT m α) :
                              m (Res α)

                              Runs code in a fresh scope, with a term manager of its own, answering its result or error.

                              α is chosen outside the scope, so nothing mentioning the scope can escape the run.

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                def Cvc.Env.run {α : Type} (code : [inst : Ω] → Env α) :
                                BaseIO (Res α)

                                Runs code in a fresh scope, with a term manager of its own, answering its result or error.

                                α is chosen outside the scope, so nothing mentioning the scope can escape the run.

                                Equations
                                Instances For
                                  def Cvc.Env.runIO {α : Type} (code : [inst : Ω] → Env α) :
                                  IO α

                                  Env.run, raising an error as an IO exception.

                                  Equations
                                  Instances For