dlinear  0.0.1
Delta-complete SMT solver for linear programming
Loading...
Searching...
No Matches
FunctionDefinition.h
1
11#pragma once
12
13#include <concepts>
14#include <cstddef>
15#include <vector>
16
17#include "dlinear/parser/vnnlib/Sort.h"
18#include "dlinear/parser/vnnlib/Term.h"
19#include "dlinear/symbolic/literal.h"
20
21namespace dlinear::vnnlib {
22
41 public:
50 FunctionDefinition(std::vector<Variable> parameters, Sort return_type, Term body);
51
57 Term operator()(const std::vector<Term>& arguments) const;
63 Term operator()(std::same_as<Term> auto... arguments) const {
64 if (parameters_.size() != sizeof...(arguments)) {
65 throw std::runtime_error("This function definition expects #" + std::to_string(parameters_.size()) +
66 " arguments ({}). Provided #" + std::to_string(sizeof...(arguments)) + " arguments.");
67 }
68 Term t = body_;
69
70 std::size_t i = 0;
71 for (const Term& arg_i : {arguments...}) {
72 const Variable& param_i{parameters_[i]};
73 arg_i.Check(param_i.get_type());
74 t = t.Substitute(param_i, arg_i);
75 ++i;
76 }
77
78 return t;
79 }
80
81 private:
82 std::vector<Variable> parameters_;
85};
86
87} // namespace dlinear::vnnlib
Represents a symbolic variable.
A new function defined by the user in the VNNLIB language using the define-fun command.
Term operator()(const std::vector< Term > &arguments) const
Call the function with the given arguments.
FunctionDefinition(std::vector< Variable > parameters, Sort return_type, Term body)
Construct a new function definition.
Sort return_type_
Return type of the function.
std::vector< Variable > parameters_
Parameters of the function.
Term operator()(std::same_as< Term > auto... arguments) const
Call the function with the given arguments.
Generic term that can be either an expression or a formula.
Definition Term.h:34
Term Substitute(const Variable &v, const Term &t)
Create a new Term with substitutes the variable v in this term with t.
Definition Term.cpp:41
Namespace for the VNNLIB parser of the dlinear library.
Definition Driver.cpp:17
Sort
Sort of a term.
Definition Sort.h:18