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.
What an Env threads: the scope's term manager and the sorts declared in it.
- tm : cvc5.TermManager
- declaredSorts : Std.HashMap String cvc5.Sort
Instances For
Equations
- code.bind f = { runOn := fun (state : ST.Ref IO.RealWorld Cvc.State) => do let a ← Cvc.EnvT.runOn✝ code state Cvc.EnvT.runOn✝ (f a) state }
Instances For
Equations
- Cvc.EnvT.liftBaseIO code = { runOn := fun (x : ST.Ref IO.RealWorld Cvc.State) => liftM code }
Instances For
Equations
- Cvc.EnvT.instMonadLiftBaseIOOfMonadLiftT = { monadLift := fun {α : Type} => Cvc.EnvT.liftBaseIO }
Equations
- Cvc.EnvT.instMonadLiftIOOfMonadLiftTBaseIO = { monadLift := fun {α : Type} => Cvc.EnvT.liftIO }
Equations
- Cvc.EnvT.liftEnv code = { runOn := monadLift ∘ Cvc.EnvT.runOn✝ code }
Instances For
Equations
- Cvc.EnvT.instMonadLiftEnvOfMonadLiftTBaseIO = { monadLift := fun {α : Type} => Cvc.EnvT.liftEnv }
Equations
- Cvc.EnvT.liftResT a? = { runOn := fun (_state : ST.Ref IO.RealWorld Cvc.State) => a? }
Instances For
Equations
- Cvc.EnvT.instMonadLiftResT = { monadLift := fun {α : Type} => Cvc.EnvT.liftResT }
Equations
- code.tryCatch errorDo = { runOn := fun (state : ST.Ref IO.RealWorld Cvc.State) => tryCatch (Cvc.EnvT.runOn✝ code state) fun (e : Cvc.Error) => Cvc.EnvT.runOn✝ (errorDo e) state }
Instances For
Equations
- Cvc.EnvT.instMonadExceptOfError = { throw := fun {α : Type} => Cvc.EnvT.throw, tryCatch := fun {α : Type} => Cvc.EnvT.tryCatch }
Equations
- Cvc.EnvT.instInhabited = { default := Cvc.throwInternal "`Inhabited` witness" }
Equations
- Cvc.EnvT.instInhabitedEnv = { default := Cvc.EnvT.instInhabitedEnv._aux_1 }
Equations
- Cvc.Env.liftBaseIO code = Cvc.EnvT.liftBaseIO code
Instances For
Equations
- Cvc.Env.instMonadLiftBaseIO = { monadLift := fun {α : Type} => Cvc.Env.liftBaseIO }
Equations
- Cvc.Env.liftIO code = Cvc.EnvT.liftIO code
Instances For
Equations
- Cvc.Env.instMonadLiftIO = { monadLift := fun {α : Type} => Cvc.Env.liftIO }
Equations
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
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
- Cvc.Env.run code = Cvc.EnvT.run fun [Cvc.Ω] => code
Instances For
Env.run, raising an error as an IO exception.
Equations
- Cvc.Env.runIO code = do let __do_lift ← liftM (Cvc.Env.run fun [Cvc.Ω] => code) match __do_lift with | Except.ok a => pure a | Except.error e => throw (IO.Error.userError e.toString)