Clingo
Loading...
Searching...
No Matches
grounder.hh
1#pragma once
2
3#include <clingo/control/context.hh>
4#include <clingo/control/parse.hh>
5
6#include <clingo/input/program.hh>
7
8#include <clingo/core/output.hh>
9
10namespace CppClingo::Control {
11
14
22
26class Grounder {
27 public:
28 Grounder(Grounder const &) = delete;
29 Grounder(Grounder &&) = delete;
30 auto operator=(Grounder const &) -> Grounder & = delete;
31 auto operator=(Grounder &&) -> Grounder & = delete;
32
33 struct Impl;
36 OutputStm &out);
38 ~Grounder() noexcept;
40 void join(Input::UnprocessedProgram const &prg);
42 auto parse(std::string_view str, Ground::ScriptExec *code = nullptr, ProgramBackend *prg = nullptr,
43 TheoryBackend *thy = nullptr) -> BuiltinIncludes;
45 auto parse(std::span<std::string_view const> const &files, Ground::ScriptExec *code = nullptr,
46 ProgramBackend *prg = nullptr, TheoryBackend *thy = nullptr) -> BuiltinIncludes;
48 void add_const(String name, Symbol value);
50 auto const_map() -> Input::ConstMap const &;
52 void mark_unsat();
54 [[nodiscard]] auto ground(ProgramParamVec const &params, Ground::ScriptCallback *context = nullptr,
55 Util::StopFlag *stop = nullptr) -> GroundResult;
57 void print_summary(bool final);
59 void accept(Ground::ProfileNode::Visitor const &visit) const;
60
62 void output_unprocessed_program(std::ostream &out);
64 void output_program(std::ostream &out);
66 void show(Input::SharedSig const &sig);
68 void mark_sig(Input::Sig const &sig);
69
71 [[nodiscard]] auto get_parts() -> std::optional<Input::StmParts> const &;
73 void set_parts(std::optional<Input::StmParts> parts);
75 [[nodiscard]] auto base() -> Ground::Bases &;
77 [[nodiscard]] auto base() const -> Ground::Bases const &;
79 [[nodiscard]] auto store() const -> SymbolStore &;
81 [[nodiscard]] auto log() const -> Logger &;
82
83 private:
85 void prepare_();
86
87 std::unique_ptr<Impl> impl_;
88};
89
91
92} // namespace CppClingo::Control
A grounder for logic programs.
Definition grounder.hh:26
void accept(Ground::ProfileNode::Visitor const &visit) const
Accept a visitor for the profile nodes.
void join(Input::UnprocessedProgram const &prg)
Join with the given program.
void output_unprocessed_program(std::ostream &out)
Output the current unprocessed program.
~Grounder() noexcept
Destroy grounder.
auto store() const -> SymbolStore &
Get the contained symbol store.
auto base() -> Ground::Bases &
Get the associated base.
void mark_unsat()
Mark the current program as unsatisfiable.
void show(Input::SharedSig const &sig)
Show the given signature.
void print_summary(bool final)
Print per step summaries.
void mark_sig(Input::Sig const &sig)
Mark the given signature as defined.
void add_const(String name, Symbol value)
Define a constant.
void output_program(std::ostream &out)
Output the current program.
auto log() const -> Logger &
Get the contained logger.
auto const_map() -> Input::ConstMap const &
Get the const map.
auto get_parts() -> std::optional< Input::StmParts > const &
Get the program parts to ground.
Grounder(Logger &log, SymbolStore &store, Input::RewriteOptions const &opts, GroundOptions const &gopts, OutputStm &out)
Create a grounder object.
void set_parts(std::optional< Input::StmParts > parts)
Set the program parts to ground.
Simple logger to report message to stderr or via a callback.
Definition logger.hh:63
Interface to output statements.
Definition output.hh:82
Abstract class connecting grounder and solver.
Definition backend.hh:56
Reference to a string stored in a symbol store.
Definition symbol.hh:18
A store for symbols.
Definition symbol.hh:454
Variant-like class to store symbols stored in a symbol store.
Definition symbol.hh:225
Abstract class connecting grounder and theory data.
Definition backend.hh:234
BuiltinIncludes
Bitset of enabled builtin includes.
Definition parse.hh:23
@ parse
Stop processing after parsing.
@ ground
Stop processing after grounding.
GroundResult
Available grounding results.
Definition core.hh:187
EstimateSelector
Selector for which estimates to consider.
Definition core.hh:204
EstimateFunction
Function to combine domain size estimates.
Definition core.hh:197
@ pred
Only consider predicates.
@ average
Use the average of the estimates.
Options to fine-tune the grounding process.
Definition grounder.hh:16
EstimateFunction fun
Function to combine estimates for recursive domains.
Definition grounder.hh:18
EstimateSelector sel
Selector to choose what kind of literals to use for recursive domains.
Definition grounder.hh:20
Options to configure rewriting.
Definition program.hh:38