Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding large-step encoding for CHCs in CProver (no [required] changes to the solver) #8465

Open
wants to merge 26 commits into
base: develop
Choose a base branch
from

Conversation

yvizel
Copy link

@yvizel yvizel commented Sep 22, 2024

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bunch of comments that each apply in several more places. More generally, however, it would be great to have comments. At bare minimum there should be high-level design comments in some place that explain how the various pieces fit together. Also, we need tests that demonstrate the new feature.

src/cprover/cprover_parse_options.h Outdated Show resolved Hide resolved
src/cprover/chc_db.cpp Outdated Show resolved Hide resolved
src/cprover/chc_db.cpp Outdated Show resolved Hide resolved
src/cprover/chc_db.cpp Outdated Show resolved Hide resolved
m_head_idx[func].insert(&r);

std::vector<symbol_exprt> use;
r.used_relations(*this,std::back_inserter(use));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest that used_relations just return a std::vector<symbol_exprt> (which is cheap with copy elision).

src/cprover/cutpoint_graph.h Outdated Show resolved Hide resolved
src/cprover/cutpoint_graph.h Outdated Show resolved Hide resolved
src/cprover/cutpoint_graph.h Outdated Show resolved Hide resolved
@qinheping qinheping self-assigned this Oct 28, 2024
@yvizel yvizel requested a review from tautschnig October 29, 2024 12:01
Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. clang-format fixes are strictly required.
  2. A bunch of suggestions below. Would be great to see them addressed, but we can do this in parallel with reviewing/working on the solver changes.

@@ -0,0 +1,9 @@
KNOWNBUG
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applies to this one as well as all other KNOWNBUG tests that you added: could you please add at the bottom:

--
Brief explanation as to what the bug is.

That is, add another -- and then an explanatory text.

chc_dbt::chc_sett chc_dbt::m_empty_set;
std::unordered_set<exprt, irep_hash> chc_grapht::m_expr_empty_set;

void horn_clauset::used_relations(chc_dbt &db, std::vector<symbol_exprt> & out) const
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll want to run clang-format (or, rather, git-clang-format) to ensure all use of whitespace is in line with the repository rules.

Comment on lines +66 to +67
std::vector<symbol_exprt> use;
r.used_relations(*this, use);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change the signature of used_relations such that this becomes std::vector<symbol_exprt> use = r.used_relations(*this);. That is, return by value.

Comment on lines +31 to +35
if (can_cast_expr<function_application_exprt>(expr))
{
const function_application_exprt & f = to_function_application_expr(expr);
funcs.insert(f);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (can_cast_expr<function_application_exprt>(expr))
{
const function_application_exprt & f = to_function_application_expr(expr);
funcs.insert(f);
}
if (auto f = expr_try_dynamic_cast<function_application_exprt>(expr))
{
funcs.insert(*f);
}

forall_exprt m_chc;

public:
horn_clauset(forall_exprt f) : m_chc(f) {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qualify this with explicit

@@ -277,6 +277,7 @@ int cprover_parse_optionst::main()

solver_options.trace = cmdline.isset("trace");
solver_options.verbose = cmdline.isset("verbose");
solver_options.large_step = cmdline.isset("large-step");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a help entry (in cprover_parse_optionst::help at the bottom of this file).

Comment on lines +8 to +9
#include <iostream>
#include <fstream>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are either of those really required?

Comment on lines +11 to +15
cutpoint_grapht::~cutpoint_grapht() {
m_edges.clear();
m_cps.clear();
m_insts.clear();
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the explicit deconstruction required?

Comment on lines +1280 to +1281
container_encoding_targett container2;
std::vector<horn_clauset> all2;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are those good for?

Comment on lines +1243 to +1248
if (!can_cast_expr<forall_exprt>(clause))
{
throw incorrect_goto_program_exceptiont("Not forall");
}
const forall_exprt& forall = to_forall_expr(clause);
db.add_clause(forall);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rewrite this using expr_try_dynamic_cast instead of can_cast_expr.

@tautschnig
Copy link
Collaborator

Also, once done with the changes, please rebase/combine all commits into a single one. (Or perhaps one for the source changes and one for the tests.)

@tautschnig tautschnig assigned yvizel and unassigned tautschnig and qinheping Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants