Documentation

cvc5.Init

DSL for definition DRY #

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

                      Defines similar functions realized by extern.

                      extern! in "prefix"
                        /-- Create a Boolean constant.
                      
                        - `b`: The Boolean constant.
                      
                        Will create an opaque definition with `[@extern extStr]` where
                        `extStr = "prefix" ++ "_" ++ "myFunction"`.
                        -/
                        def myFunction : Term → Except Error Op
                        with!?
                          endsWithBang!
                          endWithQuestion?
                        with
                          myOtherFunction : Term → Op :=
                            Error.unwrap! ∘ myFunction
                          /-- Optional function docstring: if none, inherit from the main function. -/
                          yetAnotherFunction : Term → Option Op :=
                            Except.toOption ∘ myFunction
                      
                      • in "prefix" is optional; if none, then the prefix will be the (last component of the) name of the current namespace with the first letter lowercased. Fails if the current namespace has no components.

                      • with ...: takes a sequence of identifiers, each generate a function that

                        • unwraps the result if !-ended, which generates code similar to myOtherFunction above;
                        • turns a result into an option if ?-ended, which generates code similar to yetAnotherFunction above;
                        • fails otherwise.

                        The with ... syntax is currently only compatible with external functions that produce Except Error α values.

                      • Supports declModifiers on the main (def) function myFunction such as private.

                      • Accepts a list of external (def) functions, each with its with clauses.

                      This macro can generate optional (?) and panic (!) wrappers even more automatically.

                      extern! "prefix"
                        /-- Create a Boolean constant.
                      
                        - `b`: The Boolean constant.
                      
                        Will create an opaque definition with `[@extern extStr]` where
                        `extStr = "prefix" ++ "_" ++ "myFunction"`.
                        -/
                        def !? myFunction : Term → Except Error Op
                        with
                          myOtherFunction : Term → Op :=
                            myFunction!
                          /-- Optional function docstring: if none, inherit from the main function. -/
                          yetAnotherFunction : Term → Option Op :=
                            myFunction?
                      

                      Notice the !? between def and myFunction. This generates myFunction! and myFunction? which respectively panic-unwrap errors and turn the Except into an Option. In other words, it is the same as (and internally turned into) a with!? myFunction! myFunction? clause using the first syntax above.

                      Besides !?, the following are also supported:

                      • ?!: same behavior as !?;
                      • !: only generate the panic unwrapper;
                      • ?: only generate the Option unwrapper.
                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For

                        Defines similar functions realized by extern.

                        extern! in "prefix"
                          /-- Create a Boolean constant.
                        
                          - `b`: The Boolean constant.
                        
                          Will create an opaque definition with `[@extern extStr]` where
                          `extStr = "prefix" ++ "_" ++ "myFunction"`.
                          -/
                          def myFunction : Term → Except Error Op
                          with!?
                            endsWithBang!
                            endWithQuestion?
                          with
                            myOtherFunction : Term → Op :=
                              Error.unwrap! ∘ myFunction
                            /-- Optional function docstring: if none, inherit from the main function. -/
                            yetAnotherFunction : Term → Option Op :=
                              Except.toOption ∘ myFunction
                        
                        • in "prefix" is optional; if none, then the prefix will be the (last component of the) name of the current namespace with the first letter lowercased. Fails if the current namespace has no components.

                        • with ...: takes a sequence of identifiers, each generate a function that

                          • unwraps the result if !-ended, which generates code similar to myOtherFunction above;
                          • turns a result into an option if ?-ended, which generates code similar to yetAnotherFunction above;
                          • fails otherwise.

                          The with ... syntax is currently only compatible with external functions that produce Except Error α values.

                        • Supports declModifiers on the main (def) function myFunction such as private.

                        • Accepts a list of external (def) functions, each with its with clauses.

                        This macro can generate optional (?) and panic (!) wrappers even more automatically.

                        extern! "prefix"
                          /-- Create a Boolean constant.
                        
                          - `b`: The Boolean constant.
                        
                          Will create an opaque definition with `[@extern extStr]` where
                          `extStr = "prefix" ++ "_" ++ "myFunction"`.
                          -/
                          def !? myFunction : Term → Except Error Op
                          with
                            myOtherFunction : Term → Op :=
                              myFunction!
                            /-- Optional function docstring: if none, inherit from the main function. -/
                            yetAnotherFunction : Term → Option Op :=
                              myFunction?
                        

                        Notice the !? between def and myFunction. This generates myFunction! and myFunction? which respectively panic-unwrap errors and turn the Except into an Option. In other words, it is the same as (and internally turned into) a with!? myFunction! myFunction? clause using the first syntax above.

                        Besides !?, the following are also supported:

                        • ?!: same behavior as !?;
                        • !: only generate the panic unwrapper;
                        • ?: only generate the Option unwrapper.
                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For

                            Defines an external, opaque function with optional helpers.

                            /-- Some documentation. -/
                            extern_def!? in "prefix" myFunction : Term → Except Error Op
                            

                            Generates an opaque definition

                            /-- Some documentation. -/
                            @[extern "prefix_myFunction"]
                            def myFunction : Term → Except Error Op
                            
                            • in "prefix" is optional, uses the current namespace with first letter lowercased if none.

                            • extern_def!? also defines myFunction! : Term → Op and myFunction? : Term → Option Op in terms of myFunction.

                              Other variants exist:

                              • extern_def?!: same as extern_def!?;
                              • extern_def?: only defines myFunction?;
                              • extern_def!: only defines myFunction!;
                              • extern_def: defines nothing besides myFunction.
                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For

                              Defines an external, opaque function with optional helpers.

                              /-- Some documentation. -/
                              extern_def!? in "prefix" myFunction : Term → Except Error Op
                              

                              Generates an opaque definition

                              /-- Some documentation. -/
                              @[extern "prefix_myFunction"]
                              def myFunction : Term → Except Error Op
                              
                              • in "prefix" is optional, uses the current namespace with first letter lowercased if none.

                              • extern_def!? also defines myFunction! : Term → Op and myFunction? : Term → Option Op in terms of myFunction.

                                Other variants exist:

                                • extern_def?!: same as extern_def!?;
                                • extern_def?: only defines myFunction?;
                                • extern_def!: only defines myFunction!;
                                • extern_def: defines nothing besides myFunction.
                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For