Expand description
clingo-rs

Rust bindings to the clingo library. Clingo version 5.5.0.
Requirements
- a c++14 conforming compiler
Per default the crate uses the clingo library via dynamic linking.
It is assumed that a clingo dynamic library is installed on the system.
You have to set the environment variable CLINGO_LIBRARY_PATH. For example:
export CLINGO_LIBRARY_PATH=/scratch/miniconda3/envs/test/lib
Examples
cargo run --example=ast 0
cargo run --example=backend 0
cargo run --example=configuration
cargo run --example=control 0
cargo run --example=model 0
cargo run --example=propagator 0
cargo run --example=solve-async 0
cargo run --example=statistics 0
cargo run --example=symbol 0
cargo run --example=symbolic-atoms 0
cargo run --example=theory-atoms 0
cargo run --example=inject-terms 0
cargo run --example=version
Features
Using derive macro
The crate provides a derive macro to help easing the use of rust data types as facts.
In your Cargo.toml add:
[dependencies]
clingo = { version = "0.7.3", features = ["derive"] }
In your source write:
use clingo::ToSymbol;
use clingo::ClingoError;
use clingo::FactBase;
#[derive(ToSymbol)]
struct MyPoint {
x: i32,
y: i32,
}
let p = MyPoint{ x:4, y:2 };
let fb = FactBase::new();
fb.insert(p);The macro performs a conversion to snake case. This means the corresponing fact for MyPoint{x:4,y:2} is my_point(4,2).
Using static-linking
You can use the clingo library via static linking.
The recommended way to use the optional static linking support is as follows.
[dependencies]
clingo = { version = "0.7.3", features = ["static-linking"] }
Contribution
How to make a contribution to clingo-rs?
Any contribution intentionally submitted for inclusion in the work by you, shall be licensed under the terms of the MIT license without any additional terms or conditions.
Modules
- Functions and data structures to work with program ASTs.
Structs
- Represents a (partial) assignment of a particular solver.
- Unsigned integer type used for aspif atoms.
- Handle to the backend to add directives in aspif format.
- Handle for the solver configuration.
- Bit flags describing the entries of a configuration.
- Control object holding grounding and solving state.
- Search handle to a solve call.
- Unsigned integer type used in various places.
- Represents a model.
- Object to add command-line options.
- Struct used to specify the program parts that have to be grounded.
- This object can be used to add clauses and propagate literals while solving.
- Object to initialize a user-defined propagator before each solving step.
- Bit flags to select symbols in models.
- Represents a predicate signature.
- Object to add clauses during search.
- Bit flags describing solve modes.
- Bit flags that describes the result of a solve call.
- Signed integer type used for solver literals.
- Handle for to the solver statistics.
- Represents a symbol.
- A symbolic atom in a program.
- Container that stores symbolic atoms in a program – the relevant Herbrand base gringo uses to instantiate programs.
- An iterator over symbolic atoms.
- Container that stores theory atoms, elements, and terms of a program.
- Iterator over theory atoms.
- A Literal with an associated weight.
Enums
- Enumeration of clause types determining the lifetime of a clause.
- ClingoError in the rust wrapper, like null pointers or failed matches of C enums.
- Enumeration of clingo error codes for
ClingoError::InternalError. - Enumeration of clingo error types See: set_error()
- Enumeration of different external statements.
- Enumeration of different heuristic modifiers.
- Enumeration for the different model types.
- Supported check modes for propagators. Note that total checks are subject to the lock when a model is found. This means that information from previously found models can be used to discard assignments in check calls.
- Enumeration of solve events.
- Enumeration for entries of the statistics.
- Enumeration of available symbol types.
- Enumeration of theory term types.
- Represents three-valued truth values.
- Enumeration of warning codes.
- Enumeration of weight_constraint_types.
Traits
- An instance of this struct has to be registered with a solver to observe ground directives as they are passed to the solver.
- An instance of this trait has to be registered with a solver to implement a custom logging.
- An instance of this trait has to be registered with a solver to implement a custom propagator.
- helper types and traits to simplify conversion from structs to clingo symbols
Functions
- Internalize a string.
- Create a new control object.
- Create a new control object.
- Parse a term in string form.
- Parse a term in string form.
- Set an error code and message in the active thread.
- Obtain the clingo version.