https://github.com/hriener/behemoth
C++ library for syntax-guided enumeration and synthesis
https://github.com/hriener/behemoth
enumeration syntax-guided-synthesis
Last synced: about 2 months ago
JSON representation
C++ library for syntax-guided enumeration and synthesis
- Host: GitHub
- URL: https://github.com/hriener/behemoth
- Owner: hriener
- License: mit
- Created: 2018-03-21T17:39:45.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-15T11:12:57.000Z (almost 7 years ago)
- Last Synced: 2025-02-03T22:39:09.948Z (4 months ago)
- Topics: enumeration, syntax-guided-synthesis
- Language: C++
- Homepage:
- Size: 95.7 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# behemoth
![]()
behemoth is a C++ library for syntax-guided enumeration and synthesis.## Example
The following code snippet enumerates expressions over a simple grammar with the two function symbols `not(.)` and `and(.,.)`.
```c++
#includebehemoth::context ctx;
expr_printer printer( ctx );/* symbols */
const auto _N = ctx.make_fun( "_N" );
const auto _not = ctx.make_fun( "not", { _N },
expr_attr_enum::_no_double_application );
const auto _and = ctx.make_fun( "and", { _N, _N },
expr_attr_enum::_idempotent | expr_attr_enum::_commutative );/* grammar rules */
std::vector rules;
rules.push_back( rule_t{ _N, _not, /* cost = */0u } );
rules.push_back( rule_t{ _N, _and } );
for ( auto i = 0; i < /* num_variables = */ 3; ++i )
{
const auto v = ctx.make_fun( fmt::format( "x{}", i ) );
rules.push_back( rule_t{ _N, v } );
}/* enumerate expressions up to cost bound 5 */
enumerator en( ctx, printer, rules, /* cost bound = */ 5 );
en.add_expression( _N );
while ( en.is_running() )
{
en.deduce();
}
en.print_statistics();
```