From d6ba7cf0576dce669375c288c0494219c2b80869 Mon Sep 17 00:00:00 2001 From: Yakir Vizel Date: Mon, 16 Sep 2024 09:55:42 +0300 Subject: [PATCH 01/20] Adding CHCs data structures and utilities for resolution-based large step encoding --- src/cprover/chc_db.cpp | 76 ++++++++ src/cprover/chc_db.h | 231 ++++++++++++++++++++++ src/cprover/chc_large_step.h | 341 +++++++++++++++++++++++++++++++++ src/cprover/chc_wto.h | 301 +++++++++++++++++++++++++++++ src/cprover/cutpoint_graph.cpp | 251 ++++++++++++++++++++++++ src/cprover/cutpoint_graph.h | 169 ++++++++++++++++ 6 files changed, 1369 insertions(+) create mode 100644 src/cprover/chc_db.cpp create mode 100644 src/cprover/chc_db.h create mode 100644 src/cprover/chc_large_step.h create mode 100644 src/cprover/chc_wto.h create mode 100644 src/cprover/cutpoint_graph.cpp create mode 100644 src/cprover/cutpoint_graph.h diff --git a/src/cprover/chc_db.cpp b/src/cprover/chc_db.cpp new file mode 100644 index 00000000000..8a8cb6fcbcb --- /dev/null +++ b/src/cprover/chc_db.cpp @@ -0,0 +1,76 @@ +// +// Created by Yakir Vizel on 5/27/24. +// + +#include "chc_db.h" + +#include + +chc_db::chc_sett chc_db::m_empty_set; +std::set chc_graph::m_expr_empty_set; + +void chc_db::reset_indices() +{ + m_body_idx.clear(); + m_head_idx.clear(); +} + +void chc_db::build_indices() +{ + reset_indices(); + + for (auto &r: m_clauses) { + if (!can_cast_expr(*r.head())) + { + continue; + } + exprt func = to_function_application_expr(*r.head()).function(); + m_head_idx[func].insert(&r); + + std::vector use; + r.used_relations(*this,std::back_inserter(use)); + for (auto & symb : use) + { + m_body_idx[symb].insert(&r); + } + } +} + +void chc_graph::build_graph() +{ + m_db.build_indices(); + + for (auto & sp : m_db.get_state_preds()) + { + std::set outgoing; + const std::set &uses = m_db.use(sp); + for (const horn_clause *r : uses) { + const exprt * head = r->head(); + if (can_cast_expr(*head)) + { + outgoing.insert(to_function_application_expr(*head).function()); + } + } + m_outgoing.insert(std::make_pair(sp, outgoing)); + + std::set incoming; + const std::set &defs = m_db.def(sp); + chc_db::is_state_pred isStatePred(m_db); + for (const horn_clause *r : defs) { + std::set symbols = find_symbols(*r->body()); + for (auto & s : symbols) + if (isStatePred(s)) + incoming.insert(s); + } + m_incoming.insert(std::make_pair(sp, incoming)); + } + + for (auto & sp : m_db.get_state_preds()) { + std::string name = as_string(sp.get_identifier()); + + if (name.find("SInitial") != std::string::npos && incoming(sp).size() == 0) { + m_entry = &sp; + break; + } + } +} diff --git a/src/cprover/chc_db.h b/src/cprover/chc_db.h new file mode 100644 index 00000000000..76e3082cc77 --- /dev/null +++ b/src/cprover/chc_db.h @@ -0,0 +1,231 @@ +// +// Created by Yakir Vizel on 5/27/24. +// + +#ifndef CBMC_CHC_DB_H +#define CBMC_CHC_DB_H + +#include +#include +#include +#include + +#include +#include +#include +#include + +class chc_db; +class horn_clause +{ + forall_exprt m_chc; + +public: + horn_clause(forall_exprt f) : m_chc(f) {} + + horn_clause(std::vector & vars, exprt clause) : m_chc(vars, clause) { + + } + + const forall_exprt & get_chc() const + { + return m_chc; + } + + const exprt* body() const { + if (can_cast_expr(m_chc.where())) + { + return &to_implies_expr(m_chc.where()).op0(); + } + return &m_chc.where(); + } + + const exprt* head() const { + if (can_cast_expr(m_chc.where())) + { + return &to_implies_expr(m_chc.where()).op1(); + } + return nullptr; + } + + bool is_fact() const { + auto b = body(); + bool not_fact = false; + b->visit_pre( + [¬_fact](const exprt &expr) { + if(can_cast_expr(expr)) + { + not_fact = true; + } + }); + return !not_fact; + } + + bool is_query() const { + if (can_cast_expr(m_chc.where())) + { + auto h = head(); + bool res = true; + h->visit_pre( + [&res](const exprt &expr) { + if(can_cast_expr(expr)) + res = false; + }); + return res; + } + return false; + } + + template + void used_relations(chc_db &db, OutputIterator out) const; + template + void used_func_app(chc_db &db, OutputIterator out) const; +}; + +/* + * A database of CHCs. + * Uninterpreted relations need to be registered. + */ +class chc_db +{ + friend class horn_clause; +public: + struct is_state_pred : public std::__unary_function { + const chc_db &m_db; + is_state_pred(const chc_db &db) : m_db(db) {} + + bool operator()(symbol_exprt state) { return m_db.has_state_pred(state); } + }; + +private: + using chcst = std::vector; + chcst m_clauses; + + std::set m_state_preds; + + typedef std::set chc_sett; + typedef std::map> chc_indext; + chc_indext m_body_idx; + chc_indext m_head_idx; + + // representing the empty set + static chc_sett m_empty_set; + +public: + chc_db() {} + + void add_state_pred(const symbol_exprt & state) { m_state_preds.insert(state); } + const std::set &get_state_preds() { return m_state_preds; } + bool has_state_pred(const symbol_exprt & state) const { return m_state_preds.count(state) > 0; } + + void build_indices(); + void reset_indices(); + + const std::set & use(const exprt & state) const { + auto it = m_body_idx.find(state); + if (it == m_body_idx.end()) + return m_empty_set; + return it->second; + } + + const std::set & def(const exprt & state) const { + auto it = m_head_idx.find(state); + if (it == m_head_idx.end()) + return m_empty_set; + return it->second; + } + + void add_clause(const forall_exprt & f) + { + if (f.is_true()) + return; + m_clauses.push_back(horn_clause(f)); + reset_indices(); + } + + chcst::iterator begin() { return m_clauses.begin(); } + chcst::iterator end() { return m_clauses.end(); } + chcst::const_iterator begin() const { return m_clauses.begin(); } + chcst::const_iterator end() const { return m_clauses.end(); } +}; + +template +void horn_clause::used_relations(chc_db &db, OutputIterator out) const +{ + const exprt *body = this->body(); + if (body == nullptr) return; + std::set symbols = find_symbols(*body); + + chc_db::is_state_pred filter(db); + for (auto & symb : symbols) { + if (filter(symb)) { + *out = symb; + } + } +} + +template +void horn_clause::used_func_app(chc_db &db, OutputIterator out) const +{ + const exprt *body = this->body(); + if (body == nullptr) return; + + std::set funcs; + body->visit_pre([&funcs](const exprt &expr) { + if (can_cast_expr(expr)) + { + const function_application_exprt & f = to_function_application_expr(expr); + funcs.insert(f); + } + }); + + chc_db::is_state_pred filter(db); + for (auto & f : funcs) { + if (filter(to_symbol_expr(f.function()))) { + *out = f; + } + } +} + +/* + * The CHC dependency graph. + * Uninterpreted relations are vertices, dependency is based on clauses: + * relations in the body have an edge to the relation in the head. + */ +class chc_graph +{ + chc_db & m_db; + typedef std::map> grapht; + grapht m_incoming; + grapht m_outgoing; + const symbol_exprt *m_entry; + + // representing the empty set + static std::set m_expr_empty_set; + +public: + chc_graph(chc_db & db) : m_db(db), m_entry(nullptr) {} + + void build_graph(); + + bool has_entry() const { return m_entry != nullptr; } + const symbol_exprt *entry() const { + INVARIANT(has_entry(), "Entry must exist."); + return m_entry; } + + const std::set &outgoing(const symbol_exprt &state) const { + auto it = m_outgoing.find(state); + if (it == m_outgoing.end()) + return m_expr_empty_set; + return it->second; + } + + const std::set &incoming(const symbol_exprt &state) const { + auto it = m_incoming.find(state); + if (it == m_incoming.end()) + return m_expr_empty_set; + return it->second; + } +}; + +#endif //CBMC_CHC_DB_H diff --git a/src/cprover/chc_large_step.h b/src/cprover/chc_large_step.h new file mode 100644 index 00000000000..a27e72a8ef5 --- /dev/null +++ b/src/cprover/chc_large_step.h @@ -0,0 +1,341 @@ +// +// Created by Yakir Vizel on 7/23/24. +// + +#ifndef CBMC_CHC_LARGE_STEP_H +#define CBMC_CHC_LARGE_STEP_H + +#include "chc_wto.h" +#include +#include + +class ResolutionVisitor : public wto_element_visitort +{ +private: + chc_db & m_db; + chc_db m_new_db; + std::unordered_map> m_def; + std::set m_heads; + + unsigned m_id; + +public: + ResolutionVisitor(chc_db & db) : m_db(db), m_id(0) {} + + virtual void visit(const wto_singletont & s) + { + const symbol_exprt* symb = s.get(); + resolve(symb); + } + + virtual void visit(const wto_componentt & comp) + { + const symbol_exprt* head = comp.head(); + m_heads.insert(head->hash()); + std::string str = head->get_identifier().c_str(); + std::cout << "Head: " << str << "\n"; + for (auto it = comp.begin(); it != comp.end(); it++) + { + it->get()->accept(this); + } + resolve(head); + } + + std::vector getClauses() + { + std::vector all; + for (auto it = m_heads.begin(); it != m_heads.end(); it++) + { + auto c = m_def.find(*it); + INVARIANT(c != m_def.end(), "No clauses"); + all.insert(all.begin(), c->second.begin(), c->second.end()); + } + return all; + } + + const std::vector& getClauses(const symbol_exprt* symb) + { + auto it = m_def.find(symb->hash()); + INVARIANT(it != m_def.end(), "No clauses"); + return it->second; + } + +private: + void resolve(const symbol_exprt *symb) + { + for (auto clause : m_db.def(*symb)) + { + std::vector use; + if (false) + { + std::cout << "Clause: " << format(clause->get_chc()) << "\n"; + } + clause->used_relations(m_db,std::back_inserter(use)); + if (use.size() > 1) { + throw incorrect_goto_program_exceptiont("Non-linear CHCs not supported yet"); + } + + if (clause->is_fact()) + { + m_heads.insert(symb->hash()); + std::vector def_chcs; + def_chcs.push_back(clause->get_chc()); + m_def.insert(std::make_pair(symb->hash(), def_chcs)); + } + + for (auto & p : use) + { + auto it = m_def.find(p.hash()); + std::vector def_chcs; + if (it == m_def.end() || m_heads.find(p.hash()) != m_heads.end()) + { + def_chcs.push_back(*clause); + } + else + { + for (auto cls_it = it->second.begin(); cls_it != it->second.end(); cls_it++) + { + forall_exprt resolvent = resolve_cls2((*cls_it), *clause); + if (false) + std::cout << "Result where:\n" << format(resolvent) << "\n"; + def_chcs.push_back(resolvent); + } + } + auto def_it = m_def.find(symb->hash()); + if (def_it == m_def.end()) + m_def.insert(std::make_pair(symb->hash(), def_chcs)); + else + { + auto & vec = def_it->second; + vec.insert(vec.end(), def_chcs.begin(), def_chcs.end()); + } + } + } + } + + forall_exprt resolve_cls(const horn_clause & c1, const horn_clause & c2) + { + const exprt &body1 = *c1.body(); + const exprt &head1 = *c1.head(); + const exprt &body2 = *c2.body(); + const exprt &head2 = *c2.head(); + + std::vector use2; + c2.used_func_app(m_db,std::back_inserter(use2)); + + INVARIANT(use2.size() == 1, "Only handling linear case"); + if (use2.size() != 1) + throw analysis_exceptiont("Resolution not possible"); + + function_application_exprt & body2_pred = use2[0]; + + const function_application_exprt *head1_pred = nullptr; + if (can_cast_expr(*c1.head())) + { + head1_pred = &to_function_application_expr(head1); + } + if (head1_pred == nullptr) + throw analysis_exceptiont("Resolution not possible"); + + if (false) + std::cout << "Resolving: \n" << format(c1.get_chc()) << "\nAnd: \n" + << format(c2.get_chc()) << "\n"; + + std::set all_vars(c1.get_chc().variables().begin(), c1.get_chc().variables().end()); + all_vars.insert(c2.get_chc().variables().begin(), c2.get_chc().variables().end()); + + const function_application_exprt *body1_pred = nullptr; + exprt::operandst body_ops; + if (body1.id() == ID_and) + { + body1_pred = &to_function_application_expr(to_and_expr(body1).op0()); + body_ops.push_back(to_and_expr(body1).op1()); + } + else + { + body1_pred = &to_function_application_expr(body1); + } + exprt transformed_body = (can_cast_expr(body2)) ? to_and_expr(body2).op1() : true_exprt(); + exprt transformed_head = head2; + for (unsigned i=0; i < head1_pred->arguments().size(); i++) + { + const exprt &head_arg = head1_pred->arguments().at(i); + const symbol_exprt & body_arg = to_symbol_expr(body2_pred.arguments().at(i)); + if ((head_arg.id() != ID_symbol) || + (to_symbol_expr(head_arg).get_identifier() != body_arg.get_identifier())) + { + //std::cout << "body arg: " << format(body_arg) << " head arg: " << format(head_arg) << "\n"; + std::string name = as_string(body_arg.get_identifier()); + name = name + "__n" + std::to_string(m_id++); + symbol_exprt v(name, head_arg.type()); + equal_exprt eq(v, head_arg); + std::cout << format(eq) << "\n"; + all_vars.insert(v); + body_ops.push_back(eq); + + std::map subs; + subs.insert(std::make_pair(body_arg.get_identifier(), v)); + + if (!transformed_body.is_true()) { + std::optional s = substitute_symbols(subs, transformed_body); + if (s.has_value()) + transformed_body = std::move(s.value()); + } + if (can_cast_expr(body2)) { + //std::cout << "Body 2: " << format(to_and_expr(body2).op1()) << "\n"; + std::optional s = substitute_symbols(subs, to_and_expr(body2).op1()); + if (s.has_value()) + { + //std::cout << "Body 2 after: " << format(s.value()) << "\n"; + body_ops.push_back(std::move(s.value())); + } + } + + std::optional s = substitute_symbols(subs, transformed_head); + if (s.has_value()) + { + transformed_head = std::move(s.value()); + } + } + } + + if (body_ops.empty()) { + transformed_body = *body1_pred; + } + else + { + transformed_body = and_exprt( + *body1_pred, ((body_ops.size() > 1) ? std::move(and_exprt(body_ops)) : std::move(body_ops[0]))); + } + + forall_exprt f(std::vector(all_vars.begin(), all_vars.end()), + implies_exprt(std::move(transformed_body), std::move(transformed_head))); + return f; + } + + forall_exprt resolve_cls2(const horn_clause & c1, const horn_clause & c2) + { + const exprt &body1 = *c1.body(); + const exprt &head1 = *c1.head(); + const exprt &body2 = *c2.body(); + const exprt &head2 = *c2.head(); + + std::vector use2; + c2.used_func_app(m_db,std::back_inserter(use2)); + + INVARIANT(use2.size() == 1, "Only handling linear case"); + if (use2.size() != 1) + throw analysis_exceptiont("Resolution not possible"); + + function_application_exprt & body2_pred = use2[0]; + + const function_application_exprt *head1_pred = nullptr; + if (can_cast_expr(*c1.head())) + { + head1_pred = &to_function_application_expr(head1); + } + if (head1_pred == nullptr) + throw analysis_exceptiont("Resolution not possible"); + + if (false) + std::cout << "Resolving: \n" << format(c1.get_chc()) << "\nAnd: \n" + << format(c2.get_chc()) << "\n"; + + std::set all_vars(c1.get_chc().variables().begin(), c1.get_chc().variables().end()); + all_vars.insert(c2.get_chc().variables().begin(), c2.get_chc().variables().end()); + + const function_application_exprt *body1_pred = nullptr; + exprt::operandst body_ops; + if (body1.id() == ID_and) + { + body1_pred = &to_function_application_expr(to_and_expr(body1).op0()); + body_ops.push_back(to_and_expr(body1).op1()); + } + else + { + body1_pred = &to_function_application_expr(body1); + } + exprt transformed_body = (can_cast_expr(body2)) ? to_and_expr(body2).op1() : true_exprt(); + exprt transformed_head = head2; + + INVARIANT(head1_pred->arguments().size() == 1, "Only one argument to predicate is assumes"); + const exprt &head_arg = head1_pred->arguments().at(0); + const symbol_exprt & body_arg = to_symbol_expr(body2_pred.arguments().at(0)); + + if ((head_arg.id() != ID_symbol) || + (to_symbol_expr(head_arg).get_identifier() != body_arg.get_identifier())) + { + //std::cout << "body arg: " << format(body_arg) + // << " head arg: " << format(head_arg) << "\n"; + + std::map subs; + subs.insert(std::make_pair(body_arg.get_identifier(), head_arg)); + + if(!transformed_body.is_true()) + { + std::optional s = substitute_symbols(subs, transformed_body); + if(s.has_value()) + transformed_body = std::move(s.value()); + } + + std::optional s = substitute_symbols(subs, transformed_head); + if (s.has_value()) + { + transformed_head = std::move(s.value()); + } + } + + /*for (unsigned i=0; i < head1_pred->arguments().size(); i++) + { + const exprt &head_arg = head1_pred->arguments().at(i); + const symbol_exprt & body_arg = to_symbol_expr(body2_pred.arguments().at(i)); + if ((head_arg.id() != ID_symbol) || + (to_symbol_expr(head_arg).get_identifier() != body_arg.get_identifier())) + { + std::cout << "body arg: " << format(body_arg) << " head arg: " << format(head_arg) << "\n"; + + std::map subs; + subs.insert(std::make_pair(body_arg.get_identifier(), head_arg)); + + if (!transformed_body.is_true()) { + std::optional s = substitute_symbols(subs, transformed_body); + if (s.has_value()) + transformed_body = std::move(s.value()); + } + if (can_cast_expr(body2)) { + std::cout << "Body 2: " << format(to_and_expr(body2).op1()) << "\n"; + std::optional s = substitute_symbols(subs, to_and_expr(body2).op1()); + if (s.has_value()) + { + std::cout << "Body 2 after: " << format(s.value()) << "\n"; + body_ops.push_back(std::move(s.value())); + } + } + + std::optional s = substitute_symbols(subs, transformed_head); + if (s.has_value()) + { + transformed_head = std::move(s.value()); + } + } + }*/ + + body_ops.push_back(transformed_body); + transformed_body = and_exprt(*body1_pred, std::move(and_exprt(body_ops))); + +// if (body_ops.empty()) { +// transformed_body = *body1_pred; +// } +// else +// { +// transformed_body = and_exprt( +// *body1_pred, ((body_ops.size() > 1) ? std::move(and_exprt(body_ops)) : std::move(body_ops[0]))); +// } + + forall_exprt f(std::vector(all_vars.begin(), all_vars.end()), + implies_exprt(std::move(transformed_body), std::move(transformed_head))); + return f; + } +}; + +#endif //CBMC_CHC_LARGE_STEP_H diff --git a/src/cprover/chc_wto.h b/src/cprover/chc_wto.h new file mode 100644 index 00000000000..32bd3dfc433 --- /dev/null +++ b/src/cprover/chc_wto.h @@ -0,0 +1,301 @@ +// +// Created by Yakir Vizel on 5/28/24. +// + +#ifndef CBMC_CHC_WTO_H +#define CBMC_CHC_WTO_H + +#include "chc_db.h" +#include + +#include +#include +#include +#include +#include + +class wto_singletont; +class wto_componentt; + +class wto_element_visitort +{ +public: + + virtual void visit(const wto_singletont &) = 0; + virtual void visit(const wto_componentt &) = 0; + + virtual ~wto_element_visitort() {} +}; + +class wto_elementt +{ +public: + virtual void accept(wto_element_visitort *) = 0; + + virtual ~wto_elementt() {} +}; + +class wto_singletont : public wto_elementt +{ +private: + const symbol_exprt* m_singleton; + +public: + wto_singletont(const symbol_exprt *e) : m_singleton(e) {} + + const symbol_exprt* get() const { return m_singleton; } + + void accept(wto_element_visitort *v) override { v->visit(*this); } +}; + +class wto_componentt : public wto_elementt +{ + +public: + typedef std::shared_ptr wto_element_ptr; + typedef std::deque wto_components_t; + +private: + const symbol_exprt *m_head; + wto_components_t m_components; + +public: + wto_componentt(const symbol_exprt *head, wto_components_t components) + : m_head(head), m_components(components) {} + + typename wto_components_t::iterator begin() { + return m_components.begin(); + } + + typename wto_components_t::iterator end() { return m_components.end(); } + + typename wto_components_t::const_iterator begin() const { + return m_components.begin(); + } + + typename wto_components_t::const_iterator end() const { + return m_components.end(); + } + + const symbol_exprt* head() const { return m_head; } + + void accept(wto_element_visitort *v) override { v->visit(*this); } +}; + +class chc_wtot +{ +private: + // A helper class to extend an unsigned number with +oo; + class inf_numt + { + std::optional m_n; + + public: + // +oo + inf_numt() : m_n(std::nullopt) { } + inf_numt(unsigned n) : m_n(n) { } + inf_numt(const inf_numt &o) : m_n(o.m_n) { } + + inf_numt &operator=(inf_numt o) + { + m_n = o.m_n; + return *this; + } + + bool is_plus_infinite() const { return m_n == std::nullopt; } + bool is_finite() const { return !is_plus_infinite(); } + + unsigned number() const + { + INVARIANT(is_finite(), "Cannot call number() on infinite"); + return *m_n; + } + + bool operator==(inf_numt o) const + { + if(is_plus_infinite() && o.is_plus_infinite()) + return true; + + if(is_plus_infinite() || o.is_plus_infinite()) + return false; + + return (number() == o.number()); + } + + bool operator<=(inf_numt o) const + { + if(is_plus_infinite() && o.is_plus_infinite()) + return true; + + if(is_plus_infinite()) + return false; + + if(o.is_plus_infinite()) + return true; + + return (number() <= o.number()); + } + }; + + typedef std::shared_ptr wto_element_ptr; + typedef std::deque partition_t; + typedef std::unordered_map> + nested_components_t; + + chc_graph & m_g; + + std::unordered_map m_dfn; + std::vector m_stack; + unsigned m_cur_dfn_num; + + std::deque m_partition; + nested_components_t m_nested_comp; + +private: + // helper to avoid initializing all vertices to zero + inf_numt get_dfn(const symbol_exprt* v) const { + auto it = m_dfn.find(v->hash()); + if (it != m_dfn.end()) + return it->second; + return 0; + } + + std::deque component(const symbol_exprt* v) { + std::deque partition; + for (auto & target : m_g.outgoing(*v)) { + const symbol_exprt* t = (&to_symbol_expr(target)); + if (get_dfn(t) == 0) + visit(t, partition); + } + return partition; + } + + inf_numt visit(const symbol_exprt* v, std::deque &partition) { + std::string name = as_string(v->get_identifier()); + m_stack.push_back(v); + m_dfn[v->hash()] = m_cur_dfn_num++; + auto head = get_dfn(v); + bool loop = false; + for (auto & target : m_g.outgoing(*v)) { + const symbol_exprt* t = (&to_symbol_expr(target)); + auto min = get_dfn(t); + if (min == 0) + min = visit(t, partition); + if (min <= head) { + head = min; + loop = true; + } + } + + if (head == get_dfn(v)) { // v is the head of a component + m_dfn[v->hash()] = inf_numt(); + auto element = m_stack.back(); + m_stack.pop_back(); + if (loop) { + while (!(element == v)) { + m_dfn[element->hash()] = 0; // reset + element = m_stack.back(); + m_stack.pop_back(); + } + partition.push_front(std::static_pointer_cast( + std::make_shared(v, component(v)))); + } else { + partition.push_front(std::static_pointer_cast( + std::make_shared(v))); + } + } + return head; + } + + class nested_components_visitor : public wto_element_visitort + { + std::vector m_nested_components; + nested_components_t &m_nested_components_table; + + public: + nested_components_visitor(nested_components_t &t) + : wto_element_visitort(), m_nested_components_table(t) {} + + virtual void visit(const wto_singletont &s) override { + m_nested_components_table[s.get()->hash()] = m_nested_components; + } + + virtual void visit(const wto_componentt &c) override { + m_nested_components.push_back(c); + m_nested_components_table[c.head()->hash()] = m_nested_components; + for (auto &e : c) { + e->accept(this); + } + m_nested_components.pop_back(); + } + }; + + // build a map from graph vertex to nested components in the wto + void build_nested_components() { + nested_components_visitor vis(m_nested_comp); + for (auto c : m_partition) { + c->accept(&vis); + } + } + +public: + chc_wtot(chc_graph & g) : m_g(g), m_cur_dfn_num(0) {} + + void build_wto() { + if (!m_g.has_entry()) + { + throw incorrect_goto_program_exceptiont("No entry point to CHC"); + } + visit(m_g.entry(), m_partition); + build_nested_components(); + // cleanup + m_stack.clear(); + m_dfn.clear(); + } + + partition_t::iterator begin() { return m_partition.begin(); } + partition_t::iterator end() { return m_partition.end(); } + partition_t::const_iterator begin() const { return m_partition.begin(); } + partition_t::const_iterator end() const { return m_partition.end(); } + + std::vector::iterator nested_comp_begin(symbol_exprt* p) { + return m_nested_comp[p->hash()].begin(); + } + std::vector::iterator nested_comp_end(symbol_exprt* p) { + return m_nested_comp[p->hash()].end(); + } + std::vector::const_iterator nested_comp_begin(symbol_exprt* p) const { + auto it = m_nested_comp.find(p->hash()); + INVARIANT(it != m_nested_comp.end(), "No nested component"); + return it->second.begin(); + } + std::vector::const_iterator nested_comp_end(symbol_exprt* p) const { + auto it = m_nested_comp.find(p->hash()); + INVARIANT(it != m_nested_comp.end(), "No nested component"); + return it->second.end(); + } +}; + +class SimpleVisitor : public wto_element_visitort +{ + virtual void visit(const wto_singletont & s) + { + const symbol_exprt* symb = s.get(); + std::string str = as_string(symb->get_identifier()); + std::cout << str << " "; + } + + virtual void visit(const wto_componentt & comp) + { + const symbol_exprt* head = comp.head(); + std::string str = head->get_identifier().c_str(); + std::cout << "(" << str << " "; + for (auto it = comp.begin(); it != comp.end(); it++) + { + it->get()->accept(this); + } + std::cout << ")" << " "; + } +}; + +#endif //CBMC_CHC_WTO_H diff --git a/src/cprover/cutpoint_graph.cpp b/src/cprover/cutpoint_graph.cpp new file mode 100644 index 00000000000..9159542b564 --- /dev/null +++ b/src/cprover/cutpoint_graph.cpp @@ -0,0 +1,251 @@ +// +// Created by Yakir Vizel on 5/1/24. +// + +#include "cutpoint_graph.h" +#include "language_util.h" + +#include +#include + +cutpoint_graph::~cutpoint_graph() { + m_edges.clear(); + m_cps.clear(); + m_insts.clear(); +} + +void cutpoint_graph::run(const goto_functiont & goto_function) +{ + computeCutpoints (goto_function); + computeFwdReach (goto_function); + computeBwdReach (goto_function); + computeEdges (goto_function); + + toDot(goto_function, "cp.dot"); +} + +void cutpoint_graph::toDot(const goto_functiont & f, std::string filename) +{ + std::ofstream out; + out.open(filename); + out << "digraph G {\n"; + out << "color=black\nfontsize=20" << '\n'; + + const namespacet ns(m_goto_model.symbol_table); + + for (auto cp : m_cps) + { + cp->toDot(out, ns); + } + + for (auto edge : m_edges) + { + out << "Node_" << edge->source().id(); + out << " -> "; + out << "Node_" << edge->target().id(); + std::string label; + for (auto inst : *edge) + { + std::string code; + if (inst->is_assign()) + { + code = from_expr(ns, goto_functionst::entry_point(), inst->code()); + } + label += inst->to_string() +": " + code + "\n"; + } + out << "[fontsize=22,label=\"" << label << "\"];\n"; + } + + + out << "}\n"; + + out.close(); +} + +cutpoint_edge_ptr cutpoint_graph::getEdge(const cutpoint &s, const cutpoint &d) +{ + for (auto it = s.succ_begin (), end = s.succ_end (); it != end; ++it) + { + cutpoint_edge_ptr edg = *it; + if (&(edg->target ()) == &d) return edg; + } + + return nullptr; +} + +const cutpoint_edge_ptr cutpoint_graph::getEdge(const cutpoint &s, const cutpoint &d) const +{ + for (auto it = s.succ_begin (), end = s.succ_end (); it != end; ++it) + { + cutpoint_edge_ptr edg = *it; + if (&(edg->target ()) == &d) return edg; + } + + return nullptr; +} + +void cutpoint_graph::computeEdges (const goto_functiont &goto_function) +{ + forall_goto_program_instructions(it, goto_function.body) + { + if (isCutpoint(*it)) + { + std::vector & reach = m_fwd[&(*it)]; + cutpoint & cp = getCutpoint(*it); + + for (unsigned r = 0; r < reach.size(); r++) + { + if (reach[r] == true) + { + cutpoint_edge_ptr edg = newEdge(cp, *m_cps[r]); + edg->push_back(&(*it)); + } + } + } + else + { + std::vector & breach = m_bwd[&(*it)]; + std::vector & freach = m_fwd[&(*it)]; + + for (int i = 0; i < breach.size(); i++) + { + if (breach[i] == false) continue; + for (int j = 0; j < freach.size(); j++) { + if (freach[j] == false) continue; + cutpoint_edge_ptr edge = getEdge(*m_cps[i], *m_cps[j]); + edge->push_back(&(*it)); + } + } + } + } +} + +void cutpoint_graph::computeCutpoints(const goto_functiont &goto_function) +{ + m_cps.clear(); + + std::map cp_map; + + forall_goto_program_instructions(it, goto_function.body) + { + if (cp_map.find(&*it) != cp_map.end()) continue; + + // entry + if (it->incoming_edges.empty()) + { + auto i = cp_map.find(&*it); + if (i == cp_map.end()) + cp_map.insert(std::make_pair(&*it, cp_map.size())); + } + + // exit + if (it->is_end_function()) + { + auto i = cp_map.find(&*it); + if (i == cp_map.end()) + cp_map.insert(std::make_pair(&*it, cp_map.size())); + } + + for (auto in : it->incoming_edges) + { + auto & inst = *in; + if (inst.is_backwards_goto()) + { + auto i = cp_map.find(&*it); + if (i == cp_map.end()) + cp_map.insert(std::make_pair(&*it, cp_map.size())); + } + } + } + + forall_goto_program_instructions(it, goto_function.body) + { + auto i = cp_map.find(&*it); + if (i == cp_map.end()) continue; + auto inst = i->first; + if (isCutpoint(*inst)) continue; + + m_cps.push_back(std::make_shared(*this, m_cps.size(), *inst)); + m_insts.insert(std::make_pair(inst, m_cps.back())); + } +} + +void cutpoint_graph::computeFwdReach (const goto_functiont &goto_function) +{ + + for (auto it = goto_function.body.instructions.rbegin(); it != goto_function.body.instructions.rend();) + { + auto itf = (++it).base(); + auto succs = goto_function.body.get_successors(itf); + //if (succs.empty()) continue; + auto inst = &*itf; + m_fwd.insert(std::make_pair(inst, reachability())); + reachability &r = m_fwd [inst]; + std::cout << inst->to_string() << "\n"; + if (succs.size() > 1) std::cout << "YAY\n"; + for (auto succ : succs) + { + if (isCutpoint(*succ)) + r.set(getCutpoint(*succ).id()); + else + r |= m_fwd[&*succ]; + + } + } +} + +void cutpoint_graph::computeBwdReach (const goto_functiont &goto_function) +{ + forall_goto_program_instructions(it, goto_function.body) + { + auto inst = &*it; + m_bwd.insert(std::make_pair(inst, reachability())); + reachability &r = m_bwd[inst]; + for(auto pred : it->incoming_edges) + { + if(pred->is_backwards_goto()) + continue; + if(isCutpoint(*pred)) + r.set(getCutpoint(*pred).id()); + else + r |= m_bwd[&*pred]; + + } + } + + for (auto & cp : m_cps) + { + auto & inst = cp->inst(); + reachability &r = m_bwd [&inst]; + + for (auto pred : inst.incoming_edges) + { + if (! pred->is_backwards_goto()) continue; + if (isCutpoint(*pred)) + r.set(getCutpoint(*pred).id()); + else + r |= m_bwd[&*pred]; + } + } +} + +bool cutpoint_graph::isFwdReach(const cutpoint &cp, const goto_programt::instructiont &inst) const +{ + if (&(cp.inst ()) == &inst) return true; + + // The instruction is already a cut-point, but not the one testes. + // It is impossible to reach another cut-point without getting to it + if (isCutpoint(inst)) return false; + + // In case the instruction is not a cut-point, retrieve the backward + // reachability info (cut-point backward reachability) and check if the + // cut-point is backward reachable. If it is, then the instruction + // is forward reachable from the given cp. + auto it = m_bwd.find (&inst); + INVARIANT(it != m_bwd.end (), "No back-reachability information"); + + unsigned sz = it->second.size (); + unsigned id = cp.id (); + if (sz == 0 || id >= sz) return false; + return (it->second)[id]; +} diff --git a/src/cprover/cutpoint_graph.h b/src/cprover/cutpoint_graph.h new file mode 100644 index 00000000000..2ca0ea59fa6 --- /dev/null +++ b/src/cprover/cutpoint_graph.h @@ -0,0 +1,169 @@ +// +// Created by Yakir Vizel on 5/1/24. +// + +#ifndef CBMC_CUTPOINT_GRAPH_H +#define CBMC_CUTPOINT_GRAPH_H + +#include "goto_model.h" +#include + +/** + * A cut-point graph over goto programs. + * The cut-points are: + * 1. Entry node + * 2. Exit node + * 3. Every node that has a back-edge - namely, a loop head. + */ + +class cutpoint_graph; +class cutpoint; + +class cutpoint_edge +{ + friend class cutpoint_graph; + + cutpoint & m_src; + cutpoint & m_dst; + + typedef std::vector InstVec; + InstVec m_insts; + + cutpoint &source() { return m_src; } + cutpoint &target() { return m_dst; } +public: + cutpoint_edge(cutpoint & s, cutpoint & d) : m_src(s), m_dst(d) {} + + const cutpoint_graph& graph() const; + + const cutpoint &source() const { return m_src; } + const cutpoint &target() const { return m_dst; } + + void push_back(const goto_programt::instructiont * inst) + { + m_insts.push_back(inst); + } + + typedef InstVec::iterator iterator; + typedef InstVec::const_iterator const_iterator; + + iterator begin() { return m_insts.begin(); } + iterator end() { return m_insts.end(); } + const_iterator begin() const { return m_insts.begin(); } + const_iterator end() const { return m_insts.end(); } +}; + +typedef std::shared_ptr cutpoint_edge_ptr; + +class cutpoint +{ + friend class cutpoint_graph; + + const cutpoint_graph &m_graph; + unsigned m_id; + const goto_programt::instructiont & m_inst; + + typedef std::vector EdgeVec; + EdgeVec m_succ; + +public: + cutpoint(const cutpoint_graph &p, unsigned id, const goto_programt::instructiont &inst) + : m_graph(p), m_id(id), m_inst(inst) {} + + const cutpoint_graph &graph() const { return m_graph; } + unsigned id() const { return m_id; } + const goto_programt::instructiont &inst() const { return m_inst; } + + void addSucc(cutpoint_edge_ptr & edg) { m_succ.push_back(edg); } + + typedef EdgeVec::const_iterator const_iterator; + typedef EdgeVec::const_reverse_iterator const_reverse_iterator; + + const_iterator succ_begin() const { return m_succ.begin(); } + const_iterator succ_end() const { return m_succ.end(); } + + void toDot(std::ostream & out, const namespacet & ns) + { + out << "Node_" << m_id << " [shape=Mrecord,fontsize=22,label=\""; + out << m_inst.to_string() << "\"];\n"; + } +}; + +class cutpoint_graph +{ + const goto_modelt & m_goto_model; + + typedef std::shared_ptr cutpoint_ptr; + typedef std::vector CutpointVec; + + typedef std::vector EdgeVec; + + CutpointVec m_cps; + EdgeVec m_edges; + + class reachability : public std::vector { + public: + void set(unsigned index) { + if (index >= size()) resize(index+1, false); + (*this)[index] = true; + } + + reachability& operator|=(const reachability & other) { + if (this->size() < other.size()) + this->resize(other.size(), false); + for (unsigned i = 0; i < other.size(); i++) + (*this)[i] = (*this)[i] || other[i]; + return *this; + } + }; + + typedef std::map InstBoolMap; + + InstBoolMap m_fwd; + InstBoolMap m_bwd; + + std::map> m_insts; + + cutpoint_edge_ptr newEdge(cutpoint &s, cutpoint &d) { + m_edges.push_back(std::make_shared(s, d)); + + cutpoint_edge_ptr edg = m_edges.back(); + + s.addSucc(edg); + return edg; + } + + void computeCutpoints(const goto_functiont & goto_function); + void computeFwdReach(const goto_functiont & goto_function); + void computeBwdReach(const goto_functiont & goto_function); + void computeEdges(const goto_functiont & goto_function); + + void toDot(const goto_functiont & f, std::string filename); + +public: + cutpoint_graph(const goto_modelt & goto_model) : m_goto_model(goto_model) {} + ~cutpoint_graph(); + + void run(const goto_functiont & goto_function); + + bool isCutpoint(const goto_programt::instructiont & inst) const + { + return m_insts.count(&inst) > 0; + } + + cutpoint &getCutpoint(const goto_programt::instructiont & inst) const { + INVARIANT(isCutpoint(inst), "Function should be called with a cutpoint"); + return *(m_insts.find(&inst)->second); + } + + cutpoint_edge_ptr getEdge(const cutpoint &s, const cutpoint &d); + const cutpoint_edge_ptr getEdge(const cutpoint &s, const cutpoint &d) const; + + bool isFwdReach(const cutpoint & cp, const goto_programt::instructiont &inst) const; +}; + +inline const cutpoint_graph & cutpoint_edge::graph() const { return m_src.graph(); } + + + +#endif //CBMC_CUTPOINT_GRAPH_H From d390670d4d6d023107a7cc36fc24deb84d7759d0 Mon Sep 17 00:00:00 2001 From: Yakir Vizel Date: Mon, 16 Sep 2024 09:57:42 +0300 Subject: [PATCH 02/20] Enabling large step encoding using a flag --- src/cprover/cprover_parse_options.cpp | 1 + src/cprover/cprover_parse_options.h | 2 + src/cprover/state_encoding.cpp | 81 +++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) diff --git a/src/cprover/cprover_parse_options.cpp b/src/cprover/cprover_parse_options.cpp index c5993023c0b..35dc1435e01 100644 --- a/src/cprover/cprover_parse_options.cpp +++ b/src/cprover/cprover_parse_options.cpp @@ -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"); // solve auto result = state_encoding_solver( diff --git a/src/cprover/cprover_parse_options.h b/src/cprover/cprover_parse_options.h index 3204b20ef6b..a41d9820ae3 100644 --- a/src/cprover/cprover_parse_options.h +++ b/src/cprover/cprover_parse_options.h @@ -25,8 +25,10 @@ Author: Daniel Kroening, dkr@amazon.com "(show-goto-functions)(show-loops)(show-properties)" \ "(show-functions-with-loops)" \ "(validate-goto-model)" \ + "(large-step)" \ "(verbose)" + class cprover_parse_optionst { public: diff --git a/src/cprover/state_encoding.cpp b/src/cprover/state_encoding.cpp index 56ef744c049..18bb8773558 100644 --- a/src/cprover/state_encoding.cpp +++ b/src/cprover/state_encoding.cpp @@ -26,6 +26,8 @@ Author: Daniel Kroening, dkr@amazon.com #include "state_encoding_targets.h" #include "variable_encoding.h" +#include "chc_large_step.h" + #include #include @@ -1233,6 +1235,76 @@ void variable_encoding( } } +void large_step_encoding(const container_encoding_targett & small_step_container, + container_encoding_targett & large_step_container) +{ + chc_db db; + for (auto & clause : small_step_container.constraints) { + if (!can_cast_expr(clause)) + { + throw incorrect_goto_program_exceptiont("Not forall"); + } + const forall_exprt& forall = to_forall_expr(clause); + db.add_clause(forall); + + // For now add every function application as uninterpreted predicate. + std::set symbols; + forall.visit_pre([&symbols](const exprt &expr) { + if (can_cast_expr(expr)) + { + symbol_exprt s = to_symbol_expr(to_function_application_expr(expr).function()); + symbols.insert(s); + } + }); + + for (auto & s : symbols) + { + db.add_state_pred(s); + } + + } + chc_graph chc_g(db); + chc_g.build_graph(); + + chc_wtot wto(chc_g); + wto.build_wto(); + + SimpleVisitor v; + for (auto it = wto.begin(); it != wto.end(); it++) + { + auto x = (*it); + x->accept(&v); + } + + std::cout << "\n"; + + ResolutionVisitor rv(db); + for (auto it = wto.begin(); it != wto.end(); it++) + { + auto x = (*it); + x->accept(&rv); + } + + std::vector all = rv.getClauses(); + for (auto &clause : db) { + if (clause.is_query()) { + std::vector rels; + clause.used_relations(db, std::back_inserter(rels)); + for (auto pred : rels) + { + all.insert(all.end(), rv.getClauses(&pred).begin(), rv.getClauses(&pred).end()); + } + all.push_back(clause.get_chc()); + } + + } + + for (auto ce : all) + { + large_step_container << ce.get_chc(); + } +} + solver_resultt state_encoding_solver( const goto_modelt &goto_model, bool program_is_inlined, @@ -1254,5 +1326,14 @@ solver_resultt state_encoding_solver( } #endif + if (solver_options.large_step) { + container_encoding_targett large_step_container; + large_step_encoding(container, large_step_container); + + std::cout << "Solving large-step\n"; + return solver(large_step_container.constraints, solver_options, ns); + } + + std::cout << "Solving small-step\n"; return solver(container.constraints, solver_options, ns); } From fc597d67d13b123b6ac7eba2816087b77685ddc0 Mon Sep 17 00:00:00 2001 From: Yakir Vizel Date: Sun, 22 Sep 2024 14:15:12 +0300 Subject: [PATCH 03/20] Comparison operators for chcs --- src/cprover/chc_db.cpp | 4 ++-- src/cprover/chc_db.h | 26 ++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/cprover/chc_db.cpp b/src/cprover/chc_db.cpp index 8a8cb6fcbcb..ca8f0311805 100644 --- a/src/cprover/chc_db.cpp +++ b/src/cprover/chc_db.cpp @@ -43,7 +43,7 @@ void chc_graph::build_graph() for (auto & sp : m_db.get_state_preds()) { std::set outgoing; - const std::set &uses = m_db.use(sp); + const std::set &uses = m_db.use(sp); for (const horn_clause *r : uses) { const exprt * head = r->head(); if (can_cast_expr(*head)) @@ -54,7 +54,7 @@ void chc_graph::build_graph() m_outgoing.insert(std::make_pair(sp, outgoing)); std::set incoming; - const std::set &defs = m_db.def(sp); + const std::set &defs = m_db.def(sp); chc_db::is_state_pred isStatePred(m_db); for (const horn_clause *r : defs) { std::set symbols = find_symbols(*r->body()); diff --git a/src/cprover/chc_db.h b/src/cprover/chc_db.h index 76e3082cc77..45ad7afb6f7 100644 --- a/src/cprover/chc_db.h +++ b/src/cprover/chc_db.h @@ -76,6 +76,21 @@ class horn_clause return false; } + bool operator==(const horn_clause &other) const + { + return m_chc == other.m_chc; + } + + bool operator!=(const horn_clause &other) const + { + return !(*this==other); + } + + bool operator<(const horn_clause &other) const + { + return m_chc < other.m_chc; + } + template void used_relations(chc_db &db, OutputIterator out) const; template @@ -103,8 +118,8 @@ class chc_db std::set m_state_preds; - typedef std::set chc_sett; - typedef std::map> chc_indext; + typedef std::set chc_sett; + typedef std::map> chc_indext; chc_indext m_body_idx; chc_indext m_head_idx; @@ -121,14 +136,14 @@ class chc_db void build_indices(); void reset_indices(); - const std::set & use(const exprt & state) const { + const std::set & use(const exprt & state) const { auto it = m_body_idx.find(state); if (it == m_body_idx.end()) return m_empty_set; return it->second; } - const std::set & def(const exprt & state) const { + const std::set & def(const exprt & state) const { auto it = m_head_idx.find(state); if (it == m_head_idx.end()) return m_empty_set; @@ -139,6 +154,9 @@ class chc_db { if (f.is_true()) return; + for (auto & c : m_clauses) { + if (c.get_chc()==f) return; + } m_clauses.push_back(horn_clause(f)); reset_indices(); } From 26f982d3c8201af291720e8e6fd921b5da6439fd Mon Sep 17 00:00:00 2001 From: Yakir Vizel Date: Sun, 22 Sep 2024 14:21:08 +0300 Subject: [PATCH 04/20] Clean up old code --- src/cprover/chc_large_step.h | 144 ----------------------------------- 1 file changed, 144 deletions(-) diff --git a/src/cprover/chc_large_step.h b/src/cprover/chc_large_step.h index a27e72a8ef5..4a905df9e6d 100644 --- a/src/cprover/chc_large_step.h +++ b/src/cprover/chc_large_step.h @@ -113,106 +113,6 @@ class ResolutionVisitor : public wto_element_visitort } } - forall_exprt resolve_cls(const horn_clause & c1, const horn_clause & c2) - { - const exprt &body1 = *c1.body(); - const exprt &head1 = *c1.head(); - const exprt &body2 = *c2.body(); - const exprt &head2 = *c2.head(); - - std::vector use2; - c2.used_func_app(m_db,std::back_inserter(use2)); - - INVARIANT(use2.size() == 1, "Only handling linear case"); - if (use2.size() != 1) - throw analysis_exceptiont("Resolution not possible"); - - function_application_exprt & body2_pred = use2[0]; - - const function_application_exprt *head1_pred = nullptr; - if (can_cast_expr(*c1.head())) - { - head1_pred = &to_function_application_expr(head1); - } - if (head1_pred == nullptr) - throw analysis_exceptiont("Resolution not possible"); - - if (false) - std::cout << "Resolving: \n" << format(c1.get_chc()) << "\nAnd: \n" - << format(c2.get_chc()) << "\n"; - - std::set all_vars(c1.get_chc().variables().begin(), c1.get_chc().variables().end()); - all_vars.insert(c2.get_chc().variables().begin(), c2.get_chc().variables().end()); - - const function_application_exprt *body1_pred = nullptr; - exprt::operandst body_ops; - if (body1.id() == ID_and) - { - body1_pred = &to_function_application_expr(to_and_expr(body1).op0()); - body_ops.push_back(to_and_expr(body1).op1()); - } - else - { - body1_pred = &to_function_application_expr(body1); - } - exprt transformed_body = (can_cast_expr(body2)) ? to_and_expr(body2).op1() : true_exprt(); - exprt transformed_head = head2; - for (unsigned i=0; i < head1_pred->arguments().size(); i++) - { - const exprt &head_arg = head1_pred->arguments().at(i); - const symbol_exprt & body_arg = to_symbol_expr(body2_pred.arguments().at(i)); - if ((head_arg.id() != ID_symbol) || - (to_symbol_expr(head_arg).get_identifier() != body_arg.get_identifier())) - { - //std::cout << "body arg: " << format(body_arg) << " head arg: " << format(head_arg) << "\n"; - std::string name = as_string(body_arg.get_identifier()); - name = name + "__n" + std::to_string(m_id++); - symbol_exprt v(name, head_arg.type()); - equal_exprt eq(v, head_arg); - std::cout << format(eq) << "\n"; - all_vars.insert(v); - body_ops.push_back(eq); - - std::map subs; - subs.insert(std::make_pair(body_arg.get_identifier(), v)); - - if (!transformed_body.is_true()) { - std::optional s = substitute_symbols(subs, transformed_body); - if (s.has_value()) - transformed_body = std::move(s.value()); - } - if (can_cast_expr(body2)) { - //std::cout << "Body 2: " << format(to_and_expr(body2).op1()) << "\n"; - std::optional s = substitute_symbols(subs, to_and_expr(body2).op1()); - if (s.has_value()) - { - //std::cout << "Body 2 after: " << format(s.value()) << "\n"; - body_ops.push_back(std::move(s.value())); - } - } - - std::optional s = substitute_symbols(subs, transformed_head); - if (s.has_value()) - { - transformed_head = std::move(s.value()); - } - } - } - - if (body_ops.empty()) { - transformed_body = *body1_pred; - } - else - { - transformed_body = and_exprt( - *body1_pred, ((body_ops.size() > 1) ? std::move(and_exprt(body_ops)) : std::move(body_ops[0]))); - } - - forall_exprt f(std::vector(all_vars.begin(), all_vars.end()), - implies_exprt(std::move(transformed_body), std::move(transformed_head))); - return f; - } - forall_exprt resolve_cls2(const horn_clause & c1, const horn_clause & c2) { const exprt &body1 = *c1.body(); @@ -285,53 +185,9 @@ class ResolutionVisitor : public wto_element_visitort } } - /*for (unsigned i=0; i < head1_pred->arguments().size(); i++) - { - const exprt &head_arg = head1_pred->arguments().at(i); - const symbol_exprt & body_arg = to_symbol_expr(body2_pred.arguments().at(i)); - if ((head_arg.id() != ID_symbol) || - (to_symbol_expr(head_arg).get_identifier() != body_arg.get_identifier())) - { - std::cout << "body arg: " << format(body_arg) << " head arg: " << format(head_arg) << "\n"; - - std::map subs; - subs.insert(std::make_pair(body_arg.get_identifier(), head_arg)); - - if (!transformed_body.is_true()) { - std::optional s = substitute_symbols(subs, transformed_body); - if (s.has_value()) - transformed_body = std::move(s.value()); - } - if (can_cast_expr(body2)) { - std::cout << "Body 2: " << format(to_and_expr(body2).op1()) << "\n"; - std::optional s = substitute_symbols(subs, to_and_expr(body2).op1()); - if (s.has_value()) - { - std::cout << "Body 2 after: " << format(s.value()) << "\n"; - body_ops.push_back(std::move(s.value())); - } - } - - std::optional s = substitute_symbols(subs, transformed_head); - if (s.has_value()) - { - transformed_head = std::move(s.value()); - } - } - }*/ - body_ops.push_back(transformed_body); transformed_body = and_exprt(*body1_pred, std::move(and_exprt(body_ops))); -// if (body_ops.empty()) { -// transformed_body = *body1_pred; -// } -// else -// { -// transformed_body = and_exprt( -// *body1_pred, ((body_ops.size() > 1) ? std::move(and_exprt(body_ops)) : std::move(body_ops[0]))); -// } - forall_exprt f(std::vector(all_vars.begin(), all_vars.end()), implies_exprt(std::move(transformed_body), std::move(transformed_head))); return f; From e8bb4e7b55d34dbab59c1b90dc92019fc8fea707 Mon Sep 17 00:00:00 2001 From: Yakir Vizel Date: Sun, 22 Sep 2024 14:49:48 +0300 Subject: [PATCH 05/20] Small fix --- src/cprover/chc_large_step.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/cprover/chc_large_step.h b/src/cprover/chc_large_step.h index 4a905df9e6d..b3edd52e59e 100644 --- a/src/cprover/chc_large_step.h +++ b/src/cprover/chc_large_step.h @@ -17,10 +17,8 @@ class ResolutionVisitor : public wto_element_visitort std::unordered_map> m_def; std::set m_heads; - unsigned m_id; - public: - ResolutionVisitor(chc_db & db) : m_db(db), m_id(0) {} + ResolutionVisitor(chc_db & db) : m_db(db) {} virtual void visit(const wto_singletont & s) { From 5a02d554acacc7d46a028a3844025350826901cd Mon Sep 17 00:00:00 2001 From: Yakir Vizel Date: Sun, 22 Sep 2024 15:15:38 +0300 Subject: [PATCH 06/20] Extracting new chcs after transformation --- src/cprover/chc_large_step.h | 40 ++++++++++++++++++++++++---------- src/cprover/state_encoding.cpp | 28 ++++-------------------- 2 files changed, 32 insertions(+), 36 deletions(-) diff --git a/src/cprover/chc_large_step.h b/src/cprover/chc_large_step.h index b3edd52e59e..15c06de0c80 100644 --- a/src/cprover/chc_large_step.h +++ b/src/cprover/chc_large_step.h @@ -20,6 +20,8 @@ class ResolutionVisitor : public wto_element_visitort public: ResolutionVisitor(chc_db & db) : m_db(db) {} + chc_db &giveme_new_db() { return m_new_db; } + virtual void visit(const wto_singletont & s) { const symbol_exprt* symb = s.get(); @@ -39,23 +41,37 @@ class ResolutionVisitor : public wto_element_visitort resolve(head); } - std::vector getClauses() + void populate_new_db() { - std::vector all; - for (auto it = m_heads.begin(); it != m_heads.end(); it++) + std::vector rels; + for (auto &clause : m_db) + { + if(clause.is_query()) + { + clause.used_relations(m_db, std::back_inserter(rels)); + } + } + + std::set preds_hash(m_heads.begin(), m_heads.end()); + for (auto p : rels) { + preds_hash.insert(p.hash()); + } + + for (auto it : preds_hash) { - auto c = m_def.find(*it); + auto c = m_def.find(it); INVARIANT(c != m_def.end(), "No clauses"); - all.insert(all.begin(), c->second.begin(), c->second.end()); + for (auto clause : c->second) + m_new_db.add_clause(clause.get_chc()); } - return all; - } - const std::vector& getClauses(const symbol_exprt* symb) - { - auto it = m_def.find(symb->hash()); - INVARIANT(it != m_def.end(), "No clauses"); - return it->second; + for (auto &clause : m_db) + { + if(clause.is_query()) + { + m_new_db.add_clause(clause.get_chc()); + } + } } private: diff --git a/src/cprover/state_encoding.cpp b/src/cprover/state_encoding.cpp index 18bb8773558..c35610bbde9 100644 --- a/src/cprover/state_encoding.cpp +++ b/src/cprover/state_encoding.cpp @@ -1261,7 +1261,6 @@ void large_step_encoding(const container_encoding_targett & small_step_container { db.add_state_pred(s); } - } chc_graph chc_g(db); chc_g.build_graph(); @@ -1269,15 +1268,6 @@ void large_step_encoding(const container_encoding_targett & small_step_container chc_wtot wto(chc_g); wto.build_wto(); - SimpleVisitor v; - for (auto it = wto.begin(); it != wto.end(); it++) - { - auto x = (*it); - x->accept(&v); - } - - std::cout << "\n"; - ResolutionVisitor rv(db); for (auto it = wto.begin(); it != wto.end(); it++) { @@ -1285,21 +1275,11 @@ void large_step_encoding(const container_encoding_targett & small_step_container x->accept(&rv); } - std::vector all = rv.getClauses(); - for (auto &clause : db) { - if (clause.is_query()) { - std::vector rels; - clause.used_relations(db, std::back_inserter(rels)); - for (auto pred : rels) - { - all.insert(all.end(), rv.getClauses(&pred).begin(), rv.getClauses(&pred).end()); - } - all.push_back(clause.get_chc()); - } - - } + rv.populate_new_db(); - for (auto ce : all) + container_encoding_targett container2; + std::vector all2; + for (auto & ce : rv.giveme_new_db()) { large_step_container << ce.get_chc(); } From f01cbe9505b89624c2fa2287817633ad70b0b73e Mon Sep 17 00:00:00 2001 From: Yakir Vizel Date: Sun, 13 Oct 2024 13:32:58 +0300 Subject: [PATCH 07/20] Moving from std::set to std::unordered_set --- src/cprover/chc_db.cpp | 38 ++++++++++--------- src/cprover/chc_db.h | 85 +++++++++++++++++++++++++----------------- 2 files changed, 72 insertions(+), 51 deletions(-) diff --git a/src/cprover/chc_db.cpp b/src/cprover/chc_db.cpp index ca8f0311805..e2b71200827 100644 --- a/src/cprover/chc_db.cpp +++ b/src/cprover/chc_db.cpp @@ -6,46 +6,49 @@ #include -chc_db::chc_sett chc_db::m_empty_set; -std::set chc_graph::m_expr_empty_set; +chc_dbt::chc_sett chc_dbt::m_empty_set; +std::unordered_set chc_grapht::m_expr_empty_set; -void chc_db::reset_indices() +void chc_dbt::reset_indices() { m_body_idx.clear(); m_head_idx.clear(); } -void chc_db::build_indices() +void chc_dbt::build_indices() { reset_indices(); - for (auto &r: m_clauses) { + for (std::size_t i = 0; i < m_clauses.size(); i++) + { + auto & r = m_clauses[i]; if (!can_cast_expr(*r.head())) { continue; } exprt func = to_function_application_expr(*r.head()).function(); - m_head_idx[func].insert(&r); + m_head_idx[func].insert(i); std::vector use; r.used_relations(*this,std::back_inserter(use)); for (auto & symb : use) { - m_body_idx[symb].insert(&r); + m_body_idx[symb].insert(i); } } } -void chc_graph::build_graph() +void chc_grapht::build_graph() { m_db.build_indices(); for (auto & sp : m_db.get_state_preds()) { - std::set outgoing; - const std::set &uses = m_db.use(sp); - for (const horn_clause *r : uses) { - const exprt * head = r->head(); + std::unordered_set outgoing; + const chc_dbt::chc_sett &uses = m_db.use(sp); + for (auto idx: uses) { + const horn_clauset & r = m_db.get_clause(idx); + const exprt * head = r.head(); if (can_cast_expr(*head)) { outgoing.insert(to_function_application_expr(*head).function()); @@ -53,11 +56,12 @@ void chc_graph::build_graph() } m_outgoing.insert(std::make_pair(sp, outgoing)); - std::set incoming; - const std::set &defs = m_db.def(sp); - chc_db::is_state_pred isStatePred(m_db); - for (const horn_clause *r : defs) { - std::set symbols = find_symbols(*r->body()); + std::unordered_set incoming; + const chc_dbt::chc_sett &defs = m_db.def(sp); + chc_dbt::is_state_pred isStatePred(m_db); + for (auto idx : defs) { + const horn_clauset & r = m_db.get_clause(idx); + std::set symbols = find_symbols(*r.body()); for (auto & s : symbols) if (isStatePred(s)) incoming.insert(s); diff --git a/src/cprover/chc_db.h b/src/cprover/chc_db.h index 45ad7afb6f7..3e888d2b2d4 100644 --- a/src/cprover/chc_db.h +++ b/src/cprover/chc_db.h @@ -15,15 +15,25 @@ #include #include -class chc_db; -class horn_clause +class chc_dbt; + +/* + * A horn clause. + * This class is simply a wrapper around a forall_exprt with a few utilities: + * 1. Getting the body of a clause + * 2. Getting the head of a clause + * 3. Checking if a clause is a fact or a query + * 4. Getting used relations (the predicates) or function applications + * (their instantiations) in a clause. + */ +class horn_clauset { forall_exprt m_chc; public: - horn_clause(forall_exprt f) : m_chc(f) {} + horn_clauset(forall_exprt f) : m_chc(f) {} - horn_clause(std::vector & vars, exprt clause) : m_chc(vars, clause) { + horn_clauset(std::vector & vars, exprt clause) : m_chc(vars, clause) { } @@ -76,50 +86,51 @@ class horn_clause return false; } - bool operator==(const horn_clause &other) const + bool operator==(const horn_clauset &other) const { return m_chc == other.m_chc; } - bool operator!=(const horn_clause &other) const + bool operator!=(const horn_clauset &other) const { return !(*this==other); } - bool operator<(const horn_clause &other) const + bool operator<(const horn_clauset &other) const { return m_chc < other.m_chc; } template - void used_relations(chc_db &db, OutputIterator out) const; + void used_relations(chc_dbt &db, OutputIterator out) const; template - void used_func_app(chc_db &db, OutputIterator out) const; + void used_func_app(chc_dbt &db, OutputIterator out) const; }; /* * A database of CHCs. * Uninterpreted relations need to be registered. */ -class chc_db +class chc_dbt { - friend class horn_clause; + friend class horn_clauset; public: struct is_state_pred : public std::__unary_function { - const chc_db &m_db; - is_state_pred(const chc_db &db) : m_db(db) {} + const chc_dbt &m_db; + is_state_pred(const chc_dbt &db) : m_db(db) {} bool operator()(symbol_exprt state) { return m_db.has_state_pred(state); } }; + typedef std::unordered_set chc_sett; + private: - using chcst = std::vector; + using chcst = std::vector; chcst m_clauses; - std::set m_state_preds; + std::unordered_set m_state_preds; - typedef std::set chc_sett; - typedef std::map> chc_indext; + typedef std::map chc_indext; chc_indext m_body_idx; chc_indext m_head_idx; @@ -127,23 +138,23 @@ class chc_db static chc_sett m_empty_set; public: - chc_db() {} + chc_dbt() {} void add_state_pred(const symbol_exprt & state) { m_state_preds.insert(state); } - const std::set &get_state_preds() { return m_state_preds; } + const std::unordered_set &get_state_preds() { return m_state_preds; } bool has_state_pred(const symbol_exprt & state) const { return m_state_preds.count(state) > 0; } void build_indices(); void reset_indices(); - const std::set & use(const exprt & state) const { + const chc_sett & use(const exprt & state) const { auto it = m_body_idx.find(state); if (it == m_body_idx.end()) return m_empty_set; return it->second; } - const std::set & def(const exprt & state) const { + const chc_sett & def(const exprt & state) const { auto it = m_head_idx.find(state); if (it == m_head_idx.end()) return m_empty_set; @@ -157,10 +168,16 @@ class chc_db for (auto & c : m_clauses) { if (c.get_chc()==f) return; } - m_clauses.push_back(horn_clause(f)); + m_clauses.push_back(horn_clauset(f)); reset_indices(); } + [[nodiscard]] const horn_clauset & get_clause(std::size_t idx) const + { + INVARIANT(idx < m_clauses.size(), "Index in range"); + return m_clauses[idx]; + } + chcst::iterator begin() { return m_clauses.begin(); } chcst::iterator end() { return m_clauses.end(); } chcst::const_iterator begin() const { return m_clauses.begin(); } @@ -168,13 +185,13 @@ class chc_db }; template -void horn_clause::used_relations(chc_db &db, OutputIterator out) const +void horn_clauset::used_relations(chc_dbt &db, OutputIterator out) const { const exprt *body = this->body(); if (body == nullptr) return; std::set symbols = find_symbols(*body); - chc_db::is_state_pred filter(db); + chc_dbt::is_state_pred filter(db); for (auto & symb : symbols) { if (filter(symb)) { *out = symb; @@ -183,12 +200,12 @@ void horn_clause::used_relations(chc_db &db, OutputIterator out) const } template -void horn_clause::used_func_app(chc_db &db, OutputIterator out) const +void horn_clauset::used_func_app(chc_dbt &db, OutputIterator out) const { const exprt *body = this->body(); if (body == nullptr) return; - std::set funcs; + std::unordered_set funcs; body->visit_pre([&funcs](const exprt &expr) { if (can_cast_expr(expr)) { @@ -197,7 +214,7 @@ void horn_clause::used_func_app(chc_db &db, OutputIterator out) const } }); - chc_db::is_state_pred filter(db); + chc_dbt::is_state_pred filter(db); for (auto & f : funcs) { if (filter(to_symbol_expr(f.function()))) { *out = f; @@ -210,19 +227,19 @@ void horn_clause::used_func_app(chc_db &db, OutputIterator out) const * Uninterpreted relations are vertices, dependency is based on clauses: * relations in the body have an edge to the relation in the head. */ -class chc_graph +class chc_grapht { - chc_db & m_db; - typedef std::map> grapht; + chc_dbt & m_db; + typedef std::map> grapht; grapht m_incoming; grapht m_outgoing; const symbol_exprt *m_entry; // representing the empty set - static std::set m_expr_empty_set; + static std::unordered_set m_expr_empty_set; public: - chc_graph(chc_db & db) : m_db(db), m_entry(nullptr) {} + chc_grapht(chc_dbt & db) : m_db(db), m_entry(nullptr) {} void build_graph(); @@ -231,14 +248,14 @@ class chc_graph INVARIANT(has_entry(), "Entry must exist."); return m_entry; } - const std::set &outgoing(const symbol_exprt &state) const { + const std::unordered_set &outgoing(const symbol_exprt &state) const { auto it = m_outgoing.find(state); if (it == m_outgoing.end()) return m_expr_empty_set; return it->second; } - const std::set &incoming(const symbol_exprt &state) const { + const std::unordered_set &incoming(const symbol_exprt &state) const { auto it = m_incoming.find(state); if (it == m_incoming.end()) return m_expr_empty_set; From 7672856df488d99eb0c2a7d94bb0a075be5dffcd Mon Sep 17 00:00:00 2001 From: Yakir Vizel Date: Sun, 13 Oct 2024 14:40:07 +0300 Subject: [PATCH 08/20] Naming conventions, unsigned -> size_t --- src/cprover/chc_wto.h | 6 +- src/cprover/cutpoint_graph.cpp | 91 ++++++++++-------------- src/cprover/cutpoint_graph.h | 123 ++++++++++++++++----------------- 3 files changed, 98 insertions(+), 122 deletions(-) diff --git a/src/cprover/chc_wto.h b/src/cprover/chc_wto.h index 32bd3dfc433..3b9ed31e2c4 100644 --- a/src/cprover/chc_wto.h +++ b/src/cprover/chc_wto.h @@ -142,7 +142,7 @@ class chc_wtot typedef std::unordered_map> nested_components_t; - chc_graph & m_g; + chc_grapht & m_g; std::unordered_map m_dfn; std::vector m_stack; @@ -239,7 +239,7 @@ class chc_wtot } public: - chc_wtot(chc_graph & g) : m_g(g), m_cur_dfn_num(0) {} + chc_wtot(chc_grapht & g) : m_g(g), m_cur_dfn_num(0) {} void build_wto() { if (!m_g.has_entry()) @@ -276,7 +276,7 @@ class chc_wtot } }; -class SimpleVisitor : public wto_element_visitort +class simple_visitort : public wto_element_visitort { virtual void visit(const wto_singletont & s) { diff --git a/src/cprover/cutpoint_graph.cpp b/src/cprover/cutpoint_graph.cpp index 9159542b564..4fa0d784211 100644 --- a/src/cprover/cutpoint_graph.cpp +++ b/src/cprover/cutpoint_graph.cpp @@ -8,23 +8,23 @@ #include #include -cutpoint_graph::~cutpoint_graph() { +cutpoint_grapht::~cutpoint_grapht() { m_edges.clear(); m_cps.clear(); m_insts.clear(); } -void cutpoint_graph::run(const goto_functiont & goto_function) +void cutpoint_grapht::run(const goto_functiont & goto_function) { - computeCutpoints (goto_function); - computeFwdReach (goto_function); - computeBwdReach (goto_function); - computeEdges (goto_function); + compute_cutpoints(goto_function); + compute_fwd_reach(goto_function); + compute_bwd_reach(goto_function); + compute_edges(goto_function); - toDot(goto_function, "cp.dot"); + to_dot(goto_function, "cp.dot"); } -void cutpoint_graph::toDot(const goto_functiont & f, std::string filename) +void cutpoint_grapht::to_dot(const goto_functiont & f, std::string filename) { std::ofstream out; out.open(filename); @@ -35,7 +35,7 @@ void cutpoint_graph::toDot(const goto_functiont & f, std::string filename) for (auto cp : m_cps) { - cp->toDot(out, ns); + cp->to_dot(out, ns); } for (auto edge : m_edges) @@ -62,7 +62,7 @@ void cutpoint_graph::toDot(const goto_functiont & f, std::string filename) out.close(); } -cutpoint_edge_ptr cutpoint_graph::getEdge(const cutpoint &s, const cutpoint &d) +cutpoint_edge_ptr cutpoint_grapht::get_edge(const cutpointt &s, const cutpointt &d) { for (auto it = s.succ_begin (), end = s.succ_end (); it != end; ++it) { @@ -73,7 +73,8 @@ cutpoint_edge_ptr cutpoint_graph::getEdge(const cutpoint &s, const cutpoint &d) return nullptr; } -const cutpoint_edge_ptr cutpoint_graph::getEdge(const cutpoint &s, const cutpoint &d) const +const cutpoint_edge_ptr +cutpoint_grapht::getEdge(const cutpointt &s, const cutpointt &d) const { for (auto it = s.succ_begin (), end = s.succ_end (); it != end; ++it) { @@ -84,20 +85,20 @@ const cutpoint_edge_ptr cutpoint_graph::getEdge(const cutpoint &s, const cutpoin return nullptr; } -void cutpoint_graph::computeEdges (const goto_functiont &goto_function) +void cutpoint_grapht::compute_edges(const goto_functiont &goto_function) { forall_goto_program_instructions(it, goto_function.body) { - if (isCutpoint(*it)) + if (is_cutpoint(*it)) { std::vector & reach = m_fwd[&(*it)]; - cutpoint & cp = getCutpoint(*it); + cutpointt & cp = get_cutpoint(*it); - for (unsigned r = 0; r < reach.size(); r++) + for (std::size_t r = 0; r < reach.size(); r++) { if (reach[r] == true) { - cutpoint_edge_ptr edg = newEdge(cp, *m_cps[r]); + cutpoint_edge_ptr edg = create_edge(cp, *m_cps[r]); edg->push_back(&(*it)); } } @@ -112,7 +113,7 @@ void cutpoint_graph::computeEdges (const goto_functiont &goto_function) if (breach[i] == false) continue; for (int j = 0; j < freach.size(); j++) { if (freach[j] == false) continue; - cutpoint_edge_ptr edge = getEdge(*m_cps[i], *m_cps[j]); + cutpoint_edge_ptr edge = get_edge(*m_cps[i], *m_cps[j]); edge->push_back(&(*it)); } } @@ -120,11 +121,11 @@ void cutpoint_graph::computeEdges (const goto_functiont &goto_function) } } -void cutpoint_graph::computeCutpoints(const goto_functiont &goto_function) +void cutpoint_grapht::compute_cutpoints(const goto_functiont &goto_function) { m_cps.clear(); - std::map cp_map; + std::map cp_map; forall_goto_program_instructions(it, goto_function.body) { @@ -163,14 +164,14 @@ void cutpoint_graph::computeCutpoints(const goto_functiont &goto_function) auto i = cp_map.find(&*it); if (i == cp_map.end()) continue; auto inst = i->first; - if (isCutpoint(*inst)) continue; + if (is_cutpoint(*inst)) continue; - m_cps.push_back(std::make_shared(*this, m_cps.size(), *inst)); + m_cps.push_back(std::make_shared(*this, m_cps.size(), *inst)); m_insts.insert(std::make_pair(inst, m_cps.back())); } } -void cutpoint_graph::computeFwdReach (const goto_functiont &goto_function) +void cutpoint_grapht::compute_fwd_reach(const goto_functiont &goto_function) { for (auto it = goto_function.body.instructions.rbegin(); it != goto_function.body.instructions.rend();) @@ -179,14 +180,12 @@ void cutpoint_graph::computeFwdReach (const goto_functiont &goto_function) auto succs = goto_function.body.get_successors(itf); //if (succs.empty()) continue; auto inst = &*itf; - m_fwd.insert(std::make_pair(inst, reachability())); - reachability &r = m_fwd [inst]; - std::cout << inst->to_string() << "\n"; - if (succs.size() > 1) std::cout << "YAY\n"; + m_fwd.insert(std::make_pair(inst, reachabilityt())); + reachabilityt &r = m_fwd [inst]; for (auto succ : succs) { - if (isCutpoint(*succ)) - r.set(getCutpoint(*succ).id()); + if (is_cutpoint(*succ)) + r.set(get_cutpoint(*succ).id()); else r |= m_fwd[&*succ]; @@ -194,19 +193,19 @@ void cutpoint_graph::computeFwdReach (const goto_functiont &goto_function) } } -void cutpoint_graph::computeBwdReach (const goto_functiont &goto_function) +void cutpoint_grapht::compute_bwd_reach(const goto_functiont &goto_function) { forall_goto_program_instructions(it, goto_function.body) { auto inst = &*it; - m_bwd.insert(std::make_pair(inst, reachability())); - reachability &r = m_bwd[inst]; + m_bwd.insert(std::make_pair(inst, reachabilityt())); + reachabilityt &r = m_bwd[inst]; for(auto pred : it->incoming_edges) { if(pred->is_backwards_goto()) continue; - if(isCutpoint(*pred)) - r.set(getCutpoint(*pred).id()); + if(is_cutpoint(*pred)) + r.set(get_cutpoint(*pred).id()); else r |= m_bwd[&*pred]; @@ -216,36 +215,16 @@ void cutpoint_graph::computeBwdReach (const goto_functiont &goto_function) for (auto & cp : m_cps) { auto & inst = cp->inst(); - reachability &r = m_bwd [&inst]; + reachabilityt &r = m_bwd [&inst]; for (auto pred : inst.incoming_edges) { if (! pred->is_backwards_goto()) continue; - if (isCutpoint(*pred)) - r.set(getCutpoint(*pred).id()); + if (is_cutpoint(*pred)) + r.set(get_cutpoint(*pred).id()); else r |= m_bwd[&*pred]; } } } -bool cutpoint_graph::isFwdReach(const cutpoint &cp, const goto_programt::instructiont &inst) const -{ - if (&(cp.inst ()) == &inst) return true; - - // The instruction is already a cut-point, but not the one testes. - // It is impossible to reach another cut-point without getting to it - if (isCutpoint(inst)) return false; - - // In case the instruction is not a cut-point, retrieve the backward - // reachability info (cut-point backward reachability) and check if the - // cut-point is backward reachable. If it is, then the instruction - // is forward reachable from the given cp. - auto it = m_bwd.find (&inst); - INVARIANT(it != m_bwd.end (), "No back-reachability information"); - - unsigned sz = it->second.size (); - unsigned id = cp.id (); - if (sz == 0 || id >= sz) return false; - return (it->second)[id]; -} diff --git a/src/cprover/cutpoint_graph.h b/src/cprover/cutpoint_graph.h index 2ca0ea59fa6..a54a5255653 100644 --- a/src/cprover/cutpoint_graph.h +++ b/src/cprover/cutpoint_graph.h @@ -16,36 +16,36 @@ * 3. Every node that has a back-edge - namely, a loop head. */ -class cutpoint_graph; -class cutpoint; +class cutpoint_grapht; +class cutpointt; -class cutpoint_edge +class cutpoint_edget { - friend class cutpoint_graph; + friend class cutpoint_grapht; - cutpoint & m_src; - cutpoint & m_dst; + cutpointt & m_src; + cutpointt & m_dst; - typedef std::vector InstVec; - InstVec m_insts; + typedef std::vector inst_vect; + inst_vect m_insts; - cutpoint &source() { return m_src; } - cutpoint &target() { return m_dst; } + cutpointt &source() { return m_src; } + cutpointt &target() { return m_dst; } public: - cutpoint_edge(cutpoint & s, cutpoint & d) : m_src(s), m_dst(d) {} + cutpoint_edget(cutpointt & s, cutpointt & d) : m_src(s), m_dst(d) {} - const cutpoint_graph& graph() const; + const cutpoint_grapht & graph() const; - const cutpoint &source() const { return m_src; } - const cutpoint &target() const { return m_dst; } + const cutpointt &source() const { return m_src; } + const cutpointt &target() const { return m_dst; } void push_back(const goto_programt::instructiont * inst) { m_insts.push_back(inst); } - typedef InstVec::iterator iterator; - typedef InstVec::const_iterator const_iterator; + typedef inst_vect::iterator iterator; + typedef inst_vect::const_iterator const_iterator; iterator begin() { return m_insts.begin(); } iterator end() { return m_insts.end(); } @@ -53,116 +53,113 @@ class cutpoint_edge const_iterator end() const { return m_insts.end(); } }; -typedef std::shared_ptr cutpoint_edge_ptr; +typedef std::shared_ptr cutpoint_edge_ptr; -class cutpoint +class cutpointt { - friend class cutpoint_graph; - - const cutpoint_graph &m_graph; - unsigned m_id; + const cutpoint_grapht &m_graph; + std::size_t m_id; const goto_programt::instructiont & m_inst; - typedef std::vector EdgeVec; - EdgeVec m_succ; + typedef std::vector edge_vect; + edge_vect m_succ; public: - cutpoint(const cutpoint_graph &p, unsigned id, const goto_programt::instructiont &inst) + cutpointt(const cutpoint_grapht &p, std::size_t id, const goto_programt::instructiont &inst) : m_graph(p), m_id(id), m_inst(inst) {} - const cutpoint_graph &graph() const { return m_graph; } - unsigned id() const { return m_id; } + const cutpoint_grapht &graph() const { return m_graph; } + std::size_t id() const { return m_id; } const goto_programt::instructiont &inst() const { return m_inst; } - void addSucc(cutpoint_edge_ptr & edg) { m_succ.push_back(edg); } + void add_succ(cutpoint_edge_ptr & edg) { m_succ.push_back(edg); } - typedef EdgeVec::const_iterator const_iterator; - typedef EdgeVec::const_reverse_iterator const_reverse_iterator; + typedef edge_vect::const_iterator const_iterator; + typedef edge_vect::const_reverse_iterator const_reverse_iterator; const_iterator succ_begin() const { return m_succ.begin(); } const_iterator succ_end() const { return m_succ.end(); } - void toDot(std::ostream & out, const namespacet & ns) + void to_dot(std::ostream & out, const namespacet & ns) { out << "Node_" << m_id << " [shape=Mrecord,fontsize=22,label=\""; out << m_inst.to_string() << "\"];\n"; } }; -class cutpoint_graph +class cutpoint_grapht { const goto_modelt & m_goto_model; - typedef std::shared_ptr cutpoint_ptr; - typedef std::vector CutpointVec; + typedef std::shared_ptr cutpoint_ptr; + typedef std::vector cutpoint_vect; - typedef std::vector EdgeVec; + typedef std::vector edge_vect; - CutpointVec m_cps; - EdgeVec m_edges; + cutpoint_vect m_cps; + edge_vect m_edges; - class reachability : public std::vector { + class reachabilityt : public std::vector { public: - void set(unsigned index) { + void set(std::size_t index) { if (index >= size()) resize(index+1, false); (*this)[index] = true; } - reachability& operator|=(const reachability & other) { + reachabilityt & operator|=(const reachabilityt & other) { if (this->size() < other.size()) this->resize(other.size(), false); - for (unsigned i = 0; i < other.size(); i++) + for (std::size_t i = 0; i < other.size(); i++) (*this)[i] = (*this)[i] || other[i]; return *this; } }; - typedef std::map InstBoolMap; + typedef std::map + inst_bool_mapt; - InstBoolMap m_fwd; - InstBoolMap m_bwd; + inst_bool_mapt m_fwd; + inst_bool_mapt m_bwd; - std::map> m_insts; + std::map> m_insts; - cutpoint_edge_ptr newEdge(cutpoint &s, cutpoint &d) { - m_edges.push_back(std::make_shared(s, d)); + cutpoint_edge_ptr create_edge(cutpointt &s, cutpointt &d) { + m_edges.push_back(std::make_shared(s, d)); cutpoint_edge_ptr edg = m_edges.back(); - s.addSucc(edg); + s.add_succ(edg); return edg; } - void computeCutpoints(const goto_functiont & goto_function); - void computeFwdReach(const goto_functiont & goto_function); - void computeBwdReach(const goto_functiont & goto_function); - void computeEdges(const goto_functiont & goto_function); + void compute_cutpoints(const goto_functiont & goto_function); + void compute_fwd_reach(const goto_functiont & goto_function); + void compute_bwd_reach(const goto_functiont & goto_function); + void compute_edges(const goto_functiont & goto_function); - void toDot(const goto_functiont & f, std::string filename); + void to_dot(const goto_functiont & f, std::string filename); public: - cutpoint_graph(const goto_modelt & goto_model) : m_goto_model(goto_model) {} - ~cutpoint_graph(); + cutpoint_grapht(const goto_modelt & goto_model) : m_goto_model(goto_model) {} + ~cutpoint_grapht(); void run(const goto_functiont & goto_function); - bool isCutpoint(const goto_programt::instructiont & inst) const + bool is_cutpoint(const goto_programt::instructiont & inst) const { return m_insts.count(&inst) > 0; } - cutpoint &getCutpoint(const goto_programt::instructiont & inst) const { - INVARIANT(isCutpoint(inst), "Function should be called with a cutpoint"); + cutpointt &get_cutpoint(const goto_programt::instructiont & inst) const { + INVARIANT(is_cutpoint(inst), "Function should be called with a cutpoint"); return *(m_insts.find(&inst)->second); } - cutpoint_edge_ptr getEdge(const cutpoint &s, const cutpoint &d); - const cutpoint_edge_ptr getEdge(const cutpoint &s, const cutpoint &d) const; - - bool isFwdReach(const cutpoint & cp, const goto_programt::instructiont &inst) const; + cutpoint_edge_ptr get_edge(const cutpointt &s, const cutpointt &d); + const cutpoint_edge_ptr getEdge(const cutpointt &s, const cutpointt &d) const; }; -inline const cutpoint_graph & cutpoint_edge::graph() const { return m_src.graph(); } +inline const cutpoint_grapht &cutpoint_edget::graph() const { return m_src.graph(); } From 7ae6ef2818420a9d5e7cc9d34fa3948be14a87d8 Mon Sep 17 00:00:00 2001 From: Yakir Vizel Date: Sun, 13 Oct 2024 14:41:38 +0300 Subject: [PATCH 09/20] Renaming types and function names, and adjusments to changes in API --- src/cprover/chc_large_step.h | 59 ++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/src/cprover/chc_large_step.h b/src/cprover/chc_large_step.h index 15c06de0c80..143c0fc33ea 100644 --- a/src/cprover/chc_large_step.h +++ b/src/cprover/chc_large_step.h @@ -9,23 +9,29 @@ #include #include -class ResolutionVisitor : public wto_element_visitort +/* + * Traverses the clauses in order and resolving all predicates (symbols) + * that are not a head (e.g. a head of a loop). + * This is similar to variable elimination in SAT. + */ +class resolution_visitort : public wto_element_visitort { private: - chc_db & m_db; - chc_db m_new_db; - std::unordered_map> m_def; - std::set m_heads; + chc_dbt & m_db; + chc_dbt m_new_db; + std::unordered_map> m_def; + std::unordered_set m_heads; + bool m_verbose; public: - ResolutionVisitor(chc_db & db) : m_db(db) {} + resolution_visitort(chc_dbt & db) : m_db(db), m_verbose(false) {} - chc_db &giveme_new_db() { return m_new_db; } + chc_dbt &giveme_new_db() { return m_new_db; } virtual void visit(const wto_singletont & s) { const symbol_exprt* symb = s.get(); - resolve(symb); + eliminate(symb); } virtual void visit(const wto_componentt & comp) @@ -38,7 +44,7 @@ class ResolutionVisitor : public wto_element_visitort { it->get()->accept(this); } - resolve(head); + eliminate(head); } void populate_new_db() @@ -75,43 +81,41 @@ class ResolutionVisitor : public wto_element_visitort } private: - void resolve(const symbol_exprt *symb) + void eliminate(const symbol_exprt *symb) { - for (auto clause : m_db.def(*symb)) + for (auto idx : m_db.def(*symb)) { + auto & clause = m_db.get_clause(idx); std::vector use; - if (false) - { - std::cout << "Clause: " << format(clause->get_chc()) << "\n"; - } - clause->used_relations(m_db,std::back_inserter(use)); + + clause.used_relations(m_db,std::back_inserter(use)); if (use.size() > 1) { throw incorrect_goto_program_exceptiont("Non-linear CHCs not supported yet"); } - if (clause->is_fact()) + if (clause.is_fact()) { m_heads.insert(symb->hash()); - std::vector def_chcs; - def_chcs.push_back(clause->get_chc()); + std::vector def_chcs; + def_chcs.push_back(clause.get_chc()); m_def.insert(std::make_pair(symb->hash(), def_chcs)); } for (auto & p : use) { auto it = m_def.find(p.hash()); - std::vector def_chcs; + std::vector def_chcs; if (it == m_def.end() || m_heads.find(p.hash()) != m_heads.end()) { - def_chcs.push_back(*clause); + def_chcs.push_back(clause); } else { for (auto cls_it = it->second.begin(); cls_it != it->second.end(); cls_it++) { - forall_exprt resolvent = resolve_cls2((*cls_it), *clause); - if (false) - std::cout << "Result where:\n" << format(resolvent) << "\n"; + forall_exprt resolvent = resolve_clauses((*cls_it), clause); + if (m_verbose) + std::cout << "Result:\n" << format(resolvent) << "\n"; def_chcs.push_back(resolvent); } } @@ -127,7 +131,7 @@ class ResolutionVisitor : public wto_element_visitort } } - forall_exprt resolve_cls2(const horn_clause & c1, const horn_clause & c2) + forall_exprt resolve_clauses(const horn_clauset & c1, const horn_clauset & c2) { const exprt &body1 = *c1.body(); const exprt &head1 = *c1.head(); @@ -151,7 +155,7 @@ class ResolutionVisitor : public wto_element_visitort if (head1_pred == nullptr) throw analysis_exceptiont("Resolution not possible"); - if (false) + if (m_verbose) std::cout << "Resolving: \n" << format(c1.get_chc()) << "\nAnd: \n" << format(c2.get_chc()) << "\n"; @@ -179,9 +183,6 @@ class ResolutionVisitor : public wto_element_visitort if ((head_arg.id() != ID_symbol) || (to_symbol_expr(head_arg).get_identifier() != body_arg.get_identifier())) { - //std::cout << "body arg: " << format(body_arg) - // << " head arg: " << format(head_arg) << "\n"; - std::map subs; subs.insert(std::make_pair(body_arg.get_identifier(), head_arg)); From c5fffbd835ffaa9659d1c8bb0cb2e6f3b17c0834 Mon Sep 17 00:00:00 2001 From: Yakir Vizel Date: Sun, 13 Oct 2024 14:42:36 +0300 Subject: [PATCH 10/20] Adjusting API changes --- src/cprover/state_encoding.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cprover/state_encoding.cpp b/src/cprover/state_encoding.cpp index c35610bbde9..ad0ee44d9c4 100644 --- a/src/cprover/state_encoding.cpp +++ b/src/cprover/state_encoding.cpp @@ -1238,7 +1238,7 @@ void variable_encoding( void large_step_encoding(const container_encoding_targett & small_step_container, container_encoding_targett & large_step_container) { - chc_db db; + chc_dbt db; for (auto & clause : small_step_container.constraints) { if (!can_cast_expr(clause)) { @@ -1262,13 +1262,13 @@ void large_step_encoding(const container_encoding_targett & small_step_container db.add_state_pred(s); } } - chc_graph chc_g(db); + chc_grapht chc_g(db); chc_g.build_graph(); chc_wtot wto(chc_g); wto.build_wto(); - ResolutionVisitor rv(db); + resolution_visitort rv(db); for (auto it = wto.begin(); it != wto.end(); it++) { auto x = (*it); @@ -1278,7 +1278,7 @@ void large_step_encoding(const container_encoding_targett & small_step_container rv.populate_new_db(); container_encoding_targett container2; - std::vector all2; + std::vector all2; for (auto & ce : rv.giveme_new_db()) { large_step_container << ce.get_chc(); From be0662ba6080b3cb9a4d1d4616930deef1978b06 Mon Sep 17 00:00:00 2001 From: Yakir Vizel Date: Mon, 28 Oct 2024 10:52:50 +0200 Subject: [PATCH 11/20] Equivalent query clauses may represent different properties. Allow it in CHC db --- src/cprover/chc_db.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/cprover/chc_db.h b/src/cprover/chc_db.h index 3e888d2b2d4..6534f2655fb 100644 --- a/src/cprover/chc_db.h +++ b/src/cprover/chc_db.h @@ -165,10 +165,18 @@ class chc_dbt { if (f.is_true()) return; - for (auto & c : m_clauses) { - if (c.get_chc()==f) return; + auto new_cls = horn_clauset(f); + // Equivalent (semantic) queries may represent + // different properties + if (!new_cls.is_query()) + { + for(auto &c : m_clauses) + { + if(c.get_chc() == f) + return; + } } - m_clauses.push_back(horn_clauset(f)); + m_clauses.push_back(new_cls); reset_indices(); } From 76385330d96d0365ae02000f7efc36a9e7e6b1e4 Mon Sep 17 00:00:00 2001 From: Yakir Vizel Date: Mon, 28 Oct 2024 10:57:13 +0200 Subject: [PATCH 12/20] Adding regression tests for large step encoding of CHCs --- regression/cprover/large_step/CMakeLists.txt | 3 ++ regression/cprover/large_step/Makefile | 14 ++++++ regression/cprover/large_step/arrays/array1.c | 10 +++++ .../cprover/large_step/arrays/array1.desc | 14 ++++++ regression/cprover/large_step/arrays/array2.c | 8 ++++ .../cprover/large_step/arrays/array2.desc | 11 +++++ regression/cprover/large_step/arrays/array4.c | 7 +++ .../cprover/large_step/arrays/array4.desc | 7 +++ .../large_step/arrays/array_literal1.c | 8 ++++ .../large_step/arrays/array_literal1.desc | 8 ++++ .../large_step/arrays/array_literal2.c | 8 ++++ .../cprover/large_step/arrays/array_r_ok1.c | 7 +++ .../large_step/arrays/array_r_ok1.desc | 8 ++++ .../cprover/large_step/arrays/array_set1.c | 8 ++++ .../cprover/large_step/arrays/array_set1.desc | 7 +++ .../large_step/arrays/iterate_over_array1.c | 7 +++ .../arrays/iterate_over_array1.desc | 7 +++ .../large_step/arrays/iterate_over_array2.c | 31 +++++++++++++ .../arrays/iterate_over_array2.desc | 7 +++ .../aws-c-common/aws_array_eq_c_str.desc | 6 +++ .../aws_array_eq_c_str_contract.c | 20 +++++++++ .../aws_array_eq_c_str_ignore_case.desc | 6 +++ .../aws_array_eq_c_str_ignore_case_contract.c | 20 +++++++++ .../aws_array_eq_ignore_case.desc | 6 +++ .../aws_array_eq_ignore_case_contract.c | 23 ++++++++++ .../aws-c-common/aws_hash_table_clear.desc | 6 +++ .../aws_hash_table_clear_contract.c | 15 +++++++ .../aws-c-common/aws_hash_table_eq.desc | 6 +++ .../aws-c-common/aws_hash_table_eq_contract.c | 20 +++++++++ .../aws-c-common/aws_hash_table_foreach.desc | 6 +++ .../aws_hash_table_foreach_contract.c | 20 +++++++++ .../cprover/large_step/aws-c-common/setup | 6 +++ .../todo/aws_array_list_mem_swap.desc | 6 +++ .../todo/aws_array_list_mem_swap_contract.c | 6 +++ .../todo/aws_byte_buf_append_with_lookup.desc | 6 +++ ...aws_byte_buf_append_with_lookup_contract.c | 6 +++ .../todo/aws_hash_array_ignore_case.desc | 6 +++ .../aws_hash_array_ignore_case_contract.c | 6 +++ .../aws-c-common/todo/hashlittle2.desc | 6 +++ .../aws-c-common/todo/hashlittle2_contract.c | 6 +++ .../todo/memcpy_using_uint64_impl.desc | 6 +++ .../todo/memcpy_using_uint64_impl_contract.c | 6 +++ .../todo/memset_override_0_impl.desc | 6 +++ .../todo/memset_override_0_impl_contract.c | 6 +++ .../todo/memset_using_uint64_impl.desc | 6 +++ .../todo/memset_using_uint64_impl_contract.c | 6 +++ .../aws-c-common/todo/s_find_entry1.desc | 6 +++ .../todo/s_find_entry1_contract.c | 6 +++ .../aws-c-common/todo/s_get_next_element.desc | 6 +++ .../todo/s_get_next_element_contract.c | 6 +++ .../aws-c-common/todo/s_sift_down.desc | 6 +++ .../aws-c-common/todo/s_sift_down_contract.c | 6 +++ .../aws-c-common/todo/s_sift_up.desc | 6 +++ .../aws-c-common/todo/s_sift_up_contract.c | 6 +++ regression/cprover/large_step/basic/assume1.c | 8 ++++ .../cprover/large_step/basic/assume1.desc | 14 ++++++ regression/cprover/large_step/basic/basic1.c | 8 ++++ .../cprover/large_step/basic/basic1.desc | 12 ++++++ regression/cprover/large_step/basic/basic2.c | 9 ++++ .../cprover/large_step/basic/basic2.desc | 13 ++++++ regression/cprover/large_step/basic/basic3.c | 9 ++++ .../cprover/large_step/basic/basic3.desc | 12 ++++++ regression/cprover/large_step/basic/basic4.c | 9 ++++ .../cprover/large_step/basic/basic4.desc | 11 +++++ regression/cprover/large_step/basic/basic5.c | 11 +++++ .../cprover/large_step/basic/basic5.desc | 14 ++++++ regression/cprover/large_step/basic/basic6.c | 12 ++++++ .../cprover/large_step/basic/basic6.desc | 13 ++++++ regression/cprover/large_step/basic/extern1.c | 13 ++++++ .../cprover/large_step/basic/extern1.desc | 7 +++ .../cprover/large_step/basic/no-assertions1.c | 5 +++ .../large_step/basic/no-assertions1.desc | 7 +++ regression/cprover/large_step/basic/nondet1.c | 14 ++++++ .../cprover/large_step/basic/nondet1.desc | 15 +++++++ .../cprover/large_step/branching/branching1.c | 14 ++++++ .../large_step/branching/branching1.desc | 24 +++++++++++ .../cprover/large_step/branching/branching2.c | 14 ++++++ .../large_step/branching/branching2.desc | 16 +++++++ .../large_step/contracts/check_assigns1.c | 36 ++++++++++++++++ .../large_step/contracts/check_assigns1.desc | 9 ++++ .../large_step/contracts/check_assigns2.c | 20 +++++++++ .../large_step/contracts/check_assigns2.desc | 6 +++ .../large_step/contracts/check_assigns3.c | 26 +++++++++++ .../large_step/contracts/check_assigns3.desc | 9 ++++ .../large_step/contracts/check_assigns4.c | 37 ++++++++++++++++ .../large_step/contracts/check_assigns4.desc | 11 +++++ .../large_step/contracts/check_assigns5.c | 29 +++++++++++++ .../large_step/contracts/check_assigns5.desc | 11 +++++ .../large_step/contracts/check_assigns6.c | 19 ++++++++ .../large_step/contracts/check_assigns6.desc | 8 ++++ .../contracts/check_postcondition1.c | 16 +++++++ .../contracts/check_postcondition1.desc | 8 ++++ .../contracts/check_postcondition2.c | 21 +++++++++ .../contracts/check_postcondition2.desc | 8 ++++ .../contracts/check_postcondition3.c | 17 ++++++++ .../contracts/check_postcondition3.desc | 10 +++++ .../contracts/check_postcondition4.c | 12 ++++++ .../contracts/check_postcondition4.desc | 8 ++++ .../contracts/check_postcondition5.c | 8 ++++ .../contracts/check_postcondition5.desc | 7 +++ .../contracts/check_postcondition6.c | 10 +++++ .../contracts/check_postcondition6.desc | 7 +++ .../contracts/check_precondition1.c | 13 ++++++ .../contracts/check_precondition1.desc | 8 ++++ .../contracts/check_precondition2.c | 15 +++++++ .../contracts/check_precondition2.desc | 7 +++ .../contracts/check_return_value1.c | 15 +++++++ .../contracts/check_return_value1.desc | 8 ++++ .../contracts/configured_contract1.c | 12 ++++++ .../contracts/configured_contract1.desc | 8 ++++ .../contracts/configured_contract2.c | 9 ++++ .../contracts/configured_contract2.desc | 7 +++ .../large_step/contracts/integer_range1.c | 25 +++++++++++ .../large_step/contracts/integer_range1.desc | 6 +++ .../large_step/contracts/integer_range2.c | 24 +++++++++++ .../large_step/contracts/integer_range2.desc | 6 +++ .../large_step/contracts/integer_range3.c | 28 ++++++++++++ .../large_step/contracts/integer_range3.desc | 6 +++ .../large_step/contracts/integer_range4.c | 35 +++++++++++++++ .../large_step/contracts/integer_range4.desc | 6 +++ .../large_step/contracts/memory_safety1.c | 5 +++ .../large_step/contracts/memory_safety1.desc | 7 +++ .../cprover/large_step/contracts/nested1.c | 16 +++++++ .../cprover/large_step/contracts/nested1.desc | 8 ++++ .../large_step/contracts/one_function1.c | 7 +++ .../large_step/contracts/one_function1.desc | 8 ++++ .../contracts/recursive_function1.c | 8 ++++ .../contracts/recursive_function1.desc | 7 +++ .../contracts/recursive_function2.c | 5 +++ .../contracts/recursive_function2.desc | 7 +++ .../large_step/contracts/use_assigns1.c | 16 +++++++ .../large_step/contracts/use_assigns1.desc | 7 +++ .../large_step/contracts/use_assigns2.c | 16 +++++++ .../large_step/contracts/use_assigns2.desc | 7 +++ .../cprover/large_step/contracts/use_old1.c | 6 +++ .../large_step/contracts/use_old1.desc | 7 +++ .../cprover/large_step/contracts/use_old2.c | 12 ++++++ .../large_step/contracts/use_old2.desc | 8 ++++ .../large_step/contracts/use_postcondition1.c | 13 ++++++ .../contracts/use_postcondition1.desc | 9 ++++ .../large_step/contracts/use_postcondition2.c | 14 ++++++ .../large_step/contracts/use_postcondition4.c | 19 ++++++++ .../contracts/use_postcondition4.desc | 8 ++++ .../large_step/contracts/use_precondition1.c | 8 ++++ .../contracts/use_precondition1.desc | 8 ++++ .../large_step/contracts/use_precondition2.c | 8 ++++ .../contracts/use_precondition2.desc | 9 ++++ .../cprover/large_step/cstrings/cstring1.c | 7 +++ .../cprover/large_step/cstrings/cstring1.desc | 7 +++ .../cprover/large_step/cstrings/cstring10.c | 9 ++++ .../large_step/cstrings/cstring10.desc | 7 +++ .../cprover/large_step/cstrings/cstring2.c | 10 +++++ .../cprover/large_step/cstrings/cstring2.desc | 7 +++ .../cprover/large_step/cstrings/cstring3.c | 8 ++++ .../cprover/large_step/cstrings/cstring3.desc | 7 +++ .../cprover/large_step/cstrings/cstring4.c | 8 ++++ .../cprover/large_step/cstrings/cstring4.desc | 7 +++ .../cprover/large_step/cstrings/cstring5.c | 9 ++++ .../cprover/large_step/cstrings/cstring5.desc | 7 +++ .../cprover/large_step/cstrings/cstring6.c | 9 ++++ .../cprover/large_step/cstrings/cstring6.desc | 8 ++++ .../cprover/large_step/cstrings/cstring7.c | 8 ++++ .../cprover/large_step/cstrings/cstring7.desc | 7 +++ .../cprover/large_step/cstrings/cstring8.c | 9 ++++ .../cprover/large_step/cstrings/cstring8.desc | 7 +++ .../cprover/large_step/cstrings/cstring9.c | 12 ++++++ .../cprover/large_step/cstrings/cstring9.desc | 7 +++ .../cstrings/cstring_is_function1.c | 9 ++++ .../cstrings/cstring_is_function1.desc | 7 +++ .../cstrings/cstring_is_memory_safe1.c | 12 ++++++ .../cstrings/cstring_is_memory_safe1.desc | 8 ++++ .../cstrings/cstring_is_memory_safe2.c | 10 +++++ .../cstrings/cstring_is_memory_safe2.desc | 7 +++ .../cstrings/cstring_is_memory_safe3.c | 12 ++++++ .../cstrings/cstring_is_memory_safe3.desc | 7 +++ .../large_step/cstrings/cstring_is_not_null.c | 10 +++++ .../cstrings/cstring_is_not_null.desc | 7 +++ .../large_step/cstrings/cstring_plus_one1.c | 10 +++++ .../cstrings/cstring_plus_one1.desc | 7 +++ .../large_step/cstrings/cstring_plus_one2.c | 13 ++++++ .../cstrings/cstring_plus_one2.desc | 7 +++ .../large_step/cstrings/cstring_plus_one3.c | 10 +++++ .../cstrings/cstring_plus_one3.desc | 7 +++ .../large_step/cstrings/cstring_plus_one4.c | 11 +++++ .../cstrings/cstring_plus_one4.desc | 7 +++ .../large_step/cstrings/cstring_plus_one5.c | 14 ++++++ .../cstrings/cstring_plus_one5.desc | 8 ++++ .../large_step/cstrings/cstring_preserved1.c | 13 ++++++ .../cstrings/cstring_preserved1.desc | 7 +++ .../large_step/cstrings/cstring_preserved2.c | 8 ++++ .../cstrings/cstring_preserved2.desc | 7 +++ .../cprover/large_step/cstrings/cstrlen1.c | 7 +++ .../cprover/large_step/cstrings/cstrlen1.desc | 7 +++ .../cprover/large_step/cstrings/cstrlen2.c | 5 +++ .../cprover/large_step/cstrings/cstrlen2.desc | 7 +++ .../cstrings/iterate_over_string1.c | 16 +++++++ .../cstrings/iterate_over_string1.desc | 7 +++ .../cstrings/iterate_over_string2.c | 18 ++++++++ .../cstrings/iterate_over_string2.desc | 7 +++ .../cstrings/iterate_over_string3.c | 37 ++++++++++++++++ .../cstrings/iterate_over_string3.desc | 7 +++ .../large_step/cstrings/string_literal1.c | 8 ++++ .../large_step/cstrings/string_literal1.desc | 8 ++++ .../large_step/cstrings/string_literal2.c | 11 +++++ .../large_step/cstrings/string_literal2.desc | 6 +++ .../large_step/cstrings/string_literal3.c | 7 +++ .../large_step/cstrings/string_literal3.desc | 8 ++++ .../large_step/cstrings/string_literal4.c | 7 +++ .../large_step/cstrings/string_literal4.desc | 6 +++ .../cprover/large_step/cstrings/strlen1.c | 21 +++++++++ .../cprover/large_step/cstrings/strlen1.desc | 6 +++ .../cprover/large_step/cstrings/strlen2.c | 7 +++ .../cprover/large_step/cstrings/strlen2.desc | 8 ++++ .../cprover/large_step/float/basic-float1.c | 6 +++ .../large_step/float/basic-float1.desc | 9 ++++ .../cprover/large_step/function_calls/call1.c | 11 +++++ .../large_step/function_calls/call1.desc | 7 +++ .../cprover/large_step/function_calls/call2.c | 9 ++++ .../large_step/function_calls/call2.desc | 7 +++ .../cprover/large_step/function_calls/call3.c | 16 +++++++ .../large_step/function_calls/call3.desc | 7 +++ .../cprover/large_step/function_calls/call4.c | 12 ++++++ .../large_step/function_calls/call4.desc | 7 +++ .../cprover/large_step/function_calls/call5.c | 11 +++++ .../large_step/function_calls/call5.desc | 7 +++ .../cprover/large_step/function_calls/call6.c | 11 +++++ .../large_step/function_calls/call6.desc | 7 +++ .../cprover/large_step/function_calls/call7.c | 11 +++++ .../large_step/function_calls/call7.desc | 7 +++ .../cprover/large_step/function_calls/call8.c | 10 +++++ .../large_step/function_calls/call8.desc | 7 +++ .../large_step/function_calls/call_no_body1.c | 7 +++ .../function_calls/call_no_body1.desc | 9 ++++ .../large_step/function_calls/call_no_body2.c | 12 ++++++ .../function_calls/call_no_body2.desc | 7 +++ .../large_step/function_calls/call_twice1.c | 16 +++++++ .../function_calls/call_twice1.desc | 8 ++++ .../function_calls/function_pointer1.c | 17 ++++++++ .../function_calls/function_pointer1.desc | 8 ++++ .../large_step/function_calls/no_main1.c | 4 ++ .../large_step/function_calls/no_main1.desc | 7 +++ .../large_step/function_calls/recursion1.c | 9 ++++ .../large_step/function_calls/recursion1.desc | 6 +++ .../large_step/function_calls/va_args1.c | 19 ++++++++ .../large_step/function_calls/va_args1.desc | 7 +++ .../large_step/function_calls/va_args2.c | 18 ++++++++ .../large_step/function_calls/va_args2.desc | 8 ++++ .../large_step/function_calls/va_args3.c | 22 ++++++++++ .../large_step/function_calls/va_args3.desc | 9 ++++ .../function_pointers/malloc_wrapper.c | 13 ++++++ .../function_pointers/malloc_wrapper.desc | 7 +++ .../cprover/large_step/lists/sentinel_dll1.c | 28 ++++++++++++ .../large_step/lists/sentinel_dll1.desc | 7 +++ .../cprover/large_step/lists/sentinel_dll2.c | 34 +++++++++++++++ .../large_step/lists/sentinel_dll2.desc | 7 +++ .../cprover/large_step/lists/sentinel_dll3.c | 35 +++++++++++++++ .../large_step/lists/sentinel_dll3.desc | 7 +++ .../cprover/large_step/lists/sentinel_dll4.c | 32 ++++++++++++++ .../large_step/lists/sentinel_dll4.desc | 7 +++ .../cprover/large_step/lists/sentinel_dll5.c | 30 +++++++++++++ .../large_step/lists/sentinel_dll5.desc | 7 +++ .../cprover/large_step/loops/assigns1.c | 11 +++++ .../cprover/large_step/loops/assigns1.desc | 8 ++++ .../cprover/large_step/loops/assigns2.c | 12 ++++++ .../cprover/large_step/loops/assigns2.desc | 8 ++++ .../cprover/large_step/loops/block_loop.c | 17 ++++++++ .../cprover/large_step/loops/block_loop.desc | 6 +++ regression/cprover/large_step/loops/copy1.c | 22 ++++++++++ .../cprover/large_step/loops/copy1.desc | 14 ++++++ .../cprover/large_step/loops/count_up1.c | 18 ++++++++ .../cprover/large_step/loops/count_up1.desc | 8 ++++ .../cprover/large_step/loops/count_up2.c | 16 +++++++ .../cprover/large_step/loops/count_up2.desc | 8 ++++ .../cprover/large_step/loops/count_up3.c | 21 +++++++++ .../cprover/large_step/loops/count_up3.desc | 9 ++++ .../cprover/large_step/loops/count_up4.c | 20 +++++++++ .../cprover/large_step/loops/count_up4.desc | 9 ++++ .../cprover/large_step/loops/do_while1.c | 15 +++++++ .../cprover/large_step/loops/do_while1.desc | 14 ++++++ .../cprover/large_step/loops/do_while_false.c | 13 ++++++ .../large_step/loops/do_while_false.desc | 8 ++++ .../cprover/large_step/loops/failure1.c | 12 ++++++ .../cprover/large_step/loops/failure1.desc | 8 ++++ regression/cprover/large_step/loops/for1.c | 11 +++++ regression/cprover/large_step/loops/for1.desc | 16 +++++++ regression/cprover/large_step/loops/for2.c | 10 +++++ regression/cprover/large_step/loops/for2.desc | 14 ++++++ .../cprover/large_step/loops/for_loop1.c | 14 ++++++ .../cprover/large_step/loops/for_loop1.desc | 8 ++++ .../cprover/large_step/loops/for_loop2.c | 16 +++++++ .../cprover/large_step/loops/for_loop2.desc | 8 ++++ .../cprover/large_step/loops/for_loop3.c | 14 ++++++ .../cprover/large_step/loops/for_loop3.desc | 8 ++++ .../cprover/large_step/loops/forward1.c | 12 ++++++ .../cprover/large_step/loops/forward1.desc | 7 +++ .../large_step/loops/given_invariant1.c | 14 ++++++ .../large_step/loops/given_invariant1.desc | 9 ++++ .../large_step/loops/given_invariant2.c | 14 ++++++ .../large_step/loops/given_invariant2.desc | 9 ++++ .../large_step/loops/given_invariant3.c | 16 +++++++ .../large_step/loops/given_invariant3.desc | 9 ++++ .../large_step/loops/given_invariant4.c | 16 +++++++ .../large_step/loops/given_invariant4.desc | 9 ++++ .../large_step/loops/given_invariant5.c | 16 +++++++ .../large_step/loops/given_invariant5.desc | 9 ++++ .../large_step/loops/given_invariant6.c | 12 ++++++ .../large_step/loops/given_invariant6.desc | 9 ++++ .../large_step/loops/given_invariant7.c | 16 +++++++ .../large_step/loops/given_invariant7.desc | 9 ++++ .../large_step/loops/given_invariant8.c | 17 ++++++++ .../large_step/loops/given_invariant8.desc | 9 ++++ .../large_step/loops/given_invariant9.c | 19 ++++++++ .../large_step/loops/given_invariant9.desc | 10 +++++ .../cprover/large_step/loops/nondet_loop1.c | 12 ++++++ .../large_step/loops/nondet_loop1.desc | 7 +++ .../cprover/large_step/loops/while-break1.c | 12 ++++++ .../large_step/loops/while-break1.desc | 17 ++++++++ .../cprover/large_step/loops/while-true1.c | 8 ++++ .../cprover/large_step/loops/while-true1.desc | 8 ++++ .../cprover/large_step/loops/while_loop1.c | 17 ++++++++ .../cprover/large_step/loops/while_loop1.desc | 8 ++++ .../cprover/large_step/loops/while_loop2.c | 11 +++++ .../cprover/large_step/loops/while_loop2.desc | 7 +++ .../cprover/large_step/pointers/aliasing1.c | 12 ++++++ .../large_step/pointers/aliasing1.desc | 7 +++ .../cprover/large_step/pointers/aliasing2.c | 12 ++++++ .../large_step/pointers/aliasing2.desc | 7 +++ .../large_step/pointers/char_pointers1.c | 10 +++++ .../large_step/pointers/char_pointers1.desc | 7 +++ .../large_step/pointers/char_pointers2.c | 12 ++++++ .../large_step/pointers/char_pointers2.desc | 20 +++++++++ .../cprover/large_step/pointers/const1.c | 9 ++++ .../cprover/large_step/pointers/const1.desc | 7 +++ .../cprover/large_step/pointers/const2.c | 8 ++++ .../cprover/large_step/pointers/const2.desc | 7 +++ .../cprover/large_step/pointers/disjoint1.c | 12 ++++++ .../large_step/pointers/disjoint1.desc | 7 +++ .../cprover/large_step/pointers/hex_encode.c | 43 +++++++++++++++++++ .../large_step/pointers/hex_encode.desc | 6 +++ .../cprover/large_step/pointers/local1.c | 12 ++++++ .../cprover/large_step/pointers/local1.desc | 7 +++ .../cprover/large_step/pointers/malloc1.c | 11 +++++ .../cprover/large_step/pointers/malloc1.desc | 8 ++++ .../cprover/large_step/pointers/malloc2.c | 12 ++++++ .../cprover/large_step/pointers/malloc2.desc | 7 +++ .../cprover/large_step/pointers/malloc3.c | 9 ++++ .../cprover/large_step/pointers/malloc3.desc | 7 +++ .../large_step/pointers/pointer_array1.c | 12 ++++++ .../large_step/pointers/pointer_array1.desc | 9 ++++ .../pointers/pointer_into_struct1.c | 12 ++++++ .../pointers/pointer_into_struct1.desc | 7 +++ .../large_step/pointers/pointer_logic1.c | 14 ++++++ .../large_step/pointers/pointer_logic1.desc | 8 ++++ .../large_step/pointers/pointer_logic2.c | 16 +++++++ .../large_step/pointers/pointer_logic2.desc | 8 ++++ .../large_step/pointers/pointer_logic3.c | 19 ++++++++ .../large_step/pointers/pointer_logic3.desc | 9 ++++ .../large_step/pointers/pointer_to_local1.c | 8 ++++ .../pointers/pointer_to_local1.desc | 7 +++ .../large_step/pointers/pointer_to_pointer1.c | 12 ++++++ .../pointers/pointer_to_pointer1.desc | 7 +++ .../cprover/large_step/pointers/pointers0.c | 7 +++ .../large_step/pointers/pointers0.desc | 9 ++++ .../cprover/large_step/pointers/pointers1.c | 11 +++++ .../large_step/pointers/pointers1.desc | 11 +++++ .../cprover/large_step/pointers/pointers10.c | 13 ++++++ .../large_step/pointers/pointers10.desc | 7 +++ .../cprover/large_step/pointers/pointers11.c | 7 +++ .../large_step/pointers/pointers11.desc | 7 +++ .../cprover/large_step/pointers/pointers12.c | 9 ++++ .../large_step/pointers/pointers12.desc | 7 +++ .../cprover/large_step/pointers/pointers2.c | 12 ++++++ .../large_step/pointers/pointers2.desc | 14 ++++++ .../cprover/large_step/pointers/pointers3.c | 6 +++ .../large_step/pointers/pointers3.desc | 9 ++++ .../cprover/large_step/pointers/pointers4.c | 12 ++++++ .../large_step/pointers/pointers4.desc | 11 +++++ .../cprover/large_step/pointers/pointers5.c | 11 +++++ .../large_step/pointers/pointers5.desc | 9 ++++ .../cprover/large_step/pointers/pointers6.c | 12 ++++++ .../large_step/pointers/pointers6.desc | 11 +++++ .../cprover/large_step/pointers/pointers7.c | 11 +++++ .../large_step/pointers/pointers7.desc | 16 +++++++ .../cprover/large_step/pointers/pointers8.c | 11 +++++ .../large_step/pointers/pointers8.desc | 10 +++++ .../cprover/large_step/pointers/pointers9.c | 10 +++++ .../large_step/pointers/pointers9.desc | 11 +++++ .../large_step/pointers/posix_memalign1.c | 9 ++++ .../large_step/pointers/posix_memalign1.desc | 7 +++ .../large_step/pointers/struct_pointer1.c | 14 ++++++ .../large_step/pointers/struct_pointer1.desc | 10 +++++ .../large_step/pointers/struct_pointer2.c | 15 +++++++ .../large_step/pointers/struct_pointer2.desc | 10 +++++ .../large_step/pointers/struct_pointer3.c | 12 ++++++ .../large_step/pointers/struct_pointer3.desc | 7 +++ .../large_step/pointers/struct_pointer4.c | 13 ++++++ .../large_step/pointers/struct_pointer4.desc | 7 +++ .../large_step/pointers/struct_pointer5.c | 13 ++++++ .../large_step/pointers/struct_pointer5.desc | 7 +++ .../large_step/pointers/struct_pointer6.c | 16 +++++++ .../large_step/pointers/struct_pointer6.desc | 7 +++ .../cprover/large_step/quantifiers/exists1.c | 5 +++ .../large_step/quantifiers/exists1.desc | 10 +++++ .../cprover/large_step/quantifiers/forall1.c | 8 ++++ .../large_step/quantifiers/forall1.desc | 12 ++++++ .../cprover/large_step/quantifiers/zeros1.c | 10 +++++ .../large_step/quantifiers/zeros1.desc | 7 +++ .../cprover/large_step/safety/array_bounds1.c | 8 ++++ .../large_step/safety/array_bounds1.desc | 9 ++++ .../cprover/large_step/safety/array_bounds2.c | 9 ++++ .../large_step/safety/array_bounds2.desc | 9 ++++ .../cprover/large_step/safety/array_bounds3.c | 12 ++++++ .../large_step/safety/array_bounds3.desc | 7 +++ .../cprover/large_step/safety/array_bounds4.c | 11 +++++ .../large_step/safety/array_bounds4.desc | 7 +++ regression/cprover/large_step/safety/const1.c | 8 ++++ .../cprover/large_step/safety/const1.desc | 7 +++ .../large_step/safety/division_by_zero.c | 9 ++++ .../large_step/safety/division_by_zero.desc | 8 ++++ .../large_step/safety/division_by_zero2.c | 11 +++++ .../large_step/safety/division_by_zero2.desc | 7 +++ .../cprover/large_step/safety/double_free1.c | 8 ++++ .../large_step/safety/double_free1.desc | 8 ++++ .../large_step/safety/dynamic_object1.c | 13 ++++++ .../large_step/safety/dynamic_object1.desc | 8 ++++ regression/cprover/large_step/safety/free1.c | 10 +++++ .../cprover/large_step/safety/free1.desc | 8 ++++ regression/cprover/large_step/safety/free2.c | 9 ++++ .../cprover/large_step/safety/free2.desc | 7 +++ regression/cprover/large_step/safety/free3.c | 11 +++++ .../cprover/large_step/safety/free3.desc | 6 +++ regression/cprover/large_step/safety/free4.c | 20 +++++++++ .../cprover/large_step/safety/free4.desc | 6 +++ .../cprover/large_step/safety/free_null1.c | 7 +++ .../cprover/large_step/safety/free_null1.desc | 8 ++++ .../cprover/large_step/safety/live_object1.c | 9 ++++ .../large_step/safety/live_object1.desc | 8 ++++ .../large_step/safety/local_out_of_scope1.c | 12 ++++++ .../safety/local_out_of_scope1.desc | 8 ++++ .../large_step/safety/local_out_of_scope2.c | 11 +++++ .../safety/local_out_of_scope2.desc | 7 +++ .../large_step/safety/local_out_of_scope3.c | 10 +++++ .../safety/local_out_of_scope3.desc | 8 ++++ .../cprover/large_step/safety/malloc1.c | 15 +++++++ .../cprover/large_step/safety/malloc1.desc | 11 +++++ .../cprover/large_step/safety/memchr1.c | 8 ++++ .../cprover/large_step/safety/memchr1.desc | 8 ++++ .../cprover/large_step/safety/memcmp1.c | 8 ++++ .../cprover/large_step/safety/memcmp1.desc | 8 ++++ .../cprover/large_step/safety/memset1.c | 8 ++++ .../cprover/large_step/safety/memset1.desc | 8 ++++ .../cprover/large_step/safety/memset2.c | 8 ++++ .../cprover/large_step/safety/memset2.desc | 8 ++++ .../large_step/safety/null_dereference1.c | 6 +++ .../large_step/safety/null_dereference1.desc | 7 +++ .../cprover/large_step/safety/null_object1.c | 6 +++ .../large_step/safety/null_object1.desc | 7 +++ .../cprover/large_step/safety/object_size1.c | 12 ++++++ .../large_step/safety/object_size1.desc | 8 ++++ .../large_step/safety/pointer_to_pointer1.c | 13 ++++++ .../safety/pointer_to_pointer1.desc | 8 ++++ regression/cprover/large_step/safety/r_ok1.c | 9 ++++ .../cprover/large_step/safety/r_ok1.desc | 8 ++++ regression/cprover/large_step/safety/r_ok2.c | 26 +++++++++++ .../cprover/large_step/safety/r_ok2.desc | 12 ++++++ regression/cprover/large_step/safety/r_ok3.c | 13 ++++++ .../cprover/large_step/safety/r_ok3.desc | 9 ++++ regression/cprover/large_step/safety/r_ok4.c | 8 ++++ .../cprover/large_step/safety/r_ok4.desc | 7 +++ regression/cprover/large_step/safety/r_ok5.c | 7 +++ .../cprover/large_step/safety/r_ok5.desc | 7 +++ regression/cprover/large_step/safety/r_ok6.c | 9 ++++ .../cprover/large_step/safety/r_ok6.desc | 7 +++ regression/cprover/large_step/safety/r_ok7.c | 10 +++++ .../cprover/large_step/safety/r_ok7.desc | 7 +++ regression/cprover/large_step/safety/r_ok8.c | 9 ++++ .../cprover/large_step/safety/r_ok8.desc | 10 +++++ .../large_step/safety/r_ok_is_function1.c | 10 +++++ .../large_step/safety/r_ok_is_function1.desc | 7 +++ .../cprover/large_step/safety/realloc1.c | 13 ++++++ .../cprover/large_step/safety/realloc1.desc | 10 +++++ .../cprover/large_step/safety/realloc2.c | 9 ++++ .../cprover/large_step/safety/realloc2.desc | 7 +++ .../cprover/large_step/safety/shifts1.c | 9 ++++ .../cprover/large_step/safety/shifts1.desc | 9 ++++ .../large_step/safety/simple_equality1.c | 9 ++++ .../large_step/safety/simple_equality1.desc | 8 ++++ .../large_step/safety/use_after_free1.c | 9 ++++ .../large_step/safety/use_after_free1.desc | 8 ++++ .../cprover/large_step/safety/writeable1.c | 14 ++++++ .../cprover/large_step/safety/writeable1.desc | 9 ++++ .../large_step/structs/nondet_struct1.c | 12 ++++++ .../large_step/structs/nondet_struct1.desc | 7 +++ .../cprover/large_step/structs/struct1.c | 10 +++++ .../cprover/large_step/structs/struct1.desc | 9 ++++ .../cprover/large_step/structs/struct2.c | 12 ++++++ .../cprover/large_step/structs/struct2.desc | 12 ++++++ .../cprover/large_step/structs/struct3.c | 14 ++++++ .../cprover/large_step/structs/struct3.desc | 10 +++++ .../cprover/large_step/structs/struct4.c | 11 +++++ .../cprover/large_step/structs/struct4.desc | 9 ++++ .../cprover/large_step/structs/struct5.c | 14 ++++++ .../cprover/large_step/structs/struct5.desc | 7 +++ regression/cprover/large_step/trace/trace1.c | 12 ++++++ .../cprover/large_step/trace/trace1.desc | 10 +++++ regression/cprover/large_step/trace/trace3.c | 10 +++++ .../cprover/large_step/trace/trace3.desc | 8 ++++ .../cprover/large_step/trace/trace_array1.c | 18 ++++++++ .../large_step/trace/trace_array1.desc | 14 ++++++ .../large_step/trace/trace_contract1.c | 7 +++ .../large_step/trace/trace_contract1.desc | 8 ++++ .../large_step/trace/trace_function_call1.c | 11 +++++ .../trace/trace_function_call1.desc | 10 +++++ .../cprover/large_step/trace/trace_malloc1.c | 11 +++++ .../large_step/trace/trace_malloc1.desc | 11 +++++ .../cprover/large_step/trace/trace_malloc2.c | 11 +++++ .../large_step/trace/trace_malloc2.desc | 9 ++++ .../cprover/large_step/trace/trace_nondet1.c | 8 ++++ .../large_step/trace/trace_nondet1.desc | 8 ++++ .../cprover/large_step/trace/trace_pointer1.c | 9 ++++ .../large_step/trace/trace_pointer1.desc | 9 ++++ .../cprover/large_step/trace/trace_pointer2.c | 9 ++++ .../large_step/trace/trace_pointer2.desc | 9 ++++ .../cprover/large_step/trace/trace_pointer3.c | 11 +++++ .../large_step/trace/trace_pointer3.desc | 9 ++++ .../cprover/large_step/trace/trace_struct1.c | 13 ++++++ .../large_step/trace/trace_struct1.desc | 9 ++++ regression/cprover/large_step/unions/union1.c | 18 ++++++++ .../cprover/large_step/unions/union1.desc | 8 ++++ regression/cprover/large_step/unions/union2.c | 16 +++++++ .../cprover/large_step/unions/union2.desc | 7 +++ 531 files changed, 5572 insertions(+) create mode 100644 regression/cprover/large_step/CMakeLists.txt create mode 100644 regression/cprover/large_step/Makefile create mode 100644 regression/cprover/large_step/arrays/array1.c create mode 100644 regression/cprover/large_step/arrays/array1.desc create mode 100644 regression/cprover/large_step/arrays/array2.c create mode 100644 regression/cprover/large_step/arrays/array2.desc create mode 100644 regression/cprover/large_step/arrays/array4.c create mode 100644 regression/cprover/large_step/arrays/array4.desc create mode 100644 regression/cprover/large_step/arrays/array_literal1.c create mode 100644 regression/cprover/large_step/arrays/array_literal1.desc create mode 100644 regression/cprover/large_step/arrays/array_literal2.c create mode 100644 regression/cprover/large_step/arrays/array_r_ok1.c create mode 100644 regression/cprover/large_step/arrays/array_r_ok1.desc create mode 100644 regression/cprover/large_step/arrays/array_set1.c create mode 100644 regression/cprover/large_step/arrays/array_set1.desc create mode 100644 regression/cprover/large_step/arrays/iterate_over_array1.c create mode 100644 regression/cprover/large_step/arrays/iterate_over_array1.desc create mode 100644 regression/cprover/large_step/arrays/iterate_over_array2.c create mode 100644 regression/cprover/large_step/arrays/iterate_over_array2.desc create mode 100644 regression/cprover/large_step/aws-c-common/aws_array_eq_c_str.desc create mode 100644 regression/cprover/large_step/aws-c-common/aws_array_eq_c_str_contract.c create mode 100644 regression/cprover/large_step/aws-c-common/aws_array_eq_c_str_ignore_case.desc create mode 100644 regression/cprover/large_step/aws-c-common/aws_array_eq_c_str_ignore_case_contract.c create mode 100644 regression/cprover/large_step/aws-c-common/aws_array_eq_ignore_case.desc create mode 100644 regression/cprover/large_step/aws-c-common/aws_array_eq_ignore_case_contract.c create mode 100644 regression/cprover/large_step/aws-c-common/aws_hash_table_clear.desc create mode 100644 regression/cprover/large_step/aws-c-common/aws_hash_table_clear_contract.c create mode 100644 regression/cprover/large_step/aws-c-common/aws_hash_table_eq.desc create mode 100644 regression/cprover/large_step/aws-c-common/aws_hash_table_eq_contract.c create mode 100644 regression/cprover/large_step/aws-c-common/aws_hash_table_foreach.desc create mode 100644 regression/cprover/large_step/aws-c-common/aws_hash_table_foreach_contract.c create mode 100644 regression/cprover/large_step/aws-c-common/setup create mode 100644 regression/cprover/large_step/aws-c-common/todo/aws_array_list_mem_swap.desc create mode 100644 regression/cprover/large_step/aws-c-common/todo/aws_array_list_mem_swap_contract.c create mode 100644 regression/cprover/large_step/aws-c-common/todo/aws_byte_buf_append_with_lookup.desc create mode 100644 regression/cprover/large_step/aws-c-common/todo/aws_byte_buf_append_with_lookup_contract.c create mode 100644 regression/cprover/large_step/aws-c-common/todo/aws_hash_array_ignore_case.desc create mode 100644 regression/cprover/large_step/aws-c-common/todo/aws_hash_array_ignore_case_contract.c create mode 100644 regression/cprover/large_step/aws-c-common/todo/hashlittle2.desc create mode 100644 regression/cprover/large_step/aws-c-common/todo/hashlittle2_contract.c create mode 100644 regression/cprover/large_step/aws-c-common/todo/memcpy_using_uint64_impl.desc create mode 100644 regression/cprover/large_step/aws-c-common/todo/memcpy_using_uint64_impl_contract.c create mode 100644 regression/cprover/large_step/aws-c-common/todo/memset_override_0_impl.desc create mode 100644 regression/cprover/large_step/aws-c-common/todo/memset_override_0_impl_contract.c create mode 100644 regression/cprover/large_step/aws-c-common/todo/memset_using_uint64_impl.desc create mode 100644 regression/cprover/large_step/aws-c-common/todo/memset_using_uint64_impl_contract.c create mode 100644 regression/cprover/large_step/aws-c-common/todo/s_find_entry1.desc create mode 100644 regression/cprover/large_step/aws-c-common/todo/s_find_entry1_contract.c create mode 100644 regression/cprover/large_step/aws-c-common/todo/s_get_next_element.desc create mode 100644 regression/cprover/large_step/aws-c-common/todo/s_get_next_element_contract.c create mode 100644 regression/cprover/large_step/aws-c-common/todo/s_sift_down.desc create mode 100644 regression/cprover/large_step/aws-c-common/todo/s_sift_down_contract.c create mode 100644 regression/cprover/large_step/aws-c-common/todo/s_sift_up.desc create mode 100644 regression/cprover/large_step/aws-c-common/todo/s_sift_up_contract.c create mode 100644 regression/cprover/large_step/basic/assume1.c create mode 100644 regression/cprover/large_step/basic/assume1.desc create mode 100644 regression/cprover/large_step/basic/basic1.c create mode 100644 regression/cprover/large_step/basic/basic1.desc create mode 100644 regression/cprover/large_step/basic/basic2.c create mode 100644 regression/cprover/large_step/basic/basic2.desc create mode 100644 regression/cprover/large_step/basic/basic3.c create mode 100644 regression/cprover/large_step/basic/basic3.desc create mode 100644 regression/cprover/large_step/basic/basic4.c create mode 100644 regression/cprover/large_step/basic/basic4.desc create mode 100644 regression/cprover/large_step/basic/basic5.c create mode 100644 regression/cprover/large_step/basic/basic5.desc create mode 100644 regression/cprover/large_step/basic/basic6.c create mode 100644 regression/cprover/large_step/basic/basic6.desc create mode 100644 regression/cprover/large_step/basic/extern1.c create mode 100644 regression/cprover/large_step/basic/extern1.desc create mode 100644 regression/cprover/large_step/basic/no-assertions1.c create mode 100644 regression/cprover/large_step/basic/no-assertions1.desc create mode 100644 regression/cprover/large_step/basic/nondet1.c create mode 100644 regression/cprover/large_step/basic/nondet1.desc create mode 100644 regression/cprover/large_step/branching/branching1.c create mode 100644 regression/cprover/large_step/branching/branching1.desc create mode 100644 regression/cprover/large_step/branching/branching2.c create mode 100644 regression/cprover/large_step/branching/branching2.desc create mode 100644 regression/cprover/large_step/contracts/check_assigns1.c create mode 100644 regression/cprover/large_step/contracts/check_assigns1.desc create mode 100644 regression/cprover/large_step/contracts/check_assigns2.c create mode 100644 regression/cprover/large_step/contracts/check_assigns2.desc create mode 100644 regression/cprover/large_step/contracts/check_assigns3.c create mode 100644 regression/cprover/large_step/contracts/check_assigns3.desc create mode 100644 regression/cprover/large_step/contracts/check_assigns4.c create mode 100644 regression/cprover/large_step/contracts/check_assigns4.desc create mode 100644 regression/cprover/large_step/contracts/check_assigns5.c create mode 100644 regression/cprover/large_step/contracts/check_assigns5.desc create mode 100644 regression/cprover/large_step/contracts/check_assigns6.c create mode 100644 regression/cprover/large_step/contracts/check_assigns6.desc create mode 100644 regression/cprover/large_step/contracts/check_postcondition1.c create mode 100644 regression/cprover/large_step/contracts/check_postcondition1.desc create mode 100644 regression/cprover/large_step/contracts/check_postcondition2.c create mode 100644 regression/cprover/large_step/contracts/check_postcondition2.desc create mode 100644 regression/cprover/large_step/contracts/check_postcondition3.c create mode 100644 regression/cprover/large_step/contracts/check_postcondition3.desc create mode 100644 regression/cprover/large_step/contracts/check_postcondition4.c create mode 100644 regression/cprover/large_step/contracts/check_postcondition4.desc create mode 100644 regression/cprover/large_step/contracts/check_postcondition5.c create mode 100644 regression/cprover/large_step/contracts/check_postcondition5.desc create mode 100644 regression/cprover/large_step/contracts/check_postcondition6.c create mode 100644 regression/cprover/large_step/contracts/check_postcondition6.desc create mode 100644 regression/cprover/large_step/contracts/check_precondition1.c create mode 100644 regression/cprover/large_step/contracts/check_precondition1.desc create mode 100644 regression/cprover/large_step/contracts/check_precondition2.c create mode 100644 regression/cprover/large_step/contracts/check_precondition2.desc create mode 100644 regression/cprover/large_step/contracts/check_return_value1.c create mode 100644 regression/cprover/large_step/contracts/check_return_value1.desc create mode 100644 regression/cprover/large_step/contracts/configured_contract1.c create mode 100644 regression/cprover/large_step/contracts/configured_contract1.desc create mode 100644 regression/cprover/large_step/contracts/configured_contract2.c create mode 100644 regression/cprover/large_step/contracts/configured_contract2.desc create mode 100644 regression/cprover/large_step/contracts/integer_range1.c create mode 100644 regression/cprover/large_step/contracts/integer_range1.desc create mode 100644 regression/cprover/large_step/contracts/integer_range2.c create mode 100644 regression/cprover/large_step/contracts/integer_range2.desc create mode 100644 regression/cprover/large_step/contracts/integer_range3.c create mode 100644 regression/cprover/large_step/contracts/integer_range3.desc create mode 100644 regression/cprover/large_step/contracts/integer_range4.c create mode 100644 regression/cprover/large_step/contracts/integer_range4.desc create mode 100644 regression/cprover/large_step/contracts/memory_safety1.c create mode 100644 regression/cprover/large_step/contracts/memory_safety1.desc create mode 100644 regression/cprover/large_step/contracts/nested1.c create mode 100644 regression/cprover/large_step/contracts/nested1.desc create mode 100644 regression/cprover/large_step/contracts/one_function1.c create mode 100644 regression/cprover/large_step/contracts/one_function1.desc create mode 100644 regression/cprover/large_step/contracts/recursive_function1.c create mode 100644 regression/cprover/large_step/contracts/recursive_function1.desc create mode 100644 regression/cprover/large_step/contracts/recursive_function2.c create mode 100644 regression/cprover/large_step/contracts/recursive_function2.desc create mode 100644 regression/cprover/large_step/contracts/use_assigns1.c create mode 100644 regression/cprover/large_step/contracts/use_assigns1.desc create mode 100644 regression/cprover/large_step/contracts/use_assigns2.c create mode 100644 regression/cprover/large_step/contracts/use_assigns2.desc create mode 100644 regression/cprover/large_step/contracts/use_old1.c create mode 100644 regression/cprover/large_step/contracts/use_old1.desc create mode 100644 regression/cprover/large_step/contracts/use_old2.c create mode 100644 regression/cprover/large_step/contracts/use_old2.desc create mode 100644 regression/cprover/large_step/contracts/use_postcondition1.c create mode 100644 regression/cprover/large_step/contracts/use_postcondition1.desc create mode 100644 regression/cprover/large_step/contracts/use_postcondition2.c create mode 100644 regression/cprover/large_step/contracts/use_postcondition4.c create mode 100644 regression/cprover/large_step/contracts/use_postcondition4.desc create mode 100644 regression/cprover/large_step/contracts/use_precondition1.c create mode 100644 regression/cprover/large_step/contracts/use_precondition1.desc create mode 100644 regression/cprover/large_step/contracts/use_precondition2.c create mode 100644 regression/cprover/large_step/contracts/use_precondition2.desc create mode 100644 regression/cprover/large_step/cstrings/cstring1.c create mode 100644 regression/cprover/large_step/cstrings/cstring1.desc create mode 100644 regression/cprover/large_step/cstrings/cstring10.c create mode 100644 regression/cprover/large_step/cstrings/cstring10.desc create mode 100644 regression/cprover/large_step/cstrings/cstring2.c create mode 100644 regression/cprover/large_step/cstrings/cstring2.desc create mode 100644 regression/cprover/large_step/cstrings/cstring3.c create mode 100644 regression/cprover/large_step/cstrings/cstring3.desc create mode 100644 regression/cprover/large_step/cstrings/cstring4.c create mode 100644 regression/cprover/large_step/cstrings/cstring4.desc create mode 100644 regression/cprover/large_step/cstrings/cstring5.c create mode 100644 regression/cprover/large_step/cstrings/cstring5.desc create mode 100644 regression/cprover/large_step/cstrings/cstring6.c create mode 100644 regression/cprover/large_step/cstrings/cstring6.desc create mode 100644 regression/cprover/large_step/cstrings/cstring7.c create mode 100644 regression/cprover/large_step/cstrings/cstring7.desc create mode 100644 regression/cprover/large_step/cstrings/cstring8.c create mode 100644 regression/cprover/large_step/cstrings/cstring8.desc create mode 100644 regression/cprover/large_step/cstrings/cstring9.c create mode 100644 regression/cprover/large_step/cstrings/cstring9.desc create mode 100644 regression/cprover/large_step/cstrings/cstring_is_function1.c create mode 100644 regression/cprover/large_step/cstrings/cstring_is_function1.desc create mode 100644 regression/cprover/large_step/cstrings/cstring_is_memory_safe1.c create mode 100644 regression/cprover/large_step/cstrings/cstring_is_memory_safe1.desc create mode 100644 regression/cprover/large_step/cstrings/cstring_is_memory_safe2.c create mode 100644 regression/cprover/large_step/cstrings/cstring_is_memory_safe2.desc create mode 100644 regression/cprover/large_step/cstrings/cstring_is_memory_safe3.c create mode 100644 regression/cprover/large_step/cstrings/cstring_is_memory_safe3.desc create mode 100644 regression/cprover/large_step/cstrings/cstring_is_not_null.c create mode 100644 regression/cprover/large_step/cstrings/cstring_is_not_null.desc create mode 100644 regression/cprover/large_step/cstrings/cstring_plus_one1.c create mode 100644 regression/cprover/large_step/cstrings/cstring_plus_one1.desc create mode 100644 regression/cprover/large_step/cstrings/cstring_plus_one2.c create mode 100644 regression/cprover/large_step/cstrings/cstring_plus_one2.desc create mode 100644 regression/cprover/large_step/cstrings/cstring_plus_one3.c create mode 100644 regression/cprover/large_step/cstrings/cstring_plus_one3.desc create mode 100644 regression/cprover/large_step/cstrings/cstring_plus_one4.c create mode 100644 regression/cprover/large_step/cstrings/cstring_plus_one4.desc create mode 100644 regression/cprover/large_step/cstrings/cstring_plus_one5.c create mode 100644 regression/cprover/large_step/cstrings/cstring_plus_one5.desc create mode 100644 regression/cprover/large_step/cstrings/cstring_preserved1.c create mode 100644 regression/cprover/large_step/cstrings/cstring_preserved1.desc create mode 100644 regression/cprover/large_step/cstrings/cstring_preserved2.c create mode 100644 regression/cprover/large_step/cstrings/cstring_preserved2.desc create mode 100644 regression/cprover/large_step/cstrings/cstrlen1.c create mode 100644 regression/cprover/large_step/cstrings/cstrlen1.desc create mode 100644 regression/cprover/large_step/cstrings/cstrlen2.c create mode 100644 regression/cprover/large_step/cstrings/cstrlen2.desc create mode 100644 regression/cprover/large_step/cstrings/iterate_over_string1.c create mode 100644 regression/cprover/large_step/cstrings/iterate_over_string1.desc create mode 100644 regression/cprover/large_step/cstrings/iterate_over_string2.c create mode 100644 regression/cprover/large_step/cstrings/iterate_over_string2.desc create mode 100644 regression/cprover/large_step/cstrings/iterate_over_string3.c create mode 100644 regression/cprover/large_step/cstrings/iterate_over_string3.desc create mode 100644 regression/cprover/large_step/cstrings/string_literal1.c create mode 100644 regression/cprover/large_step/cstrings/string_literal1.desc create mode 100644 regression/cprover/large_step/cstrings/string_literal2.c create mode 100644 regression/cprover/large_step/cstrings/string_literal2.desc create mode 100644 regression/cprover/large_step/cstrings/string_literal3.c create mode 100644 regression/cprover/large_step/cstrings/string_literal3.desc create mode 100644 regression/cprover/large_step/cstrings/string_literal4.c create mode 100644 regression/cprover/large_step/cstrings/string_literal4.desc create mode 100644 regression/cprover/large_step/cstrings/strlen1.c create mode 100644 regression/cprover/large_step/cstrings/strlen1.desc create mode 100644 regression/cprover/large_step/cstrings/strlen2.c create mode 100644 regression/cprover/large_step/cstrings/strlen2.desc create mode 100644 regression/cprover/large_step/float/basic-float1.c create mode 100644 regression/cprover/large_step/float/basic-float1.desc create mode 100644 regression/cprover/large_step/function_calls/call1.c create mode 100644 regression/cprover/large_step/function_calls/call1.desc create mode 100644 regression/cprover/large_step/function_calls/call2.c create mode 100644 regression/cprover/large_step/function_calls/call2.desc create mode 100644 regression/cprover/large_step/function_calls/call3.c create mode 100644 regression/cprover/large_step/function_calls/call3.desc create mode 100644 regression/cprover/large_step/function_calls/call4.c create mode 100644 regression/cprover/large_step/function_calls/call4.desc create mode 100644 regression/cprover/large_step/function_calls/call5.c create mode 100644 regression/cprover/large_step/function_calls/call5.desc create mode 100644 regression/cprover/large_step/function_calls/call6.c create mode 100644 regression/cprover/large_step/function_calls/call6.desc create mode 100644 regression/cprover/large_step/function_calls/call7.c create mode 100644 regression/cprover/large_step/function_calls/call7.desc create mode 100644 regression/cprover/large_step/function_calls/call8.c create mode 100644 regression/cprover/large_step/function_calls/call8.desc create mode 100644 regression/cprover/large_step/function_calls/call_no_body1.c create mode 100644 regression/cprover/large_step/function_calls/call_no_body1.desc create mode 100644 regression/cprover/large_step/function_calls/call_no_body2.c create mode 100644 regression/cprover/large_step/function_calls/call_no_body2.desc create mode 100644 regression/cprover/large_step/function_calls/call_twice1.c create mode 100644 regression/cprover/large_step/function_calls/call_twice1.desc create mode 100644 regression/cprover/large_step/function_calls/function_pointer1.c create mode 100644 regression/cprover/large_step/function_calls/function_pointer1.desc create mode 100644 regression/cprover/large_step/function_calls/no_main1.c create mode 100644 regression/cprover/large_step/function_calls/no_main1.desc create mode 100644 regression/cprover/large_step/function_calls/recursion1.c create mode 100644 regression/cprover/large_step/function_calls/recursion1.desc create mode 100644 regression/cprover/large_step/function_calls/va_args1.c create mode 100644 regression/cprover/large_step/function_calls/va_args1.desc create mode 100644 regression/cprover/large_step/function_calls/va_args2.c create mode 100644 regression/cprover/large_step/function_calls/va_args2.desc create mode 100644 regression/cprover/large_step/function_calls/va_args3.c create mode 100644 regression/cprover/large_step/function_calls/va_args3.desc create mode 100644 regression/cprover/large_step/function_pointers/malloc_wrapper.c create mode 100644 regression/cprover/large_step/function_pointers/malloc_wrapper.desc create mode 100644 regression/cprover/large_step/lists/sentinel_dll1.c create mode 100644 regression/cprover/large_step/lists/sentinel_dll1.desc create mode 100644 regression/cprover/large_step/lists/sentinel_dll2.c create mode 100644 regression/cprover/large_step/lists/sentinel_dll2.desc create mode 100644 regression/cprover/large_step/lists/sentinel_dll3.c create mode 100644 regression/cprover/large_step/lists/sentinel_dll3.desc create mode 100644 regression/cprover/large_step/lists/sentinel_dll4.c create mode 100644 regression/cprover/large_step/lists/sentinel_dll4.desc create mode 100644 regression/cprover/large_step/lists/sentinel_dll5.c create mode 100644 regression/cprover/large_step/lists/sentinel_dll5.desc create mode 100644 regression/cprover/large_step/loops/assigns1.c create mode 100644 regression/cprover/large_step/loops/assigns1.desc create mode 100644 regression/cprover/large_step/loops/assigns2.c create mode 100644 regression/cprover/large_step/loops/assigns2.desc create mode 100644 regression/cprover/large_step/loops/block_loop.c create mode 100644 regression/cprover/large_step/loops/block_loop.desc create mode 100644 regression/cprover/large_step/loops/copy1.c create mode 100644 regression/cprover/large_step/loops/copy1.desc create mode 100644 regression/cprover/large_step/loops/count_up1.c create mode 100644 regression/cprover/large_step/loops/count_up1.desc create mode 100644 regression/cprover/large_step/loops/count_up2.c create mode 100644 regression/cprover/large_step/loops/count_up2.desc create mode 100644 regression/cprover/large_step/loops/count_up3.c create mode 100644 regression/cprover/large_step/loops/count_up3.desc create mode 100644 regression/cprover/large_step/loops/count_up4.c create mode 100644 regression/cprover/large_step/loops/count_up4.desc create mode 100644 regression/cprover/large_step/loops/do_while1.c create mode 100644 regression/cprover/large_step/loops/do_while1.desc create mode 100644 regression/cprover/large_step/loops/do_while_false.c create mode 100644 regression/cprover/large_step/loops/do_while_false.desc create mode 100644 regression/cprover/large_step/loops/failure1.c create mode 100644 regression/cprover/large_step/loops/failure1.desc create mode 100644 regression/cprover/large_step/loops/for1.c create mode 100644 regression/cprover/large_step/loops/for1.desc create mode 100644 regression/cprover/large_step/loops/for2.c create mode 100644 regression/cprover/large_step/loops/for2.desc create mode 100644 regression/cprover/large_step/loops/for_loop1.c create mode 100644 regression/cprover/large_step/loops/for_loop1.desc create mode 100644 regression/cprover/large_step/loops/for_loop2.c create mode 100644 regression/cprover/large_step/loops/for_loop2.desc create mode 100644 regression/cprover/large_step/loops/for_loop3.c create mode 100644 regression/cprover/large_step/loops/for_loop3.desc create mode 100644 regression/cprover/large_step/loops/forward1.c create mode 100644 regression/cprover/large_step/loops/forward1.desc create mode 100644 regression/cprover/large_step/loops/given_invariant1.c create mode 100644 regression/cprover/large_step/loops/given_invariant1.desc create mode 100644 regression/cprover/large_step/loops/given_invariant2.c create mode 100644 regression/cprover/large_step/loops/given_invariant2.desc create mode 100644 regression/cprover/large_step/loops/given_invariant3.c create mode 100644 regression/cprover/large_step/loops/given_invariant3.desc create mode 100644 regression/cprover/large_step/loops/given_invariant4.c create mode 100644 regression/cprover/large_step/loops/given_invariant4.desc create mode 100644 regression/cprover/large_step/loops/given_invariant5.c create mode 100644 regression/cprover/large_step/loops/given_invariant5.desc create mode 100644 regression/cprover/large_step/loops/given_invariant6.c create mode 100644 regression/cprover/large_step/loops/given_invariant6.desc create mode 100644 regression/cprover/large_step/loops/given_invariant7.c create mode 100644 regression/cprover/large_step/loops/given_invariant7.desc create mode 100644 regression/cprover/large_step/loops/given_invariant8.c create mode 100644 regression/cprover/large_step/loops/given_invariant8.desc create mode 100644 regression/cprover/large_step/loops/given_invariant9.c create mode 100644 regression/cprover/large_step/loops/given_invariant9.desc create mode 100644 regression/cprover/large_step/loops/nondet_loop1.c create mode 100644 regression/cprover/large_step/loops/nondet_loop1.desc create mode 100644 regression/cprover/large_step/loops/while-break1.c create mode 100644 regression/cprover/large_step/loops/while-break1.desc create mode 100644 regression/cprover/large_step/loops/while-true1.c create mode 100644 regression/cprover/large_step/loops/while-true1.desc create mode 100644 regression/cprover/large_step/loops/while_loop1.c create mode 100644 regression/cprover/large_step/loops/while_loop1.desc create mode 100644 regression/cprover/large_step/loops/while_loop2.c create mode 100644 regression/cprover/large_step/loops/while_loop2.desc create mode 100644 regression/cprover/large_step/pointers/aliasing1.c create mode 100644 regression/cprover/large_step/pointers/aliasing1.desc create mode 100644 regression/cprover/large_step/pointers/aliasing2.c create mode 100644 regression/cprover/large_step/pointers/aliasing2.desc create mode 100644 regression/cprover/large_step/pointers/char_pointers1.c create mode 100644 regression/cprover/large_step/pointers/char_pointers1.desc create mode 100644 regression/cprover/large_step/pointers/char_pointers2.c create mode 100644 regression/cprover/large_step/pointers/char_pointers2.desc create mode 100644 regression/cprover/large_step/pointers/const1.c create mode 100644 regression/cprover/large_step/pointers/const1.desc create mode 100644 regression/cprover/large_step/pointers/const2.c create mode 100644 regression/cprover/large_step/pointers/const2.desc create mode 100644 regression/cprover/large_step/pointers/disjoint1.c create mode 100644 regression/cprover/large_step/pointers/disjoint1.desc create mode 100644 regression/cprover/large_step/pointers/hex_encode.c create mode 100644 regression/cprover/large_step/pointers/hex_encode.desc create mode 100644 regression/cprover/large_step/pointers/local1.c create mode 100644 regression/cprover/large_step/pointers/local1.desc create mode 100644 regression/cprover/large_step/pointers/malloc1.c create mode 100644 regression/cprover/large_step/pointers/malloc1.desc create mode 100644 regression/cprover/large_step/pointers/malloc2.c create mode 100644 regression/cprover/large_step/pointers/malloc2.desc create mode 100644 regression/cprover/large_step/pointers/malloc3.c create mode 100644 regression/cprover/large_step/pointers/malloc3.desc create mode 100644 regression/cprover/large_step/pointers/pointer_array1.c create mode 100644 regression/cprover/large_step/pointers/pointer_array1.desc create mode 100644 regression/cprover/large_step/pointers/pointer_into_struct1.c create mode 100644 regression/cprover/large_step/pointers/pointer_into_struct1.desc create mode 100644 regression/cprover/large_step/pointers/pointer_logic1.c create mode 100644 regression/cprover/large_step/pointers/pointer_logic1.desc create mode 100644 regression/cprover/large_step/pointers/pointer_logic2.c create mode 100644 regression/cprover/large_step/pointers/pointer_logic2.desc create mode 100644 regression/cprover/large_step/pointers/pointer_logic3.c create mode 100644 regression/cprover/large_step/pointers/pointer_logic3.desc create mode 100644 regression/cprover/large_step/pointers/pointer_to_local1.c create mode 100644 regression/cprover/large_step/pointers/pointer_to_local1.desc create mode 100644 regression/cprover/large_step/pointers/pointer_to_pointer1.c create mode 100644 regression/cprover/large_step/pointers/pointer_to_pointer1.desc create mode 100644 regression/cprover/large_step/pointers/pointers0.c create mode 100644 regression/cprover/large_step/pointers/pointers0.desc create mode 100644 regression/cprover/large_step/pointers/pointers1.c create mode 100644 regression/cprover/large_step/pointers/pointers1.desc create mode 100644 regression/cprover/large_step/pointers/pointers10.c create mode 100644 regression/cprover/large_step/pointers/pointers10.desc create mode 100644 regression/cprover/large_step/pointers/pointers11.c create mode 100644 regression/cprover/large_step/pointers/pointers11.desc create mode 100644 regression/cprover/large_step/pointers/pointers12.c create mode 100644 regression/cprover/large_step/pointers/pointers12.desc create mode 100644 regression/cprover/large_step/pointers/pointers2.c create mode 100644 regression/cprover/large_step/pointers/pointers2.desc create mode 100644 regression/cprover/large_step/pointers/pointers3.c create mode 100644 regression/cprover/large_step/pointers/pointers3.desc create mode 100644 regression/cprover/large_step/pointers/pointers4.c create mode 100644 regression/cprover/large_step/pointers/pointers4.desc create mode 100644 regression/cprover/large_step/pointers/pointers5.c create mode 100644 regression/cprover/large_step/pointers/pointers5.desc create mode 100644 regression/cprover/large_step/pointers/pointers6.c create mode 100644 regression/cprover/large_step/pointers/pointers6.desc create mode 100644 regression/cprover/large_step/pointers/pointers7.c create mode 100644 regression/cprover/large_step/pointers/pointers7.desc create mode 100644 regression/cprover/large_step/pointers/pointers8.c create mode 100644 regression/cprover/large_step/pointers/pointers8.desc create mode 100644 regression/cprover/large_step/pointers/pointers9.c create mode 100644 regression/cprover/large_step/pointers/pointers9.desc create mode 100644 regression/cprover/large_step/pointers/posix_memalign1.c create mode 100644 regression/cprover/large_step/pointers/posix_memalign1.desc create mode 100644 regression/cprover/large_step/pointers/struct_pointer1.c create mode 100644 regression/cprover/large_step/pointers/struct_pointer1.desc create mode 100644 regression/cprover/large_step/pointers/struct_pointer2.c create mode 100644 regression/cprover/large_step/pointers/struct_pointer2.desc create mode 100644 regression/cprover/large_step/pointers/struct_pointer3.c create mode 100644 regression/cprover/large_step/pointers/struct_pointer3.desc create mode 100644 regression/cprover/large_step/pointers/struct_pointer4.c create mode 100644 regression/cprover/large_step/pointers/struct_pointer4.desc create mode 100644 regression/cprover/large_step/pointers/struct_pointer5.c create mode 100644 regression/cprover/large_step/pointers/struct_pointer5.desc create mode 100644 regression/cprover/large_step/pointers/struct_pointer6.c create mode 100644 regression/cprover/large_step/pointers/struct_pointer6.desc create mode 100644 regression/cprover/large_step/quantifiers/exists1.c create mode 100644 regression/cprover/large_step/quantifiers/exists1.desc create mode 100644 regression/cprover/large_step/quantifiers/forall1.c create mode 100644 regression/cprover/large_step/quantifiers/forall1.desc create mode 100644 regression/cprover/large_step/quantifiers/zeros1.c create mode 100644 regression/cprover/large_step/quantifiers/zeros1.desc create mode 100644 regression/cprover/large_step/safety/array_bounds1.c create mode 100644 regression/cprover/large_step/safety/array_bounds1.desc create mode 100644 regression/cprover/large_step/safety/array_bounds2.c create mode 100644 regression/cprover/large_step/safety/array_bounds2.desc create mode 100644 regression/cprover/large_step/safety/array_bounds3.c create mode 100644 regression/cprover/large_step/safety/array_bounds3.desc create mode 100644 regression/cprover/large_step/safety/array_bounds4.c create mode 100644 regression/cprover/large_step/safety/array_bounds4.desc create mode 100644 regression/cprover/large_step/safety/const1.c create mode 100644 regression/cprover/large_step/safety/const1.desc create mode 100644 regression/cprover/large_step/safety/division_by_zero.c create mode 100644 regression/cprover/large_step/safety/division_by_zero.desc create mode 100644 regression/cprover/large_step/safety/division_by_zero2.c create mode 100644 regression/cprover/large_step/safety/division_by_zero2.desc create mode 100644 regression/cprover/large_step/safety/double_free1.c create mode 100644 regression/cprover/large_step/safety/double_free1.desc create mode 100644 regression/cprover/large_step/safety/dynamic_object1.c create mode 100644 regression/cprover/large_step/safety/dynamic_object1.desc create mode 100644 regression/cprover/large_step/safety/free1.c create mode 100644 regression/cprover/large_step/safety/free1.desc create mode 100644 regression/cprover/large_step/safety/free2.c create mode 100644 regression/cprover/large_step/safety/free2.desc create mode 100644 regression/cprover/large_step/safety/free3.c create mode 100644 regression/cprover/large_step/safety/free3.desc create mode 100644 regression/cprover/large_step/safety/free4.c create mode 100644 regression/cprover/large_step/safety/free4.desc create mode 100644 regression/cprover/large_step/safety/free_null1.c create mode 100644 regression/cprover/large_step/safety/free_null1.desc create mode 100644 regression/cprover/large_step/safety/live_object1.c create mode 100644 regression/cprover/large_step/safety/live_object1.desc create mode 100644 regression/cprover/large_step/safety/local_out_of_scope1.c create mode 100644 regression/cprover/large_step/safety/local_out_of_scope1.desc create mode 100644 regression/cprover/large_step/safety/local_out_of_scope2.c create mode 100644 regression/cprover/large_step/safety/local_out_of_scope2.desc create mode 100644 regression/cprover/large_step/safety/local_out_of_scope3.c create mode 100644 regression/cprover/large_step/safety/local_out_of_scope3.desc create mode 100644 regression/cprover/large_step/safety/malloc1.c create mode 100644 regression/cprover/large_step/safety/malloc1.desc create mode 100644 regression/cprover/large_step/safety/memchr1.c create mode 100644 regression/cprover/large_step/safety/memchr1.desc create mode 100644 regression/cprover/large_step/safety/memcmp1.c create mode 100644 regression/cprover/large_step/safety/memcmp1.desc create mode 100644 regression/cprover/large_step/safety/memset1.c create mode 100644 regression/cprover/large_step/safety/memset1.desc create mode 100644 regression/cprover/large_step/safety/memset2.c create mode 100644 regression/cprover/large_step/safety/memset2.desc create mode 100644 regression/cprover/large_step/safety/null_dereference1.c create mode 100644 regression/cprover/large_step/safety/null_dereference1.desc create mode 100644 regression/cprover/large_step/safety/null_object1.c create mode 100644 regression/cprover/large_step/safety/null_object1.desc create mode 100644 regression/cprover/large_step/safety/object_size1.c create mode 100644 regression/cprover/large_step/safety/object_size1.desc create mode 100644 regression/cprover/large_step/safety/pointer_to_pointer1.c create mode 100644 regression/cprover/large_step/safety/pointer_to_pointer1.desc create mode 100644 regression/cprover/large_step/safety/r_ok1.c create mode 100644 regression/cprover/large_step/safety/r_ok1.desc create mode 100644 regression/cprover/large_step/safety/r_ok2.c create mode 100644 regression/cprover/large_step/safety/r_ok2.desc create mode 100644 regression/cprover/large_step/safety/r_ok3.c create mode 100644 regression/cprover/large_step/safety/r_ok3.desc create mode 100644 regression/cprover/large_step/safety/r_ok4.c create mode 100644 regression/cprover/large_step/safety/r_ok4.desc create mode 100644 regression/cprover/large_step/safety/r_ok5.c create mode 100644 regression/cprover/large_step/safety/r_ok5.desc create mode 100644 regression/cprover/large_step/safety/r_ok6.c create mode 100644 regression/cprover/large_step/safety/r_ok6.desc create mode 100644 regression/cprover/large_step/safety/r_ok7.c create mode 100644 regression/cprover/large_step/safety/r_ok7.desc create mode 100644 regression/cprover/large_step/safety/r_ok8.c create mode 100644 regression/cprover/large_step/safety/r_ok8.desc create mode 100644 regression/cprover/large_step/safety/r_ok_is_function1.c create mode 100644 regression/cprover/large_step/safety/r_ok_is_function1.desc create mode 100644 regression/cprover/large_step/safety/realloc1.c create mode 100644 regression/cprover/large_step/safety/realloc1.desc create mode 100644 regression/cprover/large_step/safety/realloc2.c create mode 100644 regression/cprover/large_step/safety/realloc2.desc create mode 100644 regression/cprover/large_step/safety/shifts1.c create mode 100644 regression/cprover/large_step/safety/shifts1.desc create mode 100644 regression/cprover/large_step/safety/simple_equality1.c create mode 100644 regression/cprover/large_step/safety/simple_equality1.desc create mode 100644 regression/cprover/large_step/safety/use_after_free1.c create mode 100644 regression/cprover/large_step/safety/use_after_free1.desc create mode 100644 regression/cprover/large_step/safety/writeable1.c create mode 100644 regression/cprover/large_step/safety/writeable1.desc create mode 100644 regression/cprover/large_step/structs/nondet_struct1.c create mode 100644 regression/cprover/large_step/structs/nondet_struct1.desc create mode 100644 regression/cprover/large_step/structs/struct1.c create mode 100644 regression/cprover/large_step/structs/struct1.desc create mode 100644 regression/cprover/large_step/structs/struct2.c create mode 100644 regression/cprover/large_step/structs/struct2.desc create mode 100644 regression/cprover/large_step/structs/struct3.c create mode 100644 regression/cprover/large_step/structs/struct3.desc create mode 100644 regression/cprover/large_step/structs/struct4.c create mode 100644 regression/cprover/large_step/structs/struct4.desc create mode 100644 regression/cprover/large_step/structs/struct5.c create mode 100644 regression/cprover/large_step/structs/struct5.desc create mode 100644 regression/cprover/large_step/trace/trace1.c create mode 100644 regression/cprover/large_step/trace/trace1.desc create mode 100644 regression/cprover/large_step/trace/trace3.c create mode 100644 regression/cprover/large_step/trace/trace3.desc create mode 100644 regression/cprover/large_step/trace/trace_array1.c create mode 100644 regression/cprover/large_step/trace/trace_array1.desc create mode 100644 regression/cprover/large_step/trace/trace_contract1.c create mode 100644 regression/cprover/large_step/trace/trace_contract1.desc create mode 100644 regression/cprover/large_step/trace/trace_function_call1.c create mode 100644 regression/cprover/large_step/trace/trace_function_call1.desc create mode 100644 regression/cprover/large_step/trace/trace_malloc1.c create mode 100644 regression/cprover/large_step/trace/trace_malloc1.desc create mode 100644 regression/cprover/large_step/trace/trace_malloc2.c create mode 100644 regression/cprover/large_step/trace/trace_malloc2.desc create mode 100644 regression/cprover/large_step/trace/trace_nondet1.c create mode 100644 regression/cprover/large_step/trace/trace_nondet1.desc create mode 100644 regression/cprover/large_step/trace/trace_pointer1.c create mode 100644 regression/cprover/large_step/trace/trace_pointer1.desc create mode 100644 regression/cprover/large_step/trace/trace_pointer2.c create mode 100644 regression/cprover/large_step/trace/trace_pointer2.desc create mode 100644 regression/cprover/large_step/trace/trace_pointer3.c create mode 100644 regression/cprover/large_step/trace/trace_pointer3.desc create mode 100644 regression/cprover/large_step/trace/trace_struct1.c create mode 100644 regression/cprover/large_step/trace/trace_struct1.desc create mode 100644 regression/cprover/large_step/unions/union1.c create mode 100644 regression/cprover/large_step/unions/union1.desc create mode 100644 regression/cprover/large_step/unions/union2.c create mode 100644 regression/cprover/large_step/unions/union2.desc diff --git a/regression/cprover/large_step/CMakeLists.txt b/regression/cprover/large_step/CMakeLists.txt new file mode 100644 index 00000000000..e6a88a047af --- /dev/null +++ b/regression/cprover/large_step/CMakeLists.txt @@ -0,0 +1,3 @@ +add_test_pl_tests( + "$" +) diff --git a/regression/cprover/large_step/Makefile b/regression/cprover/large_step/Makefile new file mode 100644 index 00000000000..e5761128275 --- /dev/null +++ b/regression/cprover/large_step/Makefile @@ -0,0 +1,14 @@ +default: test-no-p + +include ../../../src/config.inc +include ../../../src/common + +test: + @../../test.pl -e -p -c '../../../../src/cprover/cprover --large-step' + +test-no-p: + @../../test.pl -e -c '../../../../src/cprover/cprover --large-step' + +clean: + find . -name '*.out' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/cprover/large_step/arrays/array1.c b/regression/cprover/large_step/arrays/array1.c new file mode 100644 index 00000000000..8b451311cb8 --- /dev/null +++ b/regression/cprover/large_step/arrays/array1.c @@ -0,0 +1,10 @@ +int array[10]; + +int main() +{ + array[1l] = 10; + array[2l] = 20; + __CPROVER_assert(array[1l] == 10, "property 1"); // passes + __CPROVER_assert(array[2l] == 20, "property 2"); // passes + __CPROVER_assert(array[2l] == 30, "property 3"); // fails +} diff --git a/regression/cprover/large_step/arrays/array1.desc b/regression/cprover/large_step/arrays/array1.desc new file mode 100644 index 00000000000..37b1ff5a824 --- /dev/null +++ b/regression/cprover/large_step/arrays/array1.desc @@ -0,0 +1,14 @@ +CORE +array1.c +--text --solve --inline --no-safety +^EXIT=10$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S10\(ς\) ⇒ S11\(ς\[element_address\(❝array❞, .*1.*\):=10\]\)$ +^\(\d+\) ∀ ς : state \. S11\(ς\) ⇒ S12\(ς\[element_address\(❝array❞, .*2.*\):=20\]\)$ +^\(\d+\) ∀ ς : state \. S12\(ς\) ⇒ \(ς\(element_address\(❝array❞, .*1.*\)\) = 10\)$ +^\(\d+\) ∀ ς : state \. S13\(ς\) ⇒ \(ς\(element_address\(❝array❞, .*2.*\)\) = 20\)$ +^\(\d+\) ∀ ς : state \. S14\(ς\) ⇒ \(ς\(element_address\(❝array❞, .*2.*\)\) = 30\)$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$ +^\[main\.assertion\.3\] line \d+ property 3: REFUTED$ +-- diff --git a/regression/cprover/large_step/arrays/array2.c b/regression/cprover/large_step/arrays/array2.c new file mode 100644 index 00000000000..733e355d963 --- /dev/null +++ b/regression/cprover/large_step/arrays/array2.c @@ -0,0 +1,8 @@ +int main() +{ + int array[10]; + int i, j, k; + __CPROVER_assume(i == j); + __CPROVER_assert(array[i] == array[j], "property 1"); // passes + __CPROVER_assert(array[i] == array[k], "property 2"); // fails +} diff --git a/regression/cprover/large_step/arrays/array2.desc b/regression/cprover/large_step/arrays/array2.desc new file mode 100644 index 00000000000..5ca669c8151 --- /dev/null +++ b/regression/cprover/large_step/arrays/array2.desc @@ -0,0 +1,11 @@ +CORE +array2.c +--text --solve --inline --no-safety +^EXIT=10$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. \(S13\(ς\) ∧ ς\(❝main::1::i❞\) = ς\(❝main::1::j❞\)\) ⇒ S14\(ς\)$ +^\(\d+\) ∀ ς : state \. S14\(ς\) ⇒ \(ς\(element_address\(❝main::1::array❞, (ς\(❝main::1::i❞\)|cast\(ς\(❝main::1::i❞\), signedbv\[64\]\))\)\) = ς\(element_address\(❝main::1::array❞, (ς\(❝main::1::j❞\)|cast\(ς\(❝main::1::j❞\), signedbv\[64\]\))\)\)\)$ +^\(\d+\) ∀ ς : state \. S15\(ς\) ⇒ \(ς\(element_address\(❝main::1::array❞, (ς\(❝main::1::i❞\)|cast\(ς\(❝main::1::i❞\), signedbv\[64\]\))\)\) = ς\(element_address\(❝main::1::array❞, (ς\(❝main::1::k❞\)|cast\(ς\(❝main::1::k❞\), signedbv\[64\]\))\)\)\)$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: REFUTED$ +-- diff --git a/regression/cprover/large_step/arrays/array4.c b/regression/cprover/large_step/arrays/array4.c new file mode 100644 index 00000000000..f148237d110 --- /dev/null +++ b/regression/cprover/large_step/arrays/array4.c @@ -0,0 +1,7 @@ +int main() +{ + int a[100]; + int *p = a; + __CPROVER_assert(p[23] == a[23], "property 1"); // should pass + return 0; +} diff --git a/regression/cprover/large_step/arrays/array4.desc b/regression/cprover/large_step/arrays/array4.desc new file mode 100644 index 00000000000..f7cc79fa687 --- /dev/null +++ b/regression/cprover/large_step/arrays/array4.desc @@ -0,0 +1,7 @@ +CORE +array4.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/arrays/array_literal1.c b/regression/cprover/large_step/arrays/array_literal1.c new file mode 100644 index 00000000000..100a4945fb9 --- /dev/null +++ b/regression/cprover/large_step/arrays/array_literal1.c @@ -0,0 +1,8 @@ +int array[10] = {0, 1, 2, 3, 4}; + +int main() +{ + __CPROVER_assert(array[0l] == 0, "property 1"); // passes + __CPROVER_assert(array[1l] == 1, "property 2"); // passes + return 0; +} diff --git a/regression/cprover/large_step/arrays/array_literal1.desc b/regression/cprover/large_step/arrays/array_literal1.desc new file mode 100644 index 00000000000..4921d0263be --- /dev/null +++ b/regression/cprover/large_step/arrays/array_literal1.desc @@ -0,0 +1,8 @@ +CORE +array_literal1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$ +-- diff --git a/regression/cprover/large_step/arrays/array_literal2.c b/regression/cprover/large_step/arrays/array_literal2.c new file mode 100644 index 00000000000..3962b4b0c11 --- /dev/null +++ b/regression/cprover/large_step/arrays/array_literal2.c @@ -0,0 +1,8 @@ +int array[] = {'a', 'b', 'c', 'd', 'e', 'f'}; + +int main() +{ + int i; + if(i >= 0 && i <= 5) + __CPROVER_assert(array[i] == 'a' + i, "property 1"); // passes +} diff --git a/regression/cprover/large_step/arrays/array_r_ok1.c b/regression/cprover/large_step/arrays/array_r_ok1.c new file mode 100644 index 00000000000..5d272647477 --- /dev/null +++ b/regression/cprover/large_step/arrays/array_r_ok1.c @@ -0,0 +1,7 @@ +int main() +{ + unsigned char array[10]; + __CPROVER_assert(__CPROVER_r_ok(array, 10), "property 1"); + unsigned char *array_ptr = array; + __CPROVER_assert(__CPROVER_r_ok(array_ptr, 10), "property 2"); +} diff --git a/regression/cprover/large_step/arrays/array_r_ok1.desc b/regression/cprover/large_step/arrays/array_r_ok1.desc new file mode 100644 index 00000000000..5b10508c6e0 --- /dev/null +++ b/regression/cprover/large_step/arrays/array_r_ok1.desc @@ -0,0 +1,8 @@ +CORE +array_r_ok1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$ +-- diff --git a/regression/cprover/large_step/arrays/array_set1.c b/regression/cprover/large_step/arrays/array_set1.c new file mode 100644 index 00000000000..c0649de2af8 --- /dev/null +++ b/regression/cprover/large_step/arrays/array_set1.c @@ -0,0 +1,8 @@ +int array[10]; + +int main() +{ + __CPROVER_array_set(array, 123); + __CPROVER_assert(array[5l] == 123, "property 1"); // passes + return 0; +} diff --git a/regression/cprover/large_step/arrays/array_set1.desc b/regression/cprover/large_step/arrays/array_set1.desc new file mode 100644 index 00000000000..277d6d0f130 --- /dev/null +++ b/regression/cprover/large_step/arrays/array_set1.desc @@ -0,0 +1,7 @@ +KNOWNBUG +array_set1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/arrays/iterate_over_array1.c b/regression/cprover/large_step/arrays/iterate_over_array1.c new file mode 100644 index 00000000000..49f729cb814 --- /dev/null +++ b/regression/cprover/large_step/arrays/iterate_over_array1.c @@ -0,0 +1,7 @@ +int array[10]; + +int main() +{ + for(__CPROVER_size_t i = 0; i < sizeof(array) / sizeof(int); i++) + array[i] = 0; +} diff --git a/regression/cprover/large_step/arrays/iterate_over_array1.desc b/regression/cprover/large_step/arrays/iterate_over_array1.desc new file mode 100644 index 00000000000..3a8abebd4c0 --- /dev/null +++ b/regression/cprover/large_step/arrays/iterate_over_array1.desc @@ -0,0 +1,7 @@ +CORE +iterate_over_array1.c +--safety +^EXIT=0$ +^SIGNAL=0$ +^\[main\.array_bounds\.1\] line \d+ array bounds in array\[.*i\]: SUCCESS$ +-- diff --git a/regression/cprover/large_step/arrays/iterate_over_array2.c b/regression/cprover/large_step/arrays/iterate_over_array2.c new file mode 100644 index 00000000000..26311bde2e5 --- /dev/null +++ b/regression/cprover/large_step/arrays/iterate_over_array2.c @@ -0,0 +1,31 @@ +#define size_t __CPROVER_size_t +#define false 0 +#define true 1 + +_Bool find_zero(const void *const array, const size_t array_len) +{ + const unsigned char *array_bytes = array; + + // iterate over array + for(size_t i = 0; i < array_len; ++i) + // clang-format off + __CPROVER_loop_invariant(i >= 0 && i <= array_len) + __CPROVER_loop_invariant(__CPROVER_POINTER_OFFSET(array_bytes) == 0) + __CPROVER_loop_invariant(__CPROVER_r_ok(array_bytes, array_len)) + // clang-format on + { + if(array_bytes[i] == 0) + { + return true; + } + } + + return false; +} + +int main() +{ + unsigned char array[10]; + size_t array_len = 10; + find_zero(array, array_len); +} diff --git a/regression/cprover/large_step/arrays/iterate_over_array2.desc b/regression/cprover/large_step/arrays/iterate_over_array2.desc new file mode 100644 index 00000000000..815eff0673d --- /dev/null +++ b/regression/cprover/large_step/arrays/iterate_over_array2.desc @@ -0,0 +1,7 @@ +CORE +iterate_over_array2.c +--safety +^EXIT=0$ +^SIGNAL=0$ +^\[find_zero\.pointer\.1\] line \d+ pointer .* safe: SUCCESS$ +-- diff --git a/regression/cprover/large_step/aws-c-common/aws_array_eq_c_str.desc b/regression/cprover/large_step/aws-c-common/aws_array_eq_c_str.desc new file mode 100644 index 00000000000..21a384e6911 --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/aws_array_eq_c_str.desc @@ -0,0 +1,6 @@ +KNOWNBUG +aws_array_eq_c_str_contract.c +-I aws-c-common/include aws-c-common/source/byte_buf.c +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/aws-c-common/aws_array_eq_c_str_contract.c b/regression/cprover/large_step/aws-c-common/aws_array_eq_c_str_contract.c new file mode 100644 index 00000000000..f36d35396a4 --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/aws_array_eq_c_str_contract.c @@ -0,0 +1,20 @@ +// Function: aws_array_eq_c_str +// Source: aws-c-common/source/byte_buf.c + +#include + +// bool aws_array_eq_c_str(const void *const array, const size_t array_len, const char *const c_str) + +int main() +{ + const void *array; + size_t array_len; + const char *c_str; + + __CPROVER_assume(__CPROVER_r_ok(array, array_len)); + __CPROVER_assume(__CPROVER_is_cstring(c_str)); + + aws_array_eq_c_str(array, array_len, c_str); + + return 0; +} diff --git a/regression/cprover/large_step/aws-c-common/aws_array_eq_c_str_ignore_case.desc b/regression/cprover/large_step/aws-c-common/aws_array_eq_c_str_ignore_case.desc new file mode 100644 index 00000000000..4edefe812c5 --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/aws_array_eq_c_str_ignore_case.desc @@ -0,0 +1,6 @@ +KNOWNBUG +aws_array_eq_c_str_ignore_case_contract.c +--safety aws-c-common/source/byte_buf.c -I aws-c-common/include +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/aws-c-common/aws_array_eq_c_str_ignore_case_contract.c b/regression/cprover/large_step/aws-c-common/aws_array_eq_c_str_ignore_case_contract.c new file mode 100644 index 00000000000..f7d7333c0c5 --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/aws_array_eq_c_str_ignore_case_contract.c @@ -0,0 +1,20 @@ +// Function: aws_array_eq_c_str_ignore_case +// Source: aws-c-common/source/byte_buf.c + +#include + +// bool aws_array_eq_c_str_ignore_case(const void *const array, const size_t array_len, const char *const c_str) + +int main() +{ + const void *array; + size_t array_len; + const char *c_str; + + __CPROVER_assume(__CPROVER_r_ok(array, array_len)); + __CPROVER_assume(__CPROVER_is_cstring(c_str)); + + aws_array_eq_c_str_ignore_case(array, array_len, c_str); + + return 0; +} diff --git a/regression/cprover/large_step/aws-c-common/aws_array_eq_ignore_case.desc b/regression/cprover/large_step/aws-c-common/aws_array_eq_ignore_case.desc new file mode 100644 index 00000000000..84bb334a63d --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/aws_array_eq_ignore_case.desc @@ -0,0 +1,6 @@ +KNOWNBUG +aws_array_eq_ignore_case_contract.c +--safety aws-c-common/source/byte_buf.c -I aws-c-common/include +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/aws-c-common/aws_array_eq_ignore_case_contract.c b/regression/cprover/large_step/aws-c-common/aws_array_eq_ignore_case_contract.c new file mode 100644 index 00000000000..7bdc77e6ef0 --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/aws_array_eq_ignore_case_contract.c @@ -0,0 +1,23 @@ +// Function: aws_array_eq_ignore_case +// Source: aws-c-common/source/byte_buf.c + +#include + +// bool aws_array_eq_ignore_case( +// const void *const array_a, +// const size_t len_a, +// const void *const array_b, +// const size_t len_b) + +int main() +{ + const void *array_a, *array_b; + size_t len_a, len_b; + + __CPROVER_assume(__CPROVER_r_ok(array_a, len_a)); + __CPROVER_assume(__CPROVER_r_ok(array_b, len_b)); + + aws_array_eq_ignore_case(array_a, len_a, array_b, len_b); + + return 0; +} diff --git a/regression/cprover/large_step/aws-c-common/aws_hash_table_clear.desc b/regression/cprover/large_step/aws-c-common/aws_hash_table_clear.desc new file mode 100644 index 00000000000..9a4a0e86a31 --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/aws_hash_table_clear.desc @@ -0,0 +1,6 @@ +KNOWNBUG +aws_hash_table_clear_contract.c +-I aws-c-common/include aws-c-common/source/hash_table.c +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/aws-c-common/aws_hash_table_clear_contract.c b/regression/cprover/large_step/aws-c-common/aws_hash_table_clear_contract.c new file mode 100644 index 00000000000..ca146702064 --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/aws_hash_table_clear_contract.c @@ -0,0 +1,15 @@ +// Function: aws_hash_table_clear +// Source: source/hash_table.c + +#include + +// void aws_hash_table_clear(struct aws_hash_table *map) + +int main() +{ + struct aws_hash_table *map; + + aws_hash_table_clear(map); + + return 0; +} diff --git a/regression/cprover/large_step/aws-c-common/aws_hash_table_eq.desc b/regression/cprover/large_step/aws-c-common/aws_hash_table_eq.desc new file mode 100644 index 00000000000..845de35ef6c --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/aws_hash_table_eq.desc @@ -0,0 +1,6 @@ +KNOWNBUG +aws_hash_table_eq_contract.c +-I aws-c-common/include aws-c-common/source/hash_table.c +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/aws-c-common/aws_hash_table_eq_contract.c b/regression/cprover/large_step/aws-c-common/aws_hash_table_eq_contract.c new file mode 100644 index 00000000000..e6e555124c0 --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/aws_hash_table_eq_contract.c @@ -0,0 +1,20 @@ +// Function: aws_hash_table_eq +// Source: source/hash_table.c + +#include + +// bool aws_hash_table_eq( +// const struct aws_hash_table *a, +// const struct aws_hash_table *b, +// aws_hash_callback_eq_fn *value_eq) + +int main() +{ + const struct aws_hash_table *a; + const struct aws_hash_table *b; + aws_hash_callback_eq_fn *value_eq; + + aws_hash_table_eq(a, b, value_eq); + + return 0; +} diff --git a/regression/cprover/large_step/aws-c-common/aws_hash_table_foreach.desc b/regression/cprover/large_step/aws-c-common/aws_hash_table_foreach.desc new file mode 100644 index 00000000000..0e07e0d4251 --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/aws_hash_table_foreach.desc @@ -0,0 +1,6 @@ +KNOWNBUG +aws_hash_table_foreach_contract.c +-I aws-c-common/include aws-c-common/source/hash_table.c +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/aws-c-common/aws_hash_table_foreach_contract.c b/regression/cprover/large_step/aws-c-common/aws_hash_table_foreach_contract.c new file mode 100644 index 00000000000..b8cedde6f94 --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/aws_hash_table_foreach_contract.c @@ -0,0 +1,20 @@ +// Function: aws_hash_table_foreach +// Source: source/hash_table.c + +#include + +// int aws_hash_table_foreach( +// struct aws_hash_table *map, +// int (*callback)(void *context, struct aws_hash_element *pElement), +// void *context) + +int main() +{ + struct aws_hash_table *map; + int (*callback)(void *context, struct aws_hash_element *pElement); + void *context; + + aws_hash_table_foreach(map, callback, context); + + return 0; +} diff --git a/regression/cprover/large_step/aws-c-common/setup b/regression/cprover/large_step/aws-c-common/setup new file mode 100644 index 00000000000..9320fa116bf --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/setup @@ -0,0 +1,6 @@ +#!/bin/sh + +git clone https://github.com/awslabs/aws-c-common -b v0.6.13 + +echo "/* nothing */" > aws-c-common/include/aws/common/config.h + diff --git a/regression/cprover/large_step/aws-c-common/todo/aws_array_list_mem_swap.desc b/regression/cprover/large_step/aws-c-common/todo/aws_array_list_mem_swap.desc new file mode 100644 index 00000000000..589f4153a64 --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/todo/aws_array_list_mem_swap.desc @@ -0,0 +1,6 @@ +CORE +aws_array_list_mem_swap_contract.c +--safety +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/aws-c-common/todo/aws_array_list_mem_swap_contract.c b/regression/cprover/large_step/aws-c-common/todo/aws_array_list_mem_swap_contract.c new file mode 100644 index 00000000000..d8cbf3238d3 --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/todo/aws_array_list_mem_swap_contract.c @@ -0,0 +1,6 @@ +// Function: aws_array_list_mem_swap + +int main() +{ + return 0; +} diff --git a/regression/cprover/large_step/aws-c-common/todo/aws_byte_buf_append_with_lookup.desc b/regression/cprover/large_step/aws-c-common/todo/aws_byte_buf_append_with_lookup.desc new file mode 100644 index 00000000000..182b9b8ed07 --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/todo/aws_byte_buf_append_with_lookup.desc @@ -0,0 +1,6 @@ +CORE +aws_byte_buf_append_with_lookup_contract.c +--safety +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/aws-c-common/todo/aws_byte_buf_append_with_lookup_contract.c b/regression/cprover/large_step/aws-c-common/todo/aws_byte_buf_append_with_lookup_contract.c new file mode 100644 index 00000000000..798127b21d9 --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/todo/aws_byte_buf_append_with_lookup_contract.c @@ -0,0 +1,6 @@ +// Function: aws_byte_buf_append_with_lookup + +int main() +{ + return 0; +} diff --git a/regression/cprover/large_step/aws-c-common/todo/aws_hash_array_ignore_case.desc b/regression/cprover/large_step/aws-c-common/todo/aws_hash_array_ignore_case.desc new file mode 100644 index 00000000000..81a0951c6ba --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/todo/aws_hash_array_ignore_case.desc @@ -0,0 +1,6 @@ +CORE +aws_hash_array_ignore_case_contract.c +--safety +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/aws-c-common/todo/aws_hash_array_ignore_case_contract.c b/regression/cprover/large_step/aws-c-common/todo/aws_hash_array_ignore_case_contract.c new file mode 100644 index 00000000000..399ff9cb87a --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/todo/aws_hash_array_ignore_case_contract.c @@ -0,0 +1,6 @@ +// Function: aws_hash_array_ignore_case + +int main() +{ + return 0; +} diff --git a/regression/cprover/large_step/aws-c-common/todo/hashlittle2.desc b/regression/cprover/large_step/aws-c-common/todo/hashlittle2.desc new file mode 100644 index 00000000000..79671d136a2 --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/todo/hashlittle2.desc @@ -0,0 +1,6 @@ +CORE +hashlittle2_contract.c +--safety +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/aws-c-common/todo/hashlittle2_contract.c b/regression/cprover/large_step/aws-c-common/todo/hashlittle2_contract.c new file mode 100644 index 00000000000..779fc545905 --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/todo/hashlittle2_contract.c @@ -0,0 +1,6 @@ +// Function: hashlittle2 + +int main() +{ + return 0; +} diff --git a/regression/cprover/large_step/aws-c-common/todo/memcpy_using_uint64_impl.desc b/regression/cprover/large_step/aws-c-common/todo/memcpy_using_uint64_impl.desc new file mode 100644 index 00000000000..ba227d70208 --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/todo/memcpy_using_uint64_impl.desc @@ -0,0 +1,6 @@ +CORE +memcpy_using_uint64_impl_contract.c +--safety +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/aws-c-common/todo/memcpy_using_uint64_impl_contract.c b/regression/cprover/large_step/aws-c-common/todo/memcpy_using_uint64_impl_contract.c new file mode 100644 index 00000000000..8fc5b9fdcab --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/todo/memcpy_using_uint64_impl_contract.c @@ -0,0 +1,6 @@ +// Function: memcpy_using_uint64_impl + +int main() +{ + return 0; +} diff --git a/regression/cprover/large_step/aws-c-common/todo/memset_override_0_impl.desc b/regression/cprover/large_step/aws-c-common/todo/memset_override_0_impl.desc new file mode 100644 index 00000000000..05a8aad2bab --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/todo/memset_override_0_impl.desc @@ -0,0 +1,6 @@ +CORE +memset_override_0_impl_contract.c +--safety +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/aws-c-common/todo/memset_override_0_impl_contract.c b/regression/cprover/large_step/aws-c-common/todo/memset_override_0_impl_contract.c new file mode 100644 index 00000000000..ef92559e5f6 --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/todo/memset_override_0_impl_contract.c @@ -0,0 +1,6 @@ +// Function: memset_override_0_impl + +int main() +{ + return 0; +} diff --git a/regression/cprover/large_step/aws-c-common/todo/memset_using_uint64_impl.desc b/regression/cprover/large_step/aws-c-common/todo/memset_using_uint64_impl.desc new file mode 100644 index 00000000000..20edd110665 --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/todo/memset_using_uint64_impl.desc @@ -0,0 +1,6 @@ +CORE +memset_using_uint64_impl_contract.c +--safety +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/aws-c-common/todo/memset_using_uint64_impl_contract.c b/regression/cprover/large_step/aws-c-common/todo/memset_using_uint64_impl_contract.c new file mode 100644 index 00000000000..f63c3b23f0b --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/todo/memset_using_uint64_impl_contract.c @@ -0,0 +1,6 @@ +// Function: memset_using_uint64_impl + +int main() +{ + return 0; +} diff --git a/regression/cprover/large_step/aws-c-common/todo/s_find_entry1.desc b/regression/cprover/large_step/aws-c-common/todo/s_find_entry1.desc new file mode 100644 index 00000000000..22def401755 --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/todo/s_find_entry1.desc @@ -0,0 +1,6 @@ +CORE +s_find_entry1_contract.c +--safety +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/aws-c-common/todo/s_find_entry1_contract.c b/regression/cprover/large_step/aws-c-common/todo/s_find_entry1_contract.c new file mode 100644 index 00000000000..9326144f4cf --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/todo/s_find_entry1_contract.c @@ -0,0 +1,6 @@ +// Function: s_find_entry1 + +int main() +{ + return 0; +} diff --git a/regression/cprover/large_step/aws-c-common/todo/s_get_next_element.desc b/regression/cprover/large_step/aws-c-common/todo/s_get_next_element.desc new file mode 100644 index 00000000000..4ac02e41e8c --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/todo/s_get_next_element.desc @@ -0,0 +1,6 @@ +CORE +s_get_next_element_contract.c +--safety +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/aws-c-common/todo/s_get_next_element_contract.c b/regression/cprover/large_step/aws-c-common/todo/s_get_next_element_contract.c new file mode 100644 index 00000000000..cc25d1a917f --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/todo/s_get_next_element_contract.c @@ -0,0 +1,6 @@ +// Function: s_get_next_element + +int main() +{ + return 0; +} diff --git a/regression/cprover/large_step/aws-c-common/todo/s_sift_down.desc b/regression/cprover/large_step/aws-c-common/todo/s_sift_down.desc new file mode 100644 index 00000000000..a27386b65ea --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/todo/s_sift_down.desc @@ -0,0 +1,6 @@ +CORE +s_sift_down_contract.c +--safety +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/aws-c-common/todo/s_sift_down_contract.c b/regression/cprover/large_step/aws-c-common/todo/s_sift_down_contract.c new file mode 100644 index 00000000000..fba47a319da --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/todo/s_sift_down_contract.c @@ -0,0 +1,6 @@ +// Function: s_sift_down + +int main() +{ + return 0; +} diff --git a/regression/cprover/large_step/aws-c-common/todo/s_sift_up.desc b/regression/cprover/large_step/aws-c-common/todo/s_sift_up.desc new file mode 100644 index 00000000000..84b60a6ac04 --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/todo/s_sift_up.desc @@ -0,0 +1,6 @@ +CORE +s_sift_up_contract.c +--safety +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/aws-c-common/todo/s_sift_up_contract.c b/regression/cprover/large_step/aws-c-common/todo/s_sift_up_contract.c new file mode 100644 index 00000000000..d15ecf63be7 --- /dev/null +++ b/regression/cprover/large_step/aws-c-common/todo/s_sift_up_contract.c @@ -0,0 +1,6 @@ +// Function: s_sift_up + +int main() +{ + return 0; +} diff --git a/regression/cprover/large_step/basic/assume1.c b/regression/cprover/large_step/basic/assume1.c new file mode 100644 index 00000000000..4a61fb2ace0 --- /dev/null +++ b/regression/cprover/large_step/basic/assume1.c @@ -0,0 +1,8 @@ +int main() +{ + int x; + + __CPROVER_assume(x >= 10); + __CPROVER_assert(x >= 5, "property 1"); // should pass + __CPROVER_assert(x >= 15, "property 2"); // should fail +} diff --git a/regression/cprover/large_step/basic/assume1.desc b/regression/cprover/large_step/basic/assume1.desc new file mode 100644 index 00000000000..80e691c1dfd --- /dev/null +++ b/regression/cprover/large_step/basic/assume1.desc @@ -0,0 +1,14 @@ +CORE +assume1.c +--text --solve --inline +^EXIT=10$ +^SIGNAL=0$ +^ \(\d+\) ∀ ς : state \. initial_state\(ς\) ⇒ SInitial\(ς\)$ +^ \(\d+\) S0 = SInitial$ +^ \(\d+\) S1 = S0$ +^\(\d+\) ∀ ς : state \. \(S10\(ς\) ∧ ς\(❝main::1::x❞\) ≥ 10\) ⇒ S11\(ς\)$ +^\(\d+\) ∀ ς : state \. S11\(ς\) ⇒ \(ς\(❝main::1::x❞\) ≥ 5\)$ +^\(\d+\) ∀ ς : state \. S12\(ς\) ⇒ \(ς\(❝main::1::x❞\) ≥ 15\)$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: REFUTED$ +-- diff --git a/regression/cprover/large_step/basic/basic1.c b/regression/cprover/large_step/basic/basic1.c new file mode 100644 index 00000000000..d79811088ce --- /dev/null +++ b/regression/cprover/large_step/basic/basic1.c @@ -0,0 +1,8 @@ +int x; + +int main() +{ + x = 1; + __CPROVER_assert(x == 1, "property 1"); + return 0; +} diff --git a/regression/cprover/large_step/basic/basic1.desc b/regression/cprover/large_step/basic/basic1.desc new file mode 100644 index 00000000000..a8de994b8a6 --- /dev/null +++ b/regression/cprover/large_step/basic/basic1.desc @@ -0,0 +1,12 @@ +CORE +basic1.c +--text --solve --inline +^EXIT=0$ +^SIGNAL=0$ +^ \(\d+\) ∀ ς : state \. initial_state\(ς\) ⇒ SInitial\(ς\)$ +^ \(\d+\) S0 = SInitial$ +^\(\d+\) ∀ ς : state \. S7\(ς\) ⇒ S8\(ς\[❝x❞:=0\]\)$ +^\(\d+\) ∀ ς : state \. S10\(ς\) ⇒ S11\(ς\[❝x❞:=1\]\)$ +^\(\d+\) ∀ ς : state \. S11\(ς\) ⇒ \(ς\(❝x❞\) = 1\)$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/basic/basic2.c b/regression/cprover/large_step/basic/basic2.c new file mode 100644 index 00000000000..8becf0b4d00 --- /dev/null +++ b/regression/cprover/large_step/basic/basic2.c @@ -0,0 +1,9 @@ +int x; + +int main() +{ + x = 1; + ; + __CPROVER_assert(x == 1, "property 1"); + return 0; +} diff --git a/regression/cprover/large_step/basic/basic2.desc b/regression/cprover/large_step/basic/basic2.desc new file mode 100644 index 00000000000..ecbef615ff7 --- /dev/null +++ b/regression/cprover/large_step/basic/basic2.desc @@ -0,0 +1,13 @@ +CORE +basic2.c +--text --solve --inline +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S7\(ς\) ⇒ S8\(ς\[❝x❞:=0\]\)$ +^\(\d+\) S9 = S8$ +^\(\d+\) S10 = S9$ +^\(\d+\) ∀ ς : state \. S10\(ς\) ⇒ S11\(ς\[❝x❞:=1\]\)$ +^\(\d+\) S12 = S11$ +^\(\d+\) ∀ ς : state \. S12\(ς\) ⇒ \(ς\(❝x❞\) = 1\)$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/basic/basic3.c b/regression/cprover/large_step/basic/basic3.c new file mode 100644 index 00000000000..91731f94e78 --- /dev/null +++ b/regression/cprover/large_step/basic/basic3.c @@ -0,0 +1,9 @@ +int x, y; + +int main() +{ + x = 1; + y = 2; + __CPROVER_assert(x == 1, "property 1"); + return 0; +} diff --git a/regression/cprover/large_step/basic/basic3.desc b/regression/cprover/large_step/basic/basic3.desc new file mode 100644 index 00000000000..a8631aef078 --- /dev/null +++ b/regression/cprover/large_step/basic/basic3.desc @@ -0,0 +1,12 @@ +CORE +basic3.c +--text --solve --inline +^EXIT=0$ +^SIGNAL=0$ +\(\d+\) ∀ ς : state \. S7\(ς\) ⇒ S8\(ς\[❝x❞:=0\]\) +\(\d+\) ∀ ς : state \. S8\(ς\) ⇒ S9\(ς\[❝y❞:=0\]\) +\(\d+\) ∀ ς : state \. S11\(ς\) ⇒ S12\(ς\[❝x❞:=1\]\) +\(\d+\) ∀ ς : state \. S12\(ς\) ⇒ S13\(ς\[❝y❞:=2\]\) +\(\d+\) ∀ ς : state \. S13\(ς\) ⇒ \(ς\(❝x❞\) = 1\) +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/basic/basic4.c b/regression/cprover/large_step/basic/basic4.c new file mode 100644 index 00000000000..555b0ac5eab --- /dev/null +++ b/regression/cprover/large_step/basic/basic4.c @@ -0,0 +1,9 @@ +int x; + +int main() +{ + x = 1; + x = 2; + __CPROVER_assert(x == 1, "property 1"); + return 0; +} diff --git a/regression/cprover/large_step/basic/basic4.desc b/regression/cprover/large_step/basic/basic4.desc new file mode 100644 index 00000000000..bca24eb3a18 --- /dev/null +++ b/regression/cprover/large_step/basic/basic4.desc @@ -0,0 +1,11 @@ +CORE +basic4.c +--text --solve --inline +^EXIT=10$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S7\(ς\) ⇒ S8\(ς\[❝x❞:=0\]\)$ +^\(\d+\) ∀ ς : state \. S10\(ς\) ⇒ S11\(ς\[❝x❞:=1\]\)$ +^\(\d+\) ∀ ς : state \. S11\(ς\) ⇒ S12\(ς\[❝x❞:=2\]\)$ +^\(\d+\) ∀ ς : state \. S12\(ς\) ⇒ \(ς\(❝x❞\) = 1\)$ +^\[main\.assertion\.1\] line \d+ property 1: REFUTED$ +-- diff --git a/regression/cprover/large_step/basic/basic5.c b/regression/cprover/large_step/basic/basic5.c new file mode 100644 index 00000000000..c5d2ba0200c --- /dev/null +++ b/regression/cprover/large_step/basic/basic5.c @@ -0,0 +1,11 @@ +int main() +{ + int x; + __CPROVER_bool c1 = (x >= 10); + __CPROVER_bool c2 = (x >= 5); + // clang-format off + __CPROVER_assert(c1 ==> c2, "property 1"); // passes + __CPROVER_assert(c2 ==> c1, "property 2"); // fails + // clang-format on + return 0; +} diff --git a/regression/cprover/large_step/basic/basic5.desc b/regression/cprover/large_step/basic/basic5.desc new file mode 100644 index 00000000000..2ac5fe52cba --- /dev/null +++ b/regression/cprover/large_step/basic/basic5.desc @@ -0,0 +1,14 @@ +CORE +basic5.c +--text --solve --inline +^EXIT=10$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S11\(ς\) ⇒ S12\(ς\[❝main::1::c1❞:=ς\(❝main::1::x❞\) ≥ 10\]\)$ +^\(\d+\) ∀ ς : state \. S12\(ς\) ⇒ S13\(enter_scope_state\(ς, ❝main::1::c2❞\)\)$ +^\(\d+\) ∀ ς : state \. S13\(ς\) ⇒ S14\(ς\[❝main::1::c2❞:=ς\(❝main::1::x❞\) ≥ 5\]\)$ +^\(\d+\) ∀ ς : state \. S14\(ς\) ⇒ \(ς\(❝main::1::c1❞\) ⇒ ς\(❝main::1::c2❞\)\)$ +^\(\d+\) S15 = S14$ +^\(\d+\) ∀ ς : state \. S15\(ς\) ⇒ \(ς\(❝main::1::c2❞\) ⇒ ς\(❝main::1::c1❞\)\)$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: REFUTED$ +-- diff --git a/regression/cprover/large_step/basic/basic6.c b/regression/cprover/large_step/basic/basic6.c new file mode 100644 index 00000000000..d17f7f4e3f2 --- /dev/null +++ b/regression/cprover/large_step/basic/basic6.c @@ -0,0 +1,12 @@ +int x; + +int main() +{ + x = 1; + x++; + x++; + x++; + x++; + __CPROVER_assert(x == 5, "property 1"); + return 0; +} diff --git a/regression/cprover/large_step/basic/basic6.desc b/regression/cprover/large_step/basic/basic6.desc new file mode 100644 index 00000000000..be02c9414c6 --- /dev/null +++ b/regression/cprover/large_step/basic/basic6.desc @@ -0,0 +1,13 @@ +CORE +basic6.c +--text --solve --inline +^EXIT=0$ +^SIGNAL=0$ +^\(13\) ∀ ς : state \. S10\(ς\) ⇒ S11\(ς\[❝x❞:=1\]\)$ +^\(14\) ∀ ς : state \. S11\(ς\) ⇒ S12\(ς\[❝x❞:=ς\(❝x❞\) \+ 1\]\)$ +^\(15\) ∀ ς : state \. S12\(ς\) ⇒ S13\(ς\[❝x❞:=ς\(❝x❞\) \+ 1\]\)$ +^\(16\) ∀ ς : state \. S13\(ς\) ⇒ S14\(ς\[❝x❞:=ς\(❝x❞\) \+ 1\]\)$ +^\(17\) ∀ ς : state \. S14\(ς\) ⇒ S15\(ς\[❝x❞:=ς\(❝x❞\) \+ 1\]\)$ +^\(18\) ∀ ς : state \. S15\(ς\) ⇒ \(ς\(❝x❞\) = 5\)$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/basic/extern1.c b/regression/cprover/large_step/basic/extern1.c new file mode 100644 index 00000000000..f0b6ac7ac39 --- /dev/null +++ b/regression/cprover/large_step/basic/extern1.c @@ -0,0 +1,13 @@ +struct S +{ + int x, y; +}; + +extern struct S some_struct; + +int main() +{ + // should fail + __CPROVER_assert(some_struct.x == some_struct.y, "property 1"); + return 0; +} diff --git a/regression/cprover/large_step/basic/extern1.desc b/regression/cprover/large_step/basic/extern1.desc new file mode 100644 index 00000000000..185f9bed398 --- /dev/null +++ b/regression/cprover/large_step/basic/extern1.desc @@ -0,0 +1,7 @@ +CORE +extern1.c + +^EXIT=10$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: REFUTED$ +-- diff --git a/regression/cprover/large_step/basic/no-assertions1.c b/regression/cprover/large_step/basic/no-assertions1.c new file mode 100644 index 00000000000..603b9efb645 --- /dev/null +++ b/regression/cprover/large_step/basic/no-assertions1.c @@ -0,0 +1,5 @@ +int main() +{ + __CPROVER_assert(0, "property 1"); + return 0; +} diff --git a/regression/cprover/large_step/basic/no-assertions1.desc b/regression/cprover/large_step/basic/no-assertions1.desc new file mode 100644 index 00000000000..77850c60273 --- /dev/null +++ b/regression/cprover/large_step/basic/no-assertions1.desc @@ -0,0 +1,7 @@ +CORE +basic1.c +--no-assertions +^EXIT=0$ +^SIGNAL=0$ +^There are no properties to show\.$ +-- diff --git a/regression/cprover/large_step/basic/nondet1.c b/regression/cprover/large_step/basic/nondet1.c new file mode 100644 index 00000000000..646308c12c2 --- /dev/null +++ b/regression/cprover/large_step/basic/nondet1.c @@ -0,0 +1,14 @@ +int nondet_int(); + +int main() +{ + int x, y; + + x = nondet_int(); + __CPROVER_assert(x == 20, "property 1"); // fails + + y = nondet_int(); + __CPROVER_assert(x == y, "property 2"); // fails + + return 0; +} diff --git a/regression/cprover/large_step/basic/nondet1.desc b/regression/cprover/large_step/basic/nondet1.desc new file mode 100644 index 00000000000..31a0da25664 --- /dev/null +++ b/regression/cprover/large_step/basic/nondet1.desc @@ -0,0 +1,15 @@ +CORE +nondet1.c +--text --solve --inline +^EXIT=10$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state, nondet::S12-0 : signedbv\[32\] \. S11\(ς\) ⇒ S12\(ς\[❝main::1::x❞:=nondet::S12-0\]\)$ +^\(\d+\) ∀ ς : state \. S12\(ς\) ⇒ \(ς\(❝main::1::x❞\) = 20\)$ +^\(\d+\) S13 = S12$ +^\(\d+\) ∀ ς : state, nondet::S14-0 : signedbv\[32\] \. S13\(ς\) ⇒ S14\(ς\[❝main::1::y❞:=nondet::S14-0\]\)$ +^\(\d+\) ∀ ς : state \. S14\(ς\) ⇒ \(ς\(❝main::1::x❞\) = ς\(❝main::1::y❞\)\)$ +^\(\d+\) S15 = S14$ +^\(\d+\) ∀ ς : state \. S15\(ς\) ⇒ S16\(ς\[❝return'❞:=0\]\)$ +^\[main\.assertion\.1\] line \d+ property 1: REFUTED$ +^\[main\.assertion\.2\] line \d+ property 2: REFUTED$ +-- diff --git a/regression/cprover/large_step/branching/branching1.c b/regression/cprover/large_step/branching/branching1.c new file mode 100644 index 00000000000..68f1d0c9d5e --- /dev/null +++ b/regression/cprover/large_step/branching/branching1.c @@ -0,0 +1,14 @@ +int main() +{ + int x; + if(x >= 5) + { + __CPROVER_assert(x >= 5, "property 1"); // should pass + __CPROVER_assert(0, "property 2"); // should fail + } + else + { + __CPROVER_assert(x < 5, "property 3"); // should pass + __CPROVER_assert(0, "property 4"); // should fail + } +} diff --git a/regression/cprover/large_step/branching/branching1.desc b/regression/cprover/large_step/branching/branching1.desc new file mode 100644 index 00000000000..21517818990 --- /dev/null +++ b/regression/cprover/large_step/branching/branching1.desc @@ -0,0 +1,24 @@ +CORE +branching1.c +--text --solve --inline +^EXIT=10$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. \(S10\(ς\) ∧ ¬\(ς\(❝main::1::x❞\) ≥ 5\)\) ⇒ S11T\(\ς\)$ +^\(\d+\) ∀ ς : state \. \(S10\(ς\) ∧ ς\(❝main::1::x❞\) ≥ 5\) ⇒ S11\(ς\)$ +^\(\d+\) ∀ ς : state \. S11\(ς\) ⇒ \(ς\(❝main::1::x❞\) ≥ 5\)$ +^\(\d+\) S12 = S11$ +^\(\d+\) ∀ ς : state \. S12\(ς\) ⇒ \(0 ≠ 0\)$ +^\(\d+\) S13 = S12$ +^\(\d+\) S14 = S13$ +^\(\d+\) ∀ ς : state \. S11T\(ς\) ⇒ \(ς\(❝main::1::x❞\) < 5\)$ +^\(\d+\) S15 = S11T$ +^\(\d+\) ∀ ς : state \. S15\(ς\) ⇒ \(0 ≠ 0\)$ +^\(\d+\) S16 = S15$ +^\(\d+\) ∀ ς : state \. S14\(ς\) ⇒ S17in\(ς\)$ +^\(\d+\) ∀ ς : state \. S16\(ς\) ⇒ S17in\(ς\)$ +^\(\d+\) S17 = S17in$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: REFUTED$ +^\[main\.assertion\.3\] line \d+ property 3: SUCCESS$ +^\[main\.assertion\.4\] line \d+ property 4: REFUTED$ +-- diff --git a/regression/cprover/large_step/branching/branching2.c b/regression/cprover/large_step/branching/branching2.c new file mode 100644 index 00000000000..6d86e28233e --- /dev/null +++ b/regression/cprover/large_step/branching/branching2.c @@ -0,0 +1,14 @@ +int main() +{ + int a, b; + + if(a >= 5) + b = 1; + else + b = 0; + + __CPROVER_assert(b == (a >= 5), "property 1"); // should pass + __CPROVER_assert(b != (a >= 5), "property 2"); // should fail + + return 0; +} diff --git a/regression/cprover/large_step/branching/branching2.desc b/regression/cprover/large_step/branching/branching2.desc new file mode 100644 index 00000000000..286cb86aa81 --- /dev/null +++ b/regression/cprover/large_step/branching/branching2.desc @@ -0,0 +1,16 @@ +CORE +branching2.c +--text --solve --inline +^EXIT=10$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. \(S11\(ς\) ∧ ¬\(ς\(❝main::1::a❞\) ≥ 5\)\) ⇒ S12T\(ς\)$ +^\(\d+\) ∀ ς : state \. \(S11\(ς\) ∧ ς\(❝main::1::a❞\) ≥ 5\) ⇒ S12\(ς\)$ +^\(\d+\) ∀ ς : state \. S12\(ς\) ⇒ S13\(ς\[❝main::1::b❞:=1\]\)$ +^\(\d+\) S14 = S13$ +^\(\d+\) ∀ ς : state \. S12T\(ς\) ⇒ S15\(ς\[❝main::1::b❞:=0\]\)$ +^\(\d+\) ∀ ς : state \. S14\(ς\) ⇒ S16in\(ς\)$ +^\(\d+\) ∀ ς : state \. S15\(ς\) ⇒ S16in\(ς\)$ +^\(\d+\) S16 = S16in$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: REFUTED$ +-- diff --git a/regression/cprover/large_step/contracts/check_assigns1.c b/regression/cprover/large_step/contracts/check_assigns1.c new file mode 100644 index 00000000000..a275c74608c --- /dev/null +++ b/regression/cprover/large_step/contracts/check_assigns1.c @@ -0,0 +1,36 @@ +int global; + +void my_function1(void) + // clang-format off + __CPROVER_assigns(global) // passes +// clang-format on +{ + global = 10; +} + +void my_function2(int parameter) + // clang-format off + __CPROVER_assigns() // fails + __CPROVER_ensures(1) +// clang-format on +{ + global = 10; +} + +void my_function3(int *pointer) + // clang-format off + __CPROVER_requires(__CPROVER_w_ok(pointer)) + __CPROVER_assigns(*pointer) // passes +// clang-format on +{ + *pointer = 10; +} + +void my_function4(void) + // clang-format off + __CPROVER_assigns() // passes +// clang-format on +{ + int local; + local = 10; +} diff --git a/regression/cprover/large_step/contracts/check_assigns1.desc b/regression/cprover/large_step/contracts/check_assigns1.desc new file mode 100644 index 00000000000..717f3da5e2e --- /dev/null +++ b/regression/cprover/large_step/contracts/check_assigns1.desc @@ -0,0 +1,9 @@ +CORE +check_assigns1.c + +^EXIT=10$ +^SIGNAL=0$ +^\[my_function1\.assigns\.1\] line \d+ assigns clause: SUCCESS$ +^\[my_function2\.assigns\.1\] line \d+ assigns clause: REFUTED +^\[my_function3\.assigns\.1\] line \d+ assigns clause: SUCCESS$ +-- diff --git a/regression/cprover/large_step/contracts/check_assigns2.c b/regression/cprover/large_step/contracts/check_assigns2.c new file mode 100644 index 00000000000..06939fc06ec --- /dev/null +++ b/regression/cprover/large_step/contracts/check_assigns2.c @@ -0,0 +1,20 @@ +struct some_struct +{ + int field; +}; + +void my_function1(int parameter) __CPROVER_assigns() // passes + __CPROVER_ensures(1) +{ + parameter = 1; +} + +void my_function2(void) __CPROVER_assigns() // passes + __CPROVER_ensures(1) +{ + struct some_struct s; + s.field = 1; + + int array[123]; + array[1] = 2; +} diff --git a/regression/cprover/large_step/contracts/check_assigns2.desc b/regression/cprover/large_step/contracts/check_assigns2.desc new file mode 100644 index 00000000000..df7ee50ef6b --- /dev/null +++ b/regression/cprover/large_step/contracts/check_assigns2.desc @@ -0,0 +1,6 @@ +CORE +check_assigns2.c + +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/contracts/check_assigns3.c b/regression/cprover/large_step/contracts/check_assigns3.c new file mode 100644 index 00000000000..85a82f4c585 --- /dev/null +++ b/regression/cprover/large_step/contracts/check_assigns3.c @@ -0,0 +1,26 @@ +void my_function1(int *parameter) + // clang-format off + __CPROVER_requires(__CPROVER_w_ok(parameter)) + __CPROVER_assigns(*parameter) // passes + // clang-fromat on +{ + *parameter = 10; +} + +void my_function2(int *parameter) + // clang-format off + __CPROVER_requires(__CPROVER_w_ok(parameter)) + __CPROVER_assigns() // fails + // clang-fromat on +{ + *parameter = 10; +} + +void my_function3(int *parameter) + // clang-format off + __CPROVER_requires(__CPROVER_w_ok(parameter)) + // implicit assigns clause fails + // clang-fromat on +{ + *parameter = 10; +} diff --git a/regression/cprover/large_step/contracts/check_assigns3.desc b/regression/cprover/large_step/contracts/check_assigns3.desc new file mode 100644 index 00000000000..a58da480570 --- /dev/null +++ b/regression/cprover/large_step/contracts/check_assigns3.desc @@ -0,0 +1,9 @@ +CORE +check_assigns3.c + +^EXIT=10$ +^SIGNAL=0$ +^\[my_function1\.assigns\.1\] line \d+ assigns clause: SUCCESS$ +^\[my_function2\.assigns\.1\] line \d+ assigns clause: REFUTED +^\[my_function3\.assigns\.1\] line \d+ assigns clause: REFUTED +-- diff --git a/regression/cprover/large_step/contracts/check_assigns4.c b/regression/cprover/large_step/contracts/check_assigns4.c new file mode 100644 index 00000000000..cb955ef6a7c --- /dev/null +++ b/regression/cprover/large_step/contracts/check_assigns4.c @@ -0,0 +1,37 @@ +struct S +{ + int x, y; +} global; + +void my_function1(void) + // clang-format off + __CPROVER_assigns(global) // passes +// clang-format on +{ + global.x = 10; + global.y = 10; +} + +void my_function2(void) + // clang-format off + __CPROVER_assigns(global.x) // passes +// clang-format on +{ + global.x = 10; +} + +void my_function3(void) + // clang-format off + __CPROVER_assigns(global.y) // passes +// clang-format on +{ + global.y = 10; +} + +void my_function4(void) + // clang-format off + __CPROVER_assigns(global.y) // fails +// clang-format on +{ + global.x = 10; +} diff --git a/regression/cprover/large_step/contracts/check_assigns4.desc b/regression/cprover/large_step/contracts/check_assigns4.desc new file mode 100644 index 00000000000..60b3c394c59 --- /dev/null +++ b/regression/cprover/large_step/contracts/check_assigns4.desc @@ -0,0 +1,11 @@ +CORE +check_assigns4.c + +^EXIT=10$ +^SIGNAL=0$ +^\[my_function1\.assigns\.1\] line \d+ assigns clause: SUCCESS$ +^\[my_function1\.assigns\.2\] line \d+ assigns clause: SUCCESS$ +^\[my_function2\.assigns\.1\] line \d+ assigns clause: SUCCESS$ +^\[my_function3\.assigns\.1\] line \d+ assigns clause: SUCCESS$ +^\[my_function4\.assigns\.1\] line \d+ assigns clause: REFUTED$ +-- diff --git a/regression/cprover/large_step/contracts/check_assigns5.c b/regression/cprover/large_step/contracts/check_assigns5.c new file mode 100644 index 00000000000..847b8e61986 --- /dev/null +++ b/regression/cprover/large_step/contracts/check_assigns5.c @@ -0,0 +1,29 @@ +struct S +{ + int x, y; +}; + +void my_function1(struct S *s) __CPROVER_requires(__CPROVER_rw_ok(s)) + __CPROVER_assigns(*s) // passes +{ + s->x = 10; + s->y = 10; +} + +void my_function2(struct S *s) __CPROVER_requires(__CPROVER_rw_ok(s)) + __CPROVER_assigns(s->x) // passes +{ + s->x = 10; +} + +void my_function3(struct S *s) __CPROVER_requires(__CPROVER_rw_ok(s)) + __CPROVER_assigns(s->y) // passes +{ + s->y = 10; +} + +void my_function4(struct S *s) __CPROVER_requires(__CPROVER_rw_ok(s)) + __CPROVER_assigns(s->y) // fails +{ + s->x = 10; +} diff --git a/regression/cprover/large_step/contracts/check_assigns5.desc b/regression/cprover/large_step/contracts/check_assigns5.desc new file mode 100644 index 00000000000..263f67b98b8 --- /dev/null +++ b/regression/cprover/large_step/contracts/check_assigns5.desc @@ -0,0 +1,11 @@ +CORE +check_assigns5.c + +^EXIT=10$ +^SIGNAL=0$ +^\[my_function1\.assigns\.1\] line \d+ assigns clause: SUCCESS$ +^\[my_function1\.assigns\.2\] line \d+ assigns clause: SUCCESS$ +^\[my_function2\.assigns\.1\] line \d+ assigns clause: SUCCESS$ +^\[my_function3\.assigns\.1\] line \d+ assigns clause: SUCCESS$ +^\[my_function4\.assigns\.1\] line \d+ assigns clause: REFUTED$ +-- diff --git a/regression/cprover/large_step/contracts/check_assigns6.c b/regression/cprover/large_step/contracts/check_assigns6.c new file mode 100644 index 00000000000..f3c076709f5 --- /dev/null +++ b/regression/cprover/large_step/contracts/check_assigns6.c @@ -0,0 +1,19 @@ +int global; +_Bool flag; + +void my_function1() + // clang-format off + __CPROVER_assigns(flag: global) // passes +// clang-format on +{ + if(flag) + global = 10; +} + +void my_function2() + // clang-format off + __CPROVER_assigns(flag: global) // fails +// clang-format on +{ + global = 10; +} diff --git a/regression/cprover/large_step/contracts/check_assigns6.desc b/regression/cprover/large_step/contracts/check_assigns6.desc new file mode 100644 index 00000000000..5541bf82c1a --- /dev/null +++ b/regression/cprover/large_step/contracts/check_assigns6.desc @@ -0,0 +1,8 @@ +CORE +check_assigns6.c + +^EXIT=10$ +^SIGNAL=0$ +^\[my_function1\.assigns\.1\] line \d+ assigns clause: SUCCESS$ +^\[my_function2\.assigns\.1\] line \d+ assigns clause: REFUTED$ +-- diff --git a/regression/cprover/large_step/contracts/check_postcondition1.c b/regression/cprover/large_step/contracts/check_postcondition1.c new file mode 100644 index 00000000000..8b800c00c3e --- /dev/null +++ b/regression/cprover/large_step/contracts/check_postcondition1.c @@ -0,0 +1,16 @@ +int global; + +void my_function1(int parameter) + // clang-format off + __CPROVER_ensures(global >= 0) // passes +// clang-format on +{ + global = 10; +} + +void my_function2(int parameter) + // clang-format off + __CPROVER_ensures(global >= 0) // fails +// clang-format on +{ +} diff --git a/regression/cprover/large_step/contracts/check_postcondition1.desc b/regression/cprover/large_step/contracts/check_postcondition1.desc new file mode 100644 index 00000000000..7a7b26d4591 --- /dev/null +++ b/regression/cprover/large_step/contracts/check_postcondition1.desc @@ -0,0 +1,8 @@ +CORE +check_postcondition1.c + +^EXIT=10$ +^SIGNAL=0$ +^\[my_function1\.postcondition\.1\] line \d+ postcondition: SUCCESS$ +^\[my_function2\.postcondition\.1\] line \d+ postcondition: REFUTED$ +-- diff --git a/regression/cprover/large_step/contracts/check_postcondition2.c b/regression/cprover/large_step/contracts/check_postcondition2.c new file mode 100644 index 00000000000..a40b34fb77d --- /dev/null +++ b/regression/cprover/large_step/contracts/check_postcondition2.c @@ -0,0 +1,21 @@ +int global; + +void my_function1(int parameter) + // clang-format off + __CPROVER_ensures(global == parameter) // passes + __CPROVER_assigns(global) +// clang-format on +{ + parameter++; + global = parameter; +} + +void my_function2(int parameter) + // clang-format off + __CPROVER_ensures(global == parameter) // fails + __CPROVER_assigns(global) +// clang-format on +{ + global = parameter; + parameter++; +} diff --git a/regression/cprover/large_step/contracts/check_postcondition2.desc b/regression/cprover/large_step/contracts/check_postcondition2.desc new file mode 100644 index 00000000000..51d52105b18 --- /dev/null +++ b/regression/cprover/large_step/contracts/check_postcondition2.desc @@ -0,0 +1,8 @@ +CORE +check_postcondition2.c + +^EXIT=10$ +^SIGNAL=0$ +^\[my_function1\.postcondition\.1\] line \d+ postcondition: SUCCESS$ +^\[my_function2\.postcondition\.1\] line \d+ postcondition: REFUTED$ +-- diff --git a/regression/cprover/large_step/contracts/check_postcondition3.c b/regression/cprover/large_step/contracts/check_postcondition3.c new file mode 100644 index 00000000000..79d863a8d9a --- /dev/null +++ b/regression/cprover/large_step/contracts/check_postcondition3.c @@ -0,0 +1,17 @@ +int global; + +void my_function1(int parameter) + __CPROVER_ensures(global == __CPROVER_old(parameter)) // passes + __CPROVER_assigns(global) +{ + global = parameter; + parameter++; +} + +void my_function2(int parameter) + __CPROVER_ensures(global == __CPROVER_old(parameter)) // fails + __CPROVER_assigns(global) +{ + parameter++; + global = parameter; +} diff --git a/regression/cprover/large_step/contracts/check_postcondition3.desc b/regression/cprover/large_step/contracts/check_postcondition3.desc new file mode 100644 index 00000000000..b8a253af23e --- /dev/null +++ b/regression/cprover/large_step/contracts/check_postcondition3.desc @@ -0,0 +1,10 @@ +CORE +check_postcondition3.c + +^EXIT=10$ +^SIGNAL=0$ +^\[my_function1\.assigns\.1\] line \d+ assigns clause: SUCCESS$ +^\[my_function1\.postcondition\.1\] line \d+ postcondition: SUCCESS$ +^\[my_function2\.assigns\.1\] line \d+ assigns clause: SUCCESS$ +^\[my_function2\.postcondition\.1\] line \d+ postcondition: REFUTED$ +-- diff --git a/regression/cprover/large_step/contracts/check_postcondition4.c b/regression/cprover/large_step/contracts/check_postcondition4.c new file mode 100644 index 00000000000..42a661f138c --- /dev/null +++ b/regression/cprover/large_step/contracts/check_postcondition4.c @@ -0,0 +1,12 @@ +int x, y; + +void my_function() + // clang-format off + __CPROVER_ensures(x == 10) // passes + __CPROVER_ensures(y == 20) // fails + __CPROVER_assigns(x, y) +// clang-format on +{ + x = 10; + y = 10; +} diff --git a/regression/cprover/large_step/contracts/check_postcondition4.desc b/regression/cprover/large_step/contracts/check_postcondition4.desc new file mode 100644 index 00000000000..fb23bd58e68 --- /dev/null +++ b/regression/cprover/large_step/contracts/check_postcondition4.desc @@ -0,0 +1,8 @@ +CORE +check_postcondition4.c + +^EXIT=10$ +^SIGNAL=0$ +^\[my_function\.postcondition\.2\] line \d+ postcondition x == 10: SUCCESS$ +^\[my_function\.postcondition\.1\] line \d+ postcondition y == 20: REFUTED$ +-- diff --git a/regression/cprover/large_step/contracts/check_postcondition5.c b/regression/cprover/large_step/contracts/check_postcondition5.c new file mode 100644 index 00000000000..d0aeb2329c2 --- /dev/null +++ b/regression/cprover/large_step/contracts/check_postcondition5.c @@ -0,0 +1,8 @@ +void my_function(int *in, int *out) __CPROVER_requires(__CPROVER_rw_ok(in)) + __CPROVER_requires(__CPROVER_rw_ok(out)) + __CPROVER_requires(!__CPROVER_same_object(in, out)) + __CPROVER_assigns(*in, *out) __CPROVER_ensures(*out == __CPROVER_old(*in)) +{ + *out = *in; + *in = 0; // overwrite +} diff --git a/regression/cprover/large_step/contracts/check_postcondition5.desc b/regression/cprover/large_step/contracts/check_postcondition5.desc new file mode 100644 index 00000000000..c35a47d73c9 --- /dev/null +++ b/regression/cprover/large_step/contracts/check_postcondition5.desc @@ -0,0 +1,7 @@ +CORE +check_postcondition5.c + +^EXIT=0$ +^SIGNAL=0$ +^\[my_function\.postcondition\.1\] line \d+ postcondition: SUCCESS$ +-- diff --git a/regression/cprover/large_step/contracts/check_postcondition6.c b/regression/cprover/large_step/contracts/check_postcondition6.c new file mode 100644 index 00000000000..4593e5ac1b9 --- /dev/null +++ b/regression/cprover/large_step/contracts/check_postcondition6.c @@ -0,0 +1,10 @@ +int my_function(int x) + __CPROVER_ensures(__CPROVER_return_value == __CPROVER_old(x)) +{ + for(int i = 0; i < 100; i++) + { + // does not modify x + } + + return x; +} diff --git a/regression/cprover/large_step/contracts/check_postcondition6.desc b/regression/cprover/large_step/contracts/check_postcondition6.desc new file mode 100644 index 00000000000..665b372c363 --- /dev/null +++ b/regression/cprover/large_step/contracts/check_postcondition6.desc @@ -0,0 +1,7 @@ +CORE +check_postcondition6.c + +^EXIT=0$ +^SIGNAL=0$ +^\[my_function\.postcondition\.1\] line \d+ postcondition: SUCCESS$ +-- diff --git a/regression/cprover/large_step/contracts/check_precondition1.c b/regression/cprover/large_step/contracts/check_precondition1.c new file mode 100644 index 00000000000..e2baa844323 --- /dev/null +++ b/regression/cprover/large_step/contracts/check_precondition1.c @@ -0,0 +1,13 @@ +void my_function(int parameter) + // clang-format off + __CPROVER_requires(parameter >= 10) +// clang-format on +{ +} + +int main() +{ + my_function(-123); // fails + my_function(123); // passes + return 0; +} diff --git a/regression/cprover/large_step/contracts/check_precondition1.desc b/regression/cprover/large_step/contracts/check_precondition1.desc new file mode 100644 index 00000000000..dc79c98981e --- /dev/null +++ b/regression/cprover/large_step/contracts/check_precondition1.desc @@ -0,0 +1,8 @@ +CORE +check_precondition1.c + +^EXIT=10$ +^SIGNAL=0$ +^\[main\.precondition\.1\] line \d+ my_function precondition .*: REFUTED$ +^\[main\.precondition\.2\] line \d+ my_function precondition .*: SUCCESS$ +-- diff --git a/regression/cprover/large_step/contracts/check_precondition2.c b/regression/cprover/large_step/contracts/check_precondition2.c new file mode 100644 index 00000000000..c919dd08be4 --- /dev/null +++ b/regression/cprover/large_step/contracts/check_precondition2.c @@ -0,0 +1,15 @@ +void callee(int parameter) + // clang-format off + __CPROVER_requires(parameter >= 10) +// clang-format on +{ +} + +void caller(int some_value) + // clang-format off + __CPROVER_requires(1) +// clang-format on +{ + if(some_value >= 10) + callee(some_value); // precondition passes +} diff --git a/regression/cprover/large_step/contracts/check_precondition2.desc b/regression/cprover/large_step/contracts/check_precondition2.desc new file mode 100644 index 00000000000..1dc91b5e22b --- /dev/null +++ b/regression/cprover/large_step/contracts/check_precondition2.desc @@ -0,0 +1,7 @@ +CORE +check_precondition2.c + +^EXIT=0$ +^SIGNAL=0$ +^\[caller\.precondition\.1\] line \d+ callee precondition parameter >= 10: SUCCESS$ +-- diff --git a/regression/cprover/large_step/contracts/check_return_value1.c b/regression/cprover/large_step/contracts/check_return_value1.c new file mode 100644 index 00000000000..c5047444ac0 --- /dev/null +++ b/regression/cprover/large_step/contracts/check_return_value1.c @@ -0,0 +1,15 @@ +int my_function1(void) + // clang-format off + __CPROVER_ensures(__CPROVER_return_value >= 0) // passes +// clang-format on +{ + return 10; +} + +int my_function2(void) + // clang-format off + __CPROVER_ensures(__CPROVER_return_value >= 0) // fails +// clang-format on +{ + return -10; +} diff --git a/regression/cprover/large_step/contracts/check_return_value1.desc b/regression/cprover/large_step/contracts/check_return_value1.desc new file mode 100644 index 00000000000..e7252fe054f --- /dev/null +++ b/regression/cprover/large_step/contracts/check_return_value1.desc @@ -0,0 +1,8 @@ +CORE +check_return_value1.c + +^EXIT=10$ +^SIGNAL=0$ +^\[my_function1\.postcondition\.1\] line \d+ postcondition: SUCCESS$ +^\[my_function2\.postcondition\.1\] line \d+ postcondition: REFUTED$ +-- diff --git a/regression/cprover/large_step/contracts/configured_contract1.c b/regression/cprover/large_step/contracts/configured_contract1.c new file mode 100644 index 00000000000..efe45304779 --- /dev/null +++ b/regression/cprover/large_step/contracts/configured_contract1.c @@ -0,0 +1,12 @@ +int global; + +// no contract given at all +void my_function1(int parameter) +{ + global = 10; +} + +// no contact given at all +void my_function2(int parameter) +{ +} diff --git a/regression/cprover/large_step/contracts/configured_contract1.desc b/regression/cprover/large_step/contracts/configured_contract1.desc new file mode 100644 index 00000000000..0d32e00d427 --- /dev/null +++ b/regression/cprover/large_step/contracts/configured_contract1.desc @@ -0,0 +1,8 @@ +KNOWNBUG +configured_contract1.yaml + +^EXIT=0$ +^SIGNAL=0$ +^program is safe / function my_function1 is safe / postcondition: SUCCESS$ +^program is safe / function my_function2 is safe / postcondition: REFUTED$ +-- diff --git a/regression/cprover/large_step/contracts/configured_contract2.c b/regression/cprover/large_step/contracts/configured_contract2.c new file mode 100644 index 00000000000..b6c2880e774 --- /dev/null +++ b/regression/cprover/large_step/contracts/configured_contract2.c @@ -0,0 +1,9 @@ +int global; + +#define MY_MAGIC_VALUE 10 + +// no contract given at all +void my_function1(int parameter) +{ + global = MY_MAGIC_VALUE; +} diff --git a/regression/cprover/large_step/contracts/configured_contract2.desc b/regression/cprover/large_step/contracts/configured_contract2.desc new file mode 100644 index 00000000000..892e11d3604 --- /dev/null +++ b/regression/cprover/large_step/contracts/configured_contract2.desc @@ -0,0 +1,7 @@ +KNOWNBUG +configured_contract2.yaml + +^EXIT=0$ +^SIGNAL=0$ +^program is safe / function my_function1 is safe / postcondition: SUCCESS$ +-- diff --git a/regression/cprover/large_step/contracts/integer_range1.c b/regression/cprover/large_step/contracts/integer_range1.c new file mode 100644 index 00000000000..27be359e147 --- /dev/null +++ b/regression/cprover/large_step/contracts/integer_range1.c @@ -0,0 +1,25 @@ +typedef __CPROVER_size_t size_t; + +void returns_a_range(const char *base, size_t size, size_t *pos) + // clang-format off + __CPROVER_requires(__CPROVER_r_ok(base, size)) + __CPROVER_requires(__CPROVER_rw_ok(pos)) + __CPROVER_requires(*pos <= size) + __CPROVER_assigns(*pos) + __CPROVER_ensures(*pos <= size) +// clang-format on +{ + size_t p = *pos; + + // skip a pair of double quotes + if(p < size && base[p] == '"') + { + p++; + + if(p < size && base[p] == '"') + { + p++; + *pos = p; + } + } +} diff --git a/regression/cprover/large_step/contracts/integer_range1.desc b/regression/cprover/large_step/contracts/integer_range1.desc new file mode 100644 index 00000000000..24e0c040b10 --- /dev/null +++ b/regression/cprover/large_step/contracts/integer_range1.desc @@ -0,0 +1,6 @@ +CORE +integer_range1.c + +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/contracts/integer_range2.c b/regression/cprover/large_step/contracts/integer_range2.c new file mode 100644 index 00000000000..63d5fb22ac6 --- /dev/null +++ b/regression/cprover/large_step/contracts/integer_range2.c @@ -0,0 +1,24 @@ +typedef __CPROVER_size_t size_t; + +void returns_a_range(const char *base, size_t size, size_t pos, size_t *length) + // clang-format off + __CPROVER_requires(__CPROVER_r_ok(base, size)) + __CPROVER_requires(pos <= size) + __CPROVER_requires(__CPROVER_rw_ok(length)) + __CPROVER_assigns(*length) + __CPROVER_ensures(__CPROVER_old(pos) + *length <= size) +// clang-format on +{ + // skip a pair of double quotes + size_t start = pos; + + if(pos < size && base[pos] == '"') + { + pos++; + + if(pos < size && base[pos] == '"') + pos++; + } + + *length = pos - start; +} diff --git a/regression/cprover/large_step/contracts/integer_range2.desc b/regression/cprover/large_step/contracts/integer_range2.desc new file mode 100644 index 00000000000..153353437ab --- /dev/null +++ b/regression/cprover/large_step/contracts/integer_range2.desc @@ -0,0 +1,6 @@ +CORE +integer_range2.c + +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/contracts/integer_range3.c b/regression/cprover/large_step/contracts/integer_range3.c new file mode 100644 index 00000000000..7442de8c612 --- /dev/null +++ b/regression/cprover/large_step/contracts/integer_range3.c @@ -0,0 +1,28 @@ +typedef __CPROVER_size_t size_t; + +_Bool returns_a_range(const char *base, size_t size, size_t pos, size_t *length) + // clang-format off + __CPROVER_requires(__CPROVER_r_ok(base, size)) __CPROVER_requires(pos <= size) + __CPROVER_requires(__CPROVER_rw_ok(length)) __CPROVER_assigns(*length) + __CPROVER_ensures( + __CPROVER_return_value ==> __CPROVER_old(pos) + *length <= size) + // clang-format off +{ + // skip a pair of double quotes + size_t start = pos; + _Bool result = 0; + + if(pos < size && base[pos] == '"') + { + pos++; + + if(pos < size && base[pos] == '"') + { + pos++; + *length = pos - start; + result = 1; + } + } + + return result; +} diff --git a/regression/cprover/large_step/contracts/integer_range3.desc b/regression/cprover/large_step/contracts/integer_range3.desc new file mode 100644 index 00000000000..831250508ae --- /dev/null +++ b/regression/cprover/large_step/contracts/integer_range3.desc @@ -0,0 +1,6 @@ +CORE +integer_range3.c + +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/contracts/integer_range4.c b/regression/cprover/large_step/contracts/integer_range4.c new file mode 100644 index 00000000000..d4075f69307 --- /dev/null +++ b/regression/cprover/large_step/contracts/integer_range4.c @@ -0,0 +1,35 @@ +typedef __CPROVER_size_t size_t; + +_Bool returns_a_range(const char *base, size_t size, size_t pos, size_t *length) + // clang-format off + __CPROVER_requires(__CPROVER_r_ok(base, size)) + __CPROVER_requires(pos <= size) + __CPROVER_requires(__CPROVER_rw_ok(length)) + __CPROVER_assigns(*length) + __CPROVER_ensures(__CPROVER_return_value ==> __CPROVER_old(pos) + *length <= size) +// clang-format on +{ + // skip any number of double quotes + size_t start = pos; + _Bool result = 0; + + while(pos < size && base[pos] == '"') + // clang-format off + __CPROVER_loop_invariant(__CPROVER_r_ok(base, size)) + __CPROVER_loop_invariant(__CPROVER_rw_ok(length)) + __CPROVER_loop_invariant(!result) + // clang-format on + { + // out to be loop invariant + __CPROVER_assert(__CPROVER_old(pos) == start, "property 1"); + pos++; + } + + if(pos > start) + { + *length = pos - start; + result = 1; + } + + return result; +} diff --git a/regression/cprover/large_step/contracts/integer_range4.desc b/regression/cprover/large_step/contracts/integer_range4.desc new file mode 100644 index 00000000000..f673f704eaf --- /dev/null +++ b/regression/cprover/large_step/contracts/integer_range4.desc @@ -0,0 +1,6 @@ +KNOWNBUG +integer_range4.c + +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/contracts/memory_safety1.c b/regression/cprover/large_step/contracts/memory_safety1.c new file mode 100644 index 00000000000..c8f6b3b800a --- /dev/null +++ b/regression/cprover/large_step/contracts/memory_safety1.c @@ -0,0 +1,5 @@ +// no contract given at all +void my_function(int *pointer) +{ + *pointer = 123; +} diff --git a/regression/cprover/large_step/contracts/memory_safety1.desc b/regression/cprover/large_step/contracts/memory_safety1.desc new file mode 100644 index 00000000000..24307e12e11 --- /dev/null +++ b/regression/cprover/large_step/contracts/memory_safety1.desc @@ -0,0 +1,7 @@ +KNOWNBUG +memory_safety1.yaml + +^EXIT=0$ +^SIGNAL=0$ +^program is safe / function my_function is safe / dereference line .*: SUCCESS$ +-- diff --git a/regression/cprover/large_step/contracts/nested1.c b/regression/cprover/large_step/contracts/nested1.c new file mode 100644 index 00000000000..2d392b59afc --- /dev/null +++ b/regression/cprover/large_step/contracts/nested1.c @@ -0,0 +1,16 @@ +void callee(int *p) + // clang-format off + __CPROVER_requires(__CPROVER_rw_ok(p)) +// clang-format on +{ +} + +void caller(int *p) + // clang-format off + __CPROVER_requires(__CPROVER_rw_ok(p)) +// clang-format on +{ + int i; + __CPROVER_assert(__CPROVER_rw_ok(p), "property 1"); + callee(&i); +} diff --git a/regression/cprover/large_step/contracts/nested1.desc b/regression/cprover/large_step/contracts/nested1.desc new file mode 100644 index 00000000000..7d95d6650f0 --- /dev/null +++ b/regression/cprover/large_step/contracts/nested1.desc @@ -0,0 +1,8 @@ +CORE +nested1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[caller\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[caller\.precondition\.1\] line \d+ callee precondition .*: SUCCESS$ +-- diff --git a/regression/cprover/large_step/contracts/one_function1.c b/regression/cprover/large_step/contracts/one_function1.c new file mode 100644 index 00000000000..e48cc77ec38 --- /dev/null +++ b/regression/cprover/large_step/contracts/one_function1.c @@ -0,0 +1,7 @@ +void my_function1() __CPROVER_ensures(0) // fails +{ +} + +void my_function2() __CPROVER_ensures(1) // passes +{ +} diff --git a/regression/cprover/large_step/contracts/one_function1.desc b/regression/cprover/large_step/contracts/one_function1.desc new file mode 100644 index 00000000000..a42d505aa4a --- /dev/null +++ b/regression/cprover/large_step/contracts/one_function1.desc @@ -0,0 +1,8 @@ +CORE +one_function1.c +--contract my_function2 +^EXIT=0$ +^SIGNAL=0$ +^\[my_function2\.postcondition\.1\] line \d+ postcondition: SUCCESS$ +-- +^\[my_function1\.postcondition\.1\] line \d+ postcondition: REFUTED$ diff --git a/regression/cprover/large_step/contracts/recursive_function1.c b/regression/cprover/large_step/contracts/recursive_function1.c new file mode 100644 index 00000000000..111471fb986 --- /dev/null +++ b/regression/cprover/large_step/contracts/recursive_function1.c @@ -0,0 +1,8 @@ +int recursive_function(int parameter) + __CPROVER_requires(parameter >= 0) // passes +{ + if(parameter == 0) + return 0; + else + return recursive_function(parameter - 1) + 1; +} diff --git a/regression/cprover/large_step/contracts/recursive_function1.desc b/regression/cprover/large_step/contracts/recursive_function1.desc new file mode 100644 index 00000000000..4b203ae12ff --- /dev/null +++ b/regression/cprover/large_step/contracts/recursive_function1.desc @@ -0,0 +1,7 @@ +CORE +recursive_function1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[recursive_function\.precondition\.1] line \d+ recursive_function precondition.*: SUCCESS$ +-- diff --git a/regression/cprover/large_step/contracts/recursive_function2.c b/regression/cprover/large_step/contracts/recursive_function2.c new file mode 100644 index 00000000000..853afd6cd2a --- /dev/null +++ b/regression/cprover/large_step/contracts/recursive_function2.c @@ -0,0 +1,5 @@ +int recursive_function() + __CPROVER_ensures(__CPROVER_return_value == 10) // passes +{ + return recursive_function(); +} diff --git a/regression/cprover/large_step/contracts/recursive_function2.desc b/regression/cprover/large_step/contracts/recursive_function2.desc new file mode 100644 index 00000000000..2c37817d6a0 --- /dev/null +++ b/regression/cprover/large_step/contracts/recursive_function2.desc @@ -0,0 +1,7 @@ +CORE +recursive_function2.c + +^EXIT=0$ +^SIGNAL=0$ +^\[recursive_function\.postcondition\.1] line \d+ postcondition: SUCCESS$ +-- diff --git a/regression/cprover/large_step/contracts/use_assigns1.c b/regression/cprover/large_step/contracts/use_assigns1.c new file mode 100644 index 00000000000..61f8949f4e1 --- /dev/null +++ b/regression/cprover/large_step/contracts/use_assigns1.c @@ -0,0 +1,16 @@ +int global; + +void my_function1(void) __CPROVER_assigns() +{ +} + +int main() +{ + global = 1; + + my_function1(); // does not assign 'global' + + __CPROVER_assert(global == 1, "property 1"); + + return 0; +} diff --git a/regression/cprover/large_step/contracts/use_assigns1.desc b/regression/cprover/large_step/contracts/use_assigns1.desc new file mode 100644 index 00000000000..58379a2849b --- /dev/null +++ b/regression/cprover/large_step/contracts/use_assigns1.desc @@ -0,0 +1,7 @@ +CORE +use_assigns1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/contracts/use_assigns2.c b/regression/cprover/large_step/contracts/use_assigns2.c new file mode 100644 index 00000000000..418e3480e76 --- /dev/null +++ b/regression/cprover/large_step/contracts/use_assigns2.c @@ -0,0 +1,16 @@ +int global; + +void my_function1(void) __CPROVER_assigns(global) +{ +} + +int main() +{ + global = 1; + + my_function1(); // does assign 'global' + + __CPROVER_assert(global == 1, "property 1"); // fails + + return 0; +} diff --git a/regression/cprover/large_step/contracts/use_assigns2.desc b/regression/cprover/large_step/contracts/use_assigns2.desc new file mode 100644 index 00000000000..bce4f56f182 --- /dev/null +++ b/regression/cprover/large_step/contracts/use_assigns2.desc @@ -0,0 +1,7 @@ +CORE +use_assigns2.c + +^EXIT=10$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: REFUTED$ +-- diff --git a/regression/cprover/large_step/contracts/use_old1.c b/regression/cprover/large_step/contracts/use_old1.c new file mode 100644 index 00000000000..bb57b4c57da --- /dev/null +++ b/regression/cprover/large_step/contracts/use_old1.c @@ -0,0 +1,6 @@ +void my_function(int parameter) __CPROVER_requires(1) +{ + int copy = parameter; + parameter = 456; + __CPROVER_assert(copy == __CPROVER_old(parameter), "property 1"); +} diff --git a/regression/cprover/large_step/contracts/use_old1.desc b/regression/cprover/large_step/contracts/use_old1.desc new file mode 100644 index 00000000000..2630bdd1987 --- /dev/null +++ b/regression/cprover/large_step/contracts/use_old1.desc @@ -0,0 +1,7 @@ +CORE +use_old1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[my_function\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/contracts/use_old2.c b/regression/cprover/large_step/contracts/use_old2.c new file mode 100644 index 00000000000..1e1e96cbe6b --- /dev/null +++ b/regression/cprover/large_step/contracts/use_old2.c @@ -0,0 +1,12 @@ +void my_function(unsigned parameter) + // clang-format off + __CPROVER_requires(1) +// clang-format on +{ + for(unsigned counter = 0; counter != 100; counter++) + { + __CPROVER_assert(parameter == __CPROVER_old(parameter), "property 1"); + } + + __CPROVER_assert(parameter == __CPROVER_old(parameter), "property 2"); +} diff --git a/regression/cprover/large_step/contracts/use_old2.desc b/regression/cprover/large_step/contracts/use_old2.desc new file mode 100644 index 00000000000..dc7286b7daa --- /dev/null +++ b/regression/cprover/large_step/contracts/use_old2.desc @@ -0,0 +1,8 @@ +CORE +use_old2.c + +^EXIT=0$ +^SIGNAL=0$ +^\[my_function\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[my_function\.assertion\.2\] line \d+ property 2: SUCCESS$ +-- diff --git a/regression/cprover/large_step/contracts/use_postcondition1.c b/regression/cprover/large_step/contracts/use_postcondition1.c new file mode 100644 index 00000000000..fba09bf368f --- /dev/null +++ b/regression/cprover/large_step/contracts/use_postcondition1.c @@ -0,0 +1,13 @@ +int global; + +void callee() __CPROVER_ensures(global >= 10) __CPROVER_assigns(global) +{ + global = 20; +} + +int main() +{ + callee(); + __CPROVER_assert(global >= 10, "property 1"); + return 0; +} diff --git a/regression/cprover/large_step/contracts/use_postcondition1.desc b/regression/cprover/large_step/contracts/use_postcondition1.desc new file mode 100644 index 00000000000..8164fa8ec70 --- /dev/null +++ b/regression/cprover/large_step/contracts/use_postcondition1.desc @@ -0,0 +1,9 @@ +CORE +use_postcondition1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[callee\.assigns\.1\] line \d+ assigns clause: SUCCESS$ +^\[callee\.postcondition\.1\] line \d+ postcondition: SUCCESS$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/contracts/use_postcondition2.c b/regression/cprover/large_step/contracts/use_postcondition2.c new file mode 100644 index 00000000000..c7133397568 --- /dev/null +++ b/regression/cprover/large_step/contracts/use_postcondition2.c @@ -0,0 +1,14 @@ +int global; + +void callee() __CPROVER_ensures(global >= 10) __CPROVER_assigns(global) +{ + global = 20; +} + +int main() +{ + global = 1; + callee(); + __CPROVER_assert(0, "property 1"); // should fail + return 0; +} diff --git a/regression/cprover/large_step/contracts/use_postcondition4.c b/regression/cprover/large_step/contracts/use_postcondition4.c new file mode 100644 index 00000000000..5fbe7fb8076 --- /dev/null +++ b/regression/cprover/large_step/contracts/use_postcondition4.c @@ -0,0 +1,19 @@ +int global1, global2; + +void callee() + // clang-format off + __CPROVER_ensures(global2 == __CPROVER_old(global1)) + __CPROVER_assigns(global1, global2) +// clang-format on +{ + global2 = global1; + global1 = 20; +} + +int main() +{ + global1 = 123; + callee(); + __CPROVER_assert(global2 == 123, "property 1"); + return 0; +} diff --git a/regression/cprover/large_step/contracts/use_postcondition4.desc b/regression/cprover/large_step/contracts/use_postcondition4.desc new file mode 100644 index 00000000000..a24466214ef --- /dev/null +++ b/regression/cprover/large_step/contracts/use_postcondition4.desc @@ -0,0 +1,8 @@ +CORE +use_postcondition4.c + +^EXIT=0$ +^SIGNAL=0$ +^\[callee\.postcondition\.1\] line \d+ postcondition: SUCCESS$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/contracts/use_precondition1.c b/regression/cprover/large_step/contracts/use_precondition1.c new file mode 100644 index 00000000000..b2cd0c3f19c --- /dev/null +++ b/regression/cprover/large_step/contracts/use_precondition1.c @@ -0,0 +1,8 @@ +void my_function(int parameter) + // clang-format off + __CPROVER_requires(parameter >= 10) +// clang-format on +{ + __CPROVER_assert(parameter != 0, "property 1"); // passes + __CPROVER_assert(parameter != 20, "property 2"); // fails +} diff --git a/regression/cprover/large_step/contracts/use_precondition1.desc b/regression/cprover/large_step/contracts/use_precondition1.desc new file mode 100644 index 00000000000..b74d6c38ab8 --- /dev/null +++ b/regression/cprover/large_step/contracts/use_precondition1.desc @@ -0,0 +1,8 @@ +CORE +use_precondition1.c + +^EXIT=10$ +^SIGNAL=0$ +^\[my_function\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[my_function\.assertion\.2\] line \d+ property 2: REFUTED$ +-- diff --git a/regression/cprover/large_step/contracts/use_precondition2.c b/regression/cprover/large_step/contracts/use_precondition2.c new file mode 100644 index 00000000000..84d963d27db --- /dev/null +++ b/regression/cprover/large_step/contracts/use_precondition2.c @@ -0,0 +1,8 @@ +void my_function(const int *p) + // clang-format off + __CPROVER_requires(__CPROVER_r_ok(p)) + __CPROVER_requires(*p >= 20) +// clang-format on +{ + __CPROVER_assert(*p != 0, "property 1"); // passes +} diff --git a/regression/cprover/large_step/contracts/use_precondition2.desc b/regression/cprover/large_step/contracts/use_precondition2.desc new file mode 100644 index 00000000000..964ca1c55f2 --- /dev/null +++ b/regression/cprover/large_step/contracts/use_precondition2.desc @@ -0,0 +1,9 @@ +CORE +use_precondition2.c +--safety +^EXIT=0$ +^SIGNAL=0$ +^\[my_function\.pointer\.1\] line \d+ pointer p safe: SUCCESS$ +^\[my_function\.pointer\.2\] line \d+ pointer p safe: SUCCESS$ +^\[my_function\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/cstrings/cstring1.c b/regression/cprover/large_step/cstrings/cstring1.c new file mode 100644 index 00000000000..9dccf42e8f6 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring1.c @@ -0,0 +1,7 @@ +int main() +{ + char buffer[100]; + buffer[10] = 0; + __CPROVER_assert(__CPROVER_is_cstring(buffer), "property 1"); // passes + return 0; +} diff --git a/regression/cprover/large_step/cstrings/cstring1.desc b/regression/cprover/large_step/cstrings/cstring1.desc new file mode 100644 index 00000000000..e4bf9ccd9fd --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring1.desc @@ -0,0 +1,7 @@ +CORE +cstring1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/cstrings/cstring10.c b/regression/cprover/large_step/cstrings/cstring10.c new file mode 100644 index 00000000000..3d659fe8dc0 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring10.c @@ -0,0 +1,9 @@ +int main() +{ + char buffer[100], *p, *q; + q = buffer; // take address + buffer[10] = 0; + *p = 123; // might point into buffer + __CPROVER_assert(__CPROVER_is_cstring(buffer), "property 1"); // fails + return 0; +} diff --git a/regression/cprover/large_step/cstrings/cstring10.desc b/regression/cprover/large_step/cstrings/cstring10.desc new file mode 100644 index 00000000000..d42368d3929 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring10.desc @@ -0,0 +1,7 @@ +CORE +cstring10.c + +^EXIT=10$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: REFUTED$ +-- diff --git a/regression/cprover/large_step/cstrings/cstring2.c b/regression/cprover/large_step/cstrings/cstring2.c new file mode 100644 index 00000000000..926e29bc707 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring2.c @@ -0,0 +1,10 @@ +int main() +{ + char buffer[100]; + + // simply state equality + uninterpreted function + if(__CPROVER_is_cstring(buffer)) + __CPROVER_assert(__CPROVER_is_cstring(buffer), "property 1"); // passes + + return 0; +} diff --git a/regression/cprover/large_step/cstrings/cstring2.desc b/regression/cprover/large_step/cstrings/cstring2.desc new file mode 100644 index 00000000000..c6dd3f06e9f --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring2.desc @@ -0,0 +1,7 @@ +CORE +cstring2.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/cstrings/cstring3.c b/regression/cprover/large_step/cstrings/cstring3.c new file mode 100644 index 00000000000..987ba47bf9c --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring3.c @@ -0,0 +1,8 @@ +int main() +{ + char buffer[100]; + buffer[10] = 0; // establish + buffer[10] = 1; // wreck + __CPROVER_assert(__CPROVER_is_cstring(buffer), "property 1"); // fails + return 0; +} diff --git a/regression/cprover/large_step/cstrings/cstring3.desc b/regression/cprover/large_step/cstrings/cstring3.desc new file mode 100644 index 00000000000..dc369db9b58 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring3.desc @@ -0,0 +1,7 @@ +CORE +cstring3.c + +^EXIT=10$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: REFUTED$ +-- diff --git a/regression/cprover/large_step/cstrings/cstring4.c b/regression/cprover/large_step/cstrings/cstring4.c new file mode 100644 index 00000000000..6831f74142c --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring4.c @@ -0,0 +1,8 @@ +int main() +{ + char buffer[100], ch; + __CPROVER_assume(__CPROVER_is_cstring(buffer)); + ch = 'a'; // does not affect 'buffer' + __CPROVER_assert(__CPROVER_is_cstring(buffer), "property 1"); // passes + return 0; +} diff --git a/regression/cprover/large_step/cstrings/cstring4.desc b/regression/cprover/large_step/cstrings/cstring4.desc new file mode 100644 index 00000000000..fb7c231131c --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring4.desc @@ -0,0 +1,7 @@ +CORE +cstring4.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/cstrings/cstring5.c b/regression/cprover/large_step/cstrings/cstring5.c new file mode 100644 index 00000000000..54dd60c2465 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring5.c @@ -0,0 +1,9 @@ +int main() +{ + char buffer[100], *p, ch; + p = &ch; + __CPROVER_assume(__CPROVER_is_cstring(buffer)); + *p = 'a'; // possibly wreck, but doesn't happen + __CPROVER_assert(__CPROVER_is_cstring(buffer), "property 1"); // passes + return 0; +} diff --git a/regression/cprover/large_step/cstrings/cstring5.desc b/regression/cprover/large_step/cstrings/cstring5.desc new file mode 100644 index 00000000000..80d46cbd6f2 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring5.desc @@ -0,0 +1,7 @@ +CORE +cstring5.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/cstrings/cstring6.c b/regression/cprover/large_step/cstrings/cstring6.c new file mode 100644 index 00000000000..6a8a717116d --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring6.c @@ -0,0 +1,9 @@ +int main() +{ + char buffer[100], *p, *q; + buffer[10] = 0; + p = buffer; + __CPROVER_assert(__CPROVER_is_cstring(p), "property 1"); // passes + __CPROVER_assert(__CPROVER_is_cstring(q), "property 2"); // fails + return 0; +} diff --git a/regression/cprover/large_step/cstrings/cstring6.desc b/regression/cprover/large_step/cstrings/cstring6.desc new file mode 100644 index 00000000000..0d84ad6e118 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring6.desc @@ -0,0 +1,8 @@ +CORE +cstring6.c + +^EXIT=10$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: REFUTED$ +-- diff --git a/regression/cprover/large_step/cstrings/cstring7.c b/regression/cprover/large_step/cstrings/cstring7.c new file mode 100644 index 00000000000..53a344607d7 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring7.c @@ -0,0 +1,8 @@ +int main() +{ + char buffer[100], *p; + buffer[10] = 0; + *p = 123; // might point into buffer + __CPROVER_assert(__CPROVER_is_cstring(buffer), "property 1"); // fails + return 0; +} diff --git a/regression/cprover/large_step/cstrings/cstring7.desc b/regression/cprover/large_step/cstrings/cstring7.desc new file mode 100644 index 00000000000..bb05f60ecba --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring7.desc @@ -0,0 +1,7 @@ +CORE +cstring7.c + +^EXIT=10$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: REFUTED$ +-- diff --git a/regression/cprover/large_step/cstrings/cstring8.c b/regression/cprover/large_step/cstrings/cstring8.c new file mode 100644 index 00000000000..b2f10b8b9a1 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring8.c @@ -0,0 +1,9 @@ +int main() +{ + char buffer[100]; + int i; + buffer[10] = 0; + buffer[i] = 123; // wrecks it + __CPROVER_assert(__CPROVER_is_cstring(buffer), "property 1"); // fails + return 0; +} diff --git a/regression/cprover/large_step/cstrings/cstring8.desc b/regression/cprover/large_step/cstrings/cstring8.desc new file mode 100644 index 00000000000..7d61f37b2d3 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring8.desc @@ -0,0 +1,7 @@ +CORE +cstring8.c + +^EXIT=10$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: REFUTED$ +-- diff --git a/regression/cprover/large_step/cstrings/cstring9.c b/regression/cprover/large_step/cstrings/cstring9.c new file mode 100644 index 00000000000..fb42ecafc8a --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring9.c @@ -0,0 +1,12 @@ +int main() +{ + const char *string; + + __CPROVER_assume(__CPROVER_is_cstring(string)); + + const char *p = string; + + __CPROVER_assert(__CPROVER_is_cstring(p), "property 1"); // passes + + return 0; +} diff --git a/regression/cprover/large_step/cstrings/cstring9.desc b/regression/cprover/large_step/cstrings/cstring9.desc new file mode 100644 index 00000000000..92b28dcfa77 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring9.desc @@ -0,0 +1,7 @@ +CORE +cstring9.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/cstrings/cstring_is_function1.c b/regression/cprover/large_step/cstrings/cstring_is_function1.c new file mode 100644 index 00000000000..a9052900c93 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring_is_function1.c @@ -0,0 +1,9 @@ +int main() +{ + const char *p, *q; + __CPROVER_assume(p == q); + __CPROVER_assert( + __CPROVER_is_cstring(p) == __CPROVER_is_cstring(q), "property 1"); // passes + + return 0; +} diff --git a/regression/cprover/large_step/cstrings/cstring_is_function1.desc b/regression/cprover/large_step/cstrings/cstring_is_function1.desc new file mode 100644 index 00000000000..7604dbe6545 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring_is_function1.desc @@ -0,0 +1,7 @@ +CORE +cstring_is_function1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/cstrings/cstring_is_memory_safe1.c b/regression/cprover/large_step/cstrings/cstring_is_memory_safe1.c new file mode 100644 index 00000000000..8080575056a --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring_is_memory_safe1.c @@ -0,0 +1,12 @@ +int main() +{ + const char *p; + __CPROVER_assume(__CPROVER_is_cstring(p)); + + // this is now safe + *p; + + p[1]; // but not that one + + return 0; +} diff --git a/regression/cprover/large_step/cstrings/cstring_is_memory_safe1.desc b/regression/cprover/large_step/cstrings/cstring_is_memory_safe1.desc new file mode 100644 index 00000000000..685679a040e --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring_is_memory_safe1.desc @@ -0,0 +1,8 @@ +CORE +cstring_is_memory_safe1.c +--safety +^EXIT=10$ +^SIGNAL=0$ +^\[main\.pointer\.1\] line \d+ pointer p safe: SUCCESS$ +^\[main\.pointer\.2\] line \d+ pointer .* safe: REFUTED$ +-- diff --git a/regression/cprover/large_step/cstrings/cstring_is_memory_safe2.c b/regression/cprover/large_step/cstrings/cstring_is_memory_safe2.c new file mode 100644 index 00000000000..bd03491e053 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring_is_memory_safe2.c @@ -0,0 +1,10 @@ +int main() +{ + const char *p; + __CPROVER_size_t i; + __CPROVER_assume(__CPROVER_is_cstring(p + i)); + // this is now safe + p[i]; + + return 0; +} diff --git a/regression/cprover/large_step/cstrings/cstring_is_memory_safe2.desc b/regression/cprover/large_step/cstrings/cstring_is_memory_safe2.desc new file mode 100644 index 00000000000..81c68eb5ba0 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring_is_memory_safe2.desc @@ -0,0 +1,7 @@ +CORE +cstring_is_memory_safe2.c +--safety +^EXIT=0$ +^SIGNAL=0$ +^\[main\.pointer\.1\] line \d+ pointer .* safe: SUCCESS$ +-- diff --git a/regression/cprover/large_step/cstrings/cstring_is_memory_safe3.c b/regression/cprover/large_step/cstrings/cstring_is_memory_safe3.c new file mode 100644 index 00000000000..b58c333d77c --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring_is_memory_safe3.c @@ -0,0 +1,12 @@ +int main() +{ + const char *p; + __CPROVER_size_t i; + __CPROVER_assume(__CPROVER_is_cstring(p + i)); + + // this is now safe + const unsigned char *unsigned_p = (const unsigned char *)p; + unsigned_p[i]; + + return 0; +} diff --git a/regression/cprover/large_step/cstrings/cstring_is_memory_safe3.desc b/regression/cprover/large_step/cstrings/cstring_is_memory_safe3.desc new file mode 100644 index 00000000000..ee45ae42ce3 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring_is_memory_safe3.desc @@ -0,0 +1,7 @@ +CORE +cstring_is_memory_safe3.c +--safety +^EXIT=0$ +^SIGNAL=0$ +^\[main\.pointer\.1\] line \d+ pointer .* safe: SUCCESS$ +-- diff --git a/regression/cprover/large_step/cstrings/cstring_is_not_null.c b/regression/cprover/large_step/cstrings/cstring_is_not_null.c new file mode 100644 index 00000000000..eed97894065 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring_is_not_null.c @@ -0,0 +1,10 @@ +int main() +{ + const char *p; + __CPROVER_assume(__CPROVER_is_cstring(p)); + + // p can't be null + __CPROVER_assert(p != 0, "property"); + + return 0; +} diff --git a/regression/cprover/large_step/cstrings/cstring_is_not_null.desc b/regression/cprover/large_step/cstrings/cstring_is_not_null.desc new file mode 100644 index 00000000000..21a959777df --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring_is_not_null.desc @@ -0,0 +1,7 @@ +CORE +cstring_is_not_null.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1] line \d+ property: SUCCESS$ +-- diff --git a/regression/cprover/large_step/cstrings/cstring_plus_one1.c b/regression/cprover/large_step/cstrings/cstring_plus_one1.c new file mode 100644 index 00000000000..dc7cad96f57 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring_plus_one1.c @@ -0,0 +1,10 @@ +int main() +{ + const char *p; + __CPROVER_assume(__CPROVER_is_cstring(p)); + + if(*p != 0) + __CPROVER_assert(__CPROVER_is_cstring(p + 1), "property 1"); // passes + + return 0; +} diff --git a/regression/cprover/large_step/cstrings/cstring_plus_one1.desc b/regression/cprover/large_step/cstrings/cstring_plus_one1.desc new file mode 100644 index 00000000000..150b2dad26d --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring_plus_one1.desc @@ -0,0 +1,7 @@ +CORE +cstring_plus_one1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/cstrings/cstring_plus_one2.c b/regression/cprover/large_step/cstrings/cstring_plus_one2.c new file mode 100644 index 00000000000..a7e41ea2b32 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring_plus_one2.c @@ -0,0 +1,13 @@ +int main() +{ + const char *p; + __CPROVER_assume(__CPROVER_is_cstring(p)); + + if(*p != 0) + { + p++; // might modify the string + __CPROVER_assert(__CPROVER_is_cstring(p), "property 1"); // passes + } + + return 0; +} diff --git a/regression/cprover/large_step/cstrings/cstring_plus_one2.desc b/regression/cprover/large_step/cstrings/cstring_plus_one2.desc new file mode 100644 index 00000000000..6fe932b95ca --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring_plus_one2.desc @@ -0,0 +1,7 @@ +CORE +cstring_plus_one2.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/cstrings/cstring_plus_one3.c b/regression/cprover/large_step/cstrings/cstring_plus_one3.c new file mode 100644 index 00000000000..c16ca65ad24 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring_plus_one3.c @@ -0,0 +1,10 @@ +int main() +{ + const char *p; + __CPROVER_size_t i; + __CPROVER_assume(__CPROVER_is_cstring(p + i)); + __CPROVER_assume(p[i] != 0); + __CPROVER_assert(__CPROVER_is_cstring(p + i + 1), "property 1"); // passes + + return 0; +} diff --git a/regression/cprover/large_step/cstrings/cstring_plus_one3.desc b/regression/cprover/large_step/cstrings/cstring_plus_one3.desc new file mode 100644 index 00000000000..07454ecbbe2 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring_plus_one3.desc @@ -0,0 +1,7 @@ +CORE +cstring_plus_one3.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/cstrings/cstring_plus_one4.c b/regression/cprover/large_step/cstrings/cstring_plus_one4.c new file mode 100644 index 00000000000..e49d600da19 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring_plus_one4.c @@ -0,0 +1,11 @@ +int main() +{ + const char *p; + __CPROVER_size_t i; + __CPROVER_assume(__CPROVER_is_cstring(p + i)); + __CPROVER_assume(p[i] != 0); + i++; + __CPROVER_assert(__CPROVER_is_cstring(p + i), "property 1"); // passes + + return 0; +} diff --git a/regression/cprover/large_step/cstrings/cstring_plus_one4.desc b/regression/cprover/large_step/cstrings/cstring_plus_one4.desc new file mode 100644 index 00000000000..6e3a9b0b737 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring_plus_one4.desc @@ -0,0 +1,7 @@ +CORE +cstring_plus_one4.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/cstrings/cstring_plus_one5.c b/regression/cprover/large_step/cstrings/cstring_plus_one5.c new file mode 100644 index 00000000000..0ac3448bd5f --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring_plus_one5.c @@ -0,0 +1,14 @@ +int main() +{ + const char *p; + + __CPROVER_assume(__CPROVER_is_cstring(p)); + __CPROVER_assume(*p != 0); + + p++; + + __CPROVER_assert(__CPROVER_is_cstring(p), "property 1"); + __CPROVER_assert(__CPROVER_r_ok(p), "property 2"); + + return 0; +} diff --git a/regression/cprover/large_step/cstrings/cstring_plus_one5.desc b/regression/cprover/large_step/cstrings/cstring_plus_one5.desc new file mode 100644 index 00000000000..52511e22c5b --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring_plus_one5.desc @@ -0,0 +1,8 @@ +CORE +cstring_plus_one5.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$ +-- diff --git a/regression/cprover/large_step/cstrings/cstring_preserved1.c b/regression/cprover/large_step/cstrings/cstring_preserved1.c new file mode 100644 index 00000000000..f50eb069268 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring_preserved1.c @@ -0,0 +1,13 @@ +int main() +{ + const char *p; + + __CPROVER_assume(__CPROVER_is_cstring(p)); + + // unrelated + const char *q = 0; + + __CPROVER_assert(__CPROVER_is_cstring(p), "p is still a cstring"); + + return 0; +} diff --git a/regression/cprover/large_step/cstrings/cstring_preserved1.desc b/regression/cprover/large_step/cstrings/cstring_preserved1.desc new file mode 100644 index 00000000000..ab461ddc658 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring_preserved1.desc @@ -0,0 +1,7 @@ +CORE +cstring_preserved1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ p is still a cstring: SUCCESS$ +-- diff --git a/regression/cprover/large_step/cstrings/cstring_preserved2.c b/regression/cprover/large_step/cstrings/cstring_preserved2.c new file mode 100644 index 00000000000..8d4dd3d7eaa --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring_preserved2.c @@ -0,0 +1,8 @@ +void cstring_preserved(const char *p) + __CPROVER_requires(__CPROVER_is_cstring(p)) +{ + // unrelated + __CPROVER_size_t i = 0; + + __CPROVER_assert(__CPROVER_is_cstring(p), "p is still a cstring"); +} diff --git a/regression/cprover/large_step/cstrings/cstring_preserved2.desc b/regression/cprover/large_step/cstrings/cstring_preserved2.desc new file mode 100644 index 00000000000..270cb706f7a --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstring_preserved2.desc @@ -0,0 +1,7 @@ +CORE +cstring_preserved2.c + +^EXIT=0$ +^SIGNAL=0$ +^\[cstring_preserved\.assertion\.1\] line \d+ p is still a cstring: SUCCESS$ +-- diff --git a/regression/cprover/large_step/cstrings/cstrlen1.c b/regression/cprover/large_step/cstrings/cstrlen1.c new file mode 100644 index 00000000000..f67f9a7bbd6 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstrlen1.c @@ -0,0 +1,7 @@ +int main() +{ + char buffer[100]; + buffer[0] = 0; + __CPROVER_assert(__CPROVER_cstrlen(buffer) == 0, "property 1"); // passes + return 0; +} diff --git a/regression/cprover/large_step/cstrings/cstrlen1.desc b/regression/cprover/large_step/cstrings/cstrlen1.desc new file mode 100644 index 00000000000..3b4ca29158e --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstrlen1.desc @@ -0,0 +1,7 @@ +CORE +cstrlen1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/cstrings/cstrlen2.c b/regression/cprover/large_step/cstrings/cstrlen2.c new file mode 100644 index 00000000000..2f8dca1e269 --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstrlen2.c @@ -0,0 +1,5 @@ +void string_access(__CPROVER_size_t length, const char *p) + __CPROVER_requires(__CPROVER_is_cstring(p) && __CPROVER_cstrlen(p) == length) +{ + __CPROVER_assert(p[length] == 0, "property 1"); // passes +} diff --git a/regression/cprover/large_step/cstrings/cstrlen2.desc b/regression/cprover/large_step/cstrings/cstrlen2.desc new file mode 100644 index 00000000000..776afeaaafc --- /dev/null +++ b/regression/cprover/large_step/cstrings/cstrlen2.desc @@ -0,0 +1,7 @@ +KNOWNBUG +cstrlen2.c + +^EXIT=0$ +^SIGNAL=0$ +^program is safe / function string_access is safe / line .* property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/cstrings/iterate_over_string1.c b/regression/cprover/large_step/cstrings/iterate_over_string1.c new file mode 100644 index 00000000000..4d86a3afe96 --- /dev/null +++ b/regression/cprover/large_step/cstrings/iterate_over_string1.c @@ -0,0 +1,16 @@ +int main() +{ + const char *p; + + __CPROVER_assume(__CPROVER_is_cstring(p)); + + while(*p != 0) + // clang-format off + __CPROVER_loop_invariant(__CPROVER_is_cstring(p)) + { + p++; + } + // clang-format on + + return 0; +} diff --git a/regression/cprover/large_step/cstrings/iterate_over_string1.desc b/regression/cprover/large_step/cstrings/iterate_over_string1.desc new file mode 100644 index 00000000000..262af2543eb --- /dev/null +++ b/regression/cprover/large_step/cstrings/iterate_over_string1.desc @@ -0,0 +1,7 @@ +CORE +iterate_over_string1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.invariant\.1\] line \d+ loop invariant: SUCCESS$ +-- diff --git a/regression/cprover/large_step/cstrings/iterate_over_string2.c b/regression/cprover/large_step/cstrings/iterate_over_string2.c new file mode 100644 index 00000000000..3cd9ab95d11 --- /dev/null +++ b/regression/cprover/large_step/cstrings/iterate_over_string2.c @@ -0,0 +1,18 @@ +int main() +{ + const char *p; + + __CPROVER_assume(__CPROVER_is_cstring(p)); + + __CPROVER_size_t i = 0; + + while(p[i] != 0) + // clang-format off + __CPROVER_loop_invariant(__CPROVER_is_cstring(p + i)) + { + i++; + } + // clang-format on + + return 0; +} diff --git a/regression/cprover/large_step/cstrings/iterate_over_string2.desc b/regression/cprover/large_step/cstrings/iterate_over_string2.desc new file mode 100644 index 00000000000..49ca08f539b --- /dev/null +++ b/regression/cprover/large_step/cstrings/iterate_over_string2.desc @@ -0,0 +1,7 @@ +CORE +iterate_over_string2.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.invariant\.1\] line \d+ loop invariant: SUCCESS$ +-- diff --git a/regression/cprover/large_step/cstrings/iterate_over_string3.c b/regression/cprover/large_step/cstrings/iterate_over_string3.c new file mode 100644 index 00000000000..88bcf043bd1 --- /dev/null +++ b/regression/cprover/large_step/cstrings/iterate_over_string3.c @@ -0,0 +1,37 @@ +#define size_t __CPROVER_size_t +#define false 0 + +_Bool compare( + const void *const array, + const size_t array_len, + const char *const c_str) +{ + // const unsigned char *array_bytes = array; + const unsigned char *str_bytes = (const unsigned char *)c_str; + + // jointly iterate over string and array + for(size_t i = 0; i < array_len; ++i) + __CPROVER_loop_invariant(__CPROVER_is_cstring(str_bytes + i)) + { + unsigned char s = str_bytes[i]; + if(s == '\0') + { + return false; + } + + // if (array_bytes[i] != s) { + // return false; + // } + } + + //return str_bytes[array_len] == '\0'; +} + +int main() +{ + unsigned char array[10]; + size_t array_len = 10; + const char *c_str; + __CPROVER_assume(__CPROVER_is_cstring(c_str)); + compare(array, array_len, c_str); +} diff --git a/regression/cprover/large_step/cstrings/iterate_over_string3.desc b/regression/cprover/large_step/cstrings/iterate_over_string3.desc new file mode 100644 index 00000000000..108dc12aea5 --- /dev/null +++ b/regression/cprover/large_step/cstrings/iterate_over_string3.desc @@ -0,0 +1,7 @@ +CORE +iterate_over_string3.c + +^EXIT=0$ +^SIGNAL=0$ +^\[compare\.invariant\.1\] line \d+ loop invariant: SUCCESS$ +-- diff --git a/regression/cprover/large_step/cstrings/string_literal1.c b/regression/cprover/large_step/cstrings/string_literal1.c new file mode 100644 index 00000000000..f2cadc39519 --- /dev/null +++ b/regression/cprover/large_step/cstrings/string_literal1.c @@ -0,0 +1,8 @@ +int main() +{ + char *p = "0123"; + __CPROVER_assert(__CPROVER_is_cstring(p), "property 1"); // passes + __CPROVER_assert(__CPROVER_is_cstring(p + 4), "property 2"); // passes + // __CPROVER_assert(__CPROVER_is_cstring(p+5), "property 3"); // fails + return 0; +} diff --git a/regression/cprover/large_step/cstrings/string_literal1.desc b/regression/cprover/large_step/cstrings/string_literal1.desc new file mode 100644 index 00000000000..665e2502eb9 --- /dev/null +++ b/regression/cprover/large_step/cstrings/string_literal1.desc @@ -0,0 +1,8 @@ +CORE +string_literal1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$ +-- diff --git a/regression/cprover/large_step/cstrings/string_literal2.c b/regression/cprover/large_step/cstrings/string_literal2.c new file mode 100644 index 00000000000..e383a12e30a --- /dev/null +++ b/regression/cprover/large_step/cstrings/string_literal2.c @@ -0,0 +1,11 @@ +const char *HEX_CHARS = "0123456789abcdef"; + +int main() +{ + unsigned char input; + char output; + + output = HEX_CHARS[input & 0xf]; + + return 0; +} diff --git a/regression/cprover/large_step/cstrings/string_literal2.desc b/regression/cprover/large_step/cstrings/string_literal2.desc new file mode 100644 index 00000000000..3a90ab877d3 --- /dev/null +++ b/regression/cprover/large_step/cstrings/string_literal2.desc @@ -0,0 +1,6 @@ +CORE +string_literal2.c +--safety +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/cstrings/string_literal3.c b/regression/cprover/large_step/cstrings/string_literal3.c new file mode 100644 index 00000000000..7826301b224 --- /dev/null +++ b/regression/cprover/large_step/cstrings/string_literal3.c @@ -0,0 +1,7 @@ +int main() +{ + char *p = "0123"; + __CPROVER_assert(__CPROVER_r_ok(p), "property 1"); // passes + __CPROVER_assert(__CPROVER_w_ok(p), "property 2"); // fails + return 0; +} diff --git a/regression/cprover/large_step/cstrings/string_literal3.desc b/regression/cprover/large_step/cstrings/string_literal3.desc new file mode 100644 index 00000000000..a690e7ac3fb --- /dev/null +++ b/regression/cprover/large_step/cstrings/string_literal3.desc @@ -0,0 +1,8 @@ +CORE +string_literal3.c + +^EXIT=10$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: REFUTED$ +-- diff --git a/regression/cprover/large_step/cstrings/string_literal4.c b/regression/cprover/large_step/cstrings/string_literal4.c new file mode 100644 index 00000000000..13694836834 --- /dev/null +++ b/regression/cprover/large_step/cstrings/string_literal4.c @@ -0,0 +1,7 @@ +int main() +{ + char *p = "0123"; + __CPROVER_assert(__CPROVER_OBJECT_SIZE(p) == 5, "property 1"); // passes + __CPROVER_assert(__CPROVER_LIVE_OBJECT(p), "property 2"); // passes + return 0; +} diff --git a/regression/cprover/large_step/cstrings/string_literal4.desc b/regression/cprover/large_step/cstrings/string_literal4.desc new file mode 100644 index 00000000000..16ecee0023a --- /dev/null +++ b/regression/cprover/large_step/cstrings/string_literal4.desc @@ -0,0 +1,6 @@ +CORE +string_literal4.c + +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/cstrings/strlen1.c b/regression/cprover/large_step/cstrings/strlen1.c new file mode 100644 index 00000000000..2260045fb51 --- /dev/null +++ b/regression/cprover/large_step/cstrings/strlen1.c @@ -0,0 +1,21 @@ +__CPROVER_size_t my_strlen(const char *p) + // clang-format off + __CPROVER_requires(__CPROVER_is_cstring(p)) + __CPROVER_ensures(__CPROVER_return_value == __CPROVER_cstrlen(p)) +// clang-format on +{ + __CPROVER_size_t result = 0; + + while(*p != 0) + // clang-format off + __CPROVER_loop_invariant(__CPROVER_is_cstring(p)) + __CPROVER_loop_invariant(p - __CPROVER_old(p) == result) + __CPROVER_loop_invariant(result <= __CPROVER_cstrlen(__CPROVER_old(p))) + { + p++; + result++; + } + // clang-format on + + return result; +} diff --git a/regression/cprover/large_step/cstrings/strlen1.desc b/regression/cprover/large_step/cstrings/strlen1.desc new file mode 100644 index 00000000000..c24acde0e35 --- /dev/null +++ b/regression/cprover/large_step/cstrings/strlen1.desc @@ -0,0 +1,6 @@ +KNOWNBUG +strlen1.c + +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/cstrings/strlen2.c b/regression/cprover/large_step/cstrings/strlen2.c new file mode 100644 index 00000000000..97b61d38f9a --- /dev/null +++ b/regression/cprover/large_step/cstrings/strlen2.c @@ -0,0 +1,7 @@ +__CPROVER_size_t strlen(const char *); + +int main() +{ + strlen("foo"); // safe + strlen(0); // unsafe +} diff --git a/regression/cprover/large_step/cstrings/strlen2.desc b/regression/cprover/large_step/cstrings/strlen2.desc new file mode 100644 index 00000000000..768b395adb3 --- /dev/null +++ b/regression/cprover/large_step/cstrings/strlen2.desc @@ -0,0 +1,8 @@ +CORE +strlen2.c +--safety +^EXIT=10$ +^SIGNAL=0$ +^\[main\.strlen\.1\] line \d+ strlen argument must be C string: SUCCESS$ +^\[main\.strlen\.2\] line \d+ strlen argument must be C string: REFUTED$ +-- diff --git a/regression/cprover/large_step/float/basic-float1.c b/regression/cprover/large_step/float/basic-float1.c new file mode 100644 index 00000000000..90a781ffcdb --- /dev/null +++ b/regression/cprover/large_step/float/basic-float1.c @@ -0,0 +1,6 @@ +int main() +{ + float f = 1.0; + __CPROVER_assert(f + 0.5f == 1.5f, "addition"); + return 0; +} diff --git a/regression/cprover/large_step/float/basic-float1.desc b/regression/cprover/large_step/float/basic-float1.desc new file mode 100644 index 00000000000..e9d78c81ddc --- /dev/null +++ b/regression/cprover/large_step/float/basic-float1.desc @@ -0,0 +1,9 @@ +CORE +basic-float1.c +--text --solve --inline +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S10\(ς\) ⇒ S11\(ς\[❝main::1::f❞:=floatbv_typecast\(1, floatbv\[32\], ς\(❝__CPROVER_rounding_mode❞\)\)\]\)$ +^\(\d+\) ∀ ς : state \. S11\(ς\) ⇒ ieee_float_equal\(floatbv_plus\(ς\(❝main::1::f❞\), 0\.5, ς\(❝__CPROVER_rounding_mode❞\)\), 1\.5\)$ +^\[main\.assertion\.1\] line \d+ addition: SUCCESS$ +-- diff --git a/regression/cprover/large_step/function_calls/call1.c b/regression/cprover/large_step/function_calls/call1.c new file mode 100644 index 00000000000..b6cad2b58c6 --- /dev/null +++ b/regression/cprover/large_step/function_calls/call1.c @@ -0,0 +1,11 @@ +int my_function() +{ + return 10; +} + +int main() +{ + int x; + x = my_function(); + __CPROVER_assert(x == 10, "property 1"); // should pass +} diff --git a/regression/cprover/large_step/function_calls/call1.desc b/regression/cprover/large_step/function_calls/call1.desc new file mode 100644 index 00000000000..3683f897a68 --- /dev/null +++ b/regression/cprover/large_step/function_calls/call1.desc @@ -0,0 +1,7 @@ +CORE +call1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/function_calls/call2.c b/regression/cprover/large_step/function_calls/call2.c new file mode 100644 index 00000000000..c477d3914d6 --- /dev/null +++ b/regression/cprover/large_step/function_calls/call2.c @@ -0,0 +1,9 @@ +// no body +int my_function(); + +int main() +{ + int x; + x = my_function(); + __CPROVER_assert(x == 10, "property 1"); // should fail +} diff --git a/regression/cprover/large_step/function_calls/call2.desc b/regression/cprover/large_step/function_calls/call2.desc new file mode 100644 index 00000000000..0dc0e41bb56 --- /dev/null +++ b/regression/cprover/large_step/function_calls/call2.desc @@ -0,0 +1,7 @@ +CORE +call2.c + +^EXIT=10$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: REFUTED$ +-- diff --git a/regression/cprover/large_step/function_calls/call3.c b/regression/cprover/large_step/function_calls/call3.c new file mode 100644 index 00000000000..e482b27685d --- /dev/null +++ b/regression/cprover/large_step/function_calls/call3.c @@ -0,0 +1,16 @@ +int bar() +{ + return 10; +} + +int foo() +{ + return bar(); +} + +int main() +{ + int x; + x = foo(); + __CPROVER_assert(x == 10, "property 1"); // should pass +} diff --git a/regression/cprover/large_step/function_calls/call3.desc b/regression/cprover/large_step/function_calls/call3.desc new file mode 100644 index 00000000000..3d229e7137a --- /dev/null +++ b/regression/cprover/large_step/function_calls/call3.desc @@ -0,0 +1,7 @@ +CORE +call3.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/function_calls/call4.c b/regression/cprover/large_step/function_calls/call4.c new file mode 100644 index 00000000000..4f5417b5709 --- /dev/null +++ b/regression/cprover/large_step/function_calls/call4.c @@ -0,0 +1,12 @@ +int global; + +void my_function() +{ + global = 10; // a side effect +} + +int main() +{ + my_function(); + __CPROVER_assert(global == 10, "property 1"); // should pass +} diff --git a/regression/cprover/large_step/function_calls/call4.desc b/regression/cprover/large_step/function_calls/call4.desc new file mode 100644 index 00000000000..2d12066f21b --- /dev/null +++ b/regression/cprover/large_step/function_calls/call4.desc @@ -0,0 +1,7 @@ +CORE +call4.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/function_calls/call5.c b/regression/cprover/large_step/function_calls/call5.c new file mode 100644 index 00000000000..b0874037a93 --- /dev/null +++ b/regression/cprover/large_step/function_calls/call5.c @@ -0,0 +1,11 @@ +int my_function(int parameter) +{ + return parameter; +} + +int main() +{ + int x; + x = my_function(123); + __CPROVER_assert(x == 123, "property 1"); // should pass +} diff --git a/regression/cprover/large_step/function_calls/call5.desc b/regression/cprover/large_step/function_calls/call5.desc new file mode 100644 index 00000000000..21dc2b161c8 --- /dev/null +++ b/regression/cprover/large_step/function_calls/call5.desc @@ -0,0 +1,7 @@ +CORE +call5.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/function_calls/call6.c b/regression/cprover/large_step/function_calls/call6.c new file mode 100644 index 00000000000..916117db462 --- /dev/null +++ b/regression/cprover/large_step/function_calls/call6.c @@ -0,0 +1,11 @@ +int my_function(int parameter1, int parameter2) +{ + return parameter1 + parameter2; +} + +int main() +{ + int x; + x = my_function(123, 1); + __CPROVER_assert(x == 124, "property 1"); // should pass +} diff --git a/regression/cprover/large_step/function_calls/call6.desc b/regression/cprover/large_step/function_calls/call6.desc new file mode 100644 index 00000000000..63e9eb2997f --- /dev/null +++ b/regression/cprover/large_step/function_calls/call6.desc @@ -0,0 +1,7 @@ +CORE +call6.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/function_calls/call7.c b/regression/cprover/large_step/function_calls/call7.c new file mode 100644 index 00000000000..8a4fd65b1f8 --- /dev/null +++ b/regression/cprover/large_step/function_calls/call7.c @@ -0,0 +1,11 @@ +int my_function(int *p) +{ + return *p; +} + +int main() +{ + int x, y; + x = my_function(&y); + __CPROVER_assert(x == y, "property 1"); // should pass +} diff --git a/regression/cprover/large_step/function_calls/call7.desc b/regression/cprover/large_step/function_calls/call7.desc new file mode 100644 index 00000000000..5ba7ff2b1b5 --- /dev/null +++ b/regression/cprover/large_step/function_calls/call7.desc @@ -0,0 +1,7 @@ +CORE +call7.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/function_calls/call8.c b/regression/cprover/large_step/function_calls/call8.c new file mode 100644 index 00000000000..f37586f51dc --- /dev/null +++ b/regression/cprover/large_step/function_calls/call8.c @@ -0,0 +1,10 @@ +void my_function(int *p) +{ + *p; +} + +int main() +{ + my_function(0); // not safe + return 0; +} diff --git a/regression/cprover/large_step/function_calls/call8.desc b/regression/cprover/large_step/function_calls/call8.desc new file mode 100644 index 00000000000..fc4b676901f --- /dev/null +++ b/regression/cprover/large_step/function_calls/call8.desc @@ -0,0 +1,7 @@ +CORE +call8.c +--safety +^EXIT=10$ +^SIGNAL=0$ +^\[my_function\.pointer\.1\] line \d+ pointer p safe: REFUTED$ +-- diff --git a/regression/cprover/large_step/function_calls/call_no_body1.c b/regression/cprover/large_step/function_calls/call_no_body1.c new file mode 100644 index 00000000000..8f3d55e3b36 --- /dev/null +++ b/regression/cprover/large_step/function_calls/call_no_body1.c @@ -0,0 +1,7 @@ +int function_without_body(); + +int main() +{ + int x = function_without_body(); + return 0; +} diff --git a/regression/cprover/large_step/function_calls/call_no_body1.desc b/regression/cprover/large_step/function_calls/call_no_body1.desc new file mode 100644 index 00000000000..dc99c1876ad --- /dev/null +++ b/regression/cprover/large_step/function_calls/call_no_body1.desc @@ -0,0 +1,9 @@ +CORE +call_no_body1.c +--text +^EXIT=0$ +^SIGNAL=0$ +^\*\*\*\* WARNING: no body for function function_without_body$ +^\(\d+\) ∀ ς : state, nondet::S18\.2-0 : signedbv\[32\] \. S18\.1\(ς\) ⇒ S18\.2\(ς\[❝main::\$tmp::return_value_function_without_body❞:=nondet::S18\.2-0\]\)$ +^\(\d+\) ∀ ς : state \. S18\.2\(ς\) ⇒ S18\.3\(ς\[❝main::1::x❞:=ς\(❝main::\$tmp::return_value_function_without_body❞\)\]\)$ +-- diff --git a/regression/cprover/large_step/function_calls/call_no_body2.c b/regression/cprover/large_step/function_calls/call_no_body2.c new file mode 100644 index 00000000000..e00056c3245 --- /dev/null +++ b/regression/cprover/large_step/function_calls/call_no_body2.c @@ -0,0 +1,12 @@ +struct some_struct +{ + int x; +}; + +struct some_struct function_without_body(); + +int main() +{ + struct some_struct s = function_without_body(); + return 0; +} diff --git a/regression/cprover/large_step/function_calls/call_no_body2.desc b/regression/cprover/large_step/function_calls/call_no_body2.desc new file mode 100644 index 00000000000..9615edec2f8 --- /dev/null +++ b/regression/cprover/large_step/function_calls/call_no_body2.desc @@ -0,0 +1,7 @@ +CORE +call_no_body2.c +--text +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state, nondet::S18\.2-0 : signedbv\[32\] \. S18\.1\(ς\) ⇒ S18\.2\(ς\[❝main::\$tmp::return_value_function_without_body❞\.❝x❞:=nondet::S18\.2-0\]\)$ +-- diff --git a/regression/cprover/large_step/function_calls/call_twice1.c b/regression/cprover/large_step/function_calls/call_twice1.c new file mode 100644 index 00000000000..41beeb4ec6e --- /dev/null +++ b/regression/cprover/large_step/function_calls/call_twice1.c @@ -0,0 +1,16 @@ +int global; + +void my_function() +{ + global++; // a side effect +} + +int main() +{ + global = 1; + my_function(); + __CPROVER_assert(global == 2, "property 1"); // should pass + + my_function(); + __CPROVER_assert(global == 3, "property 2"); // should pass +} diff --git a/regression/cprover/large_step/function_calls/call_twice1.desc b/regression/cprover/large_step/function_calls/call_twice1.desc new file mode 100644 index 00000000000..22df428dac4 --- /dev/null +++ b/regression/cprover/large_step/function_calls/call_twice1.desc @@ -0,0 +1,8 @@ +CORE +call_twice1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$ +-- diff --git a/regression/cprover/large_step/function_calls/function_pointer1.c b/regression/cprover/large_step/function_calls/function_pointer1.c new file mode 100644 index 00000000000..83492844db5 --- /dev/null +++ b/regression/cprover/large_step/function_calls/function_pointer1.c @@ -0,0 +1,17 @@ +int my_function(void) +{ + return 10; +} + +typedef int (*fptrt)(void); + +int main() +{ + fptrt fptr1 = my_function; + fptrt fptr2 = 0; + + fptr1(); // safe + fptr2(); // unsafe + + return 0; +} diff --git a/regression/cprover/large_step/function_calls/function_pointer1.desc b/regression/cprover/large_step/function_calls/function_pointer1.desc new file mode 100644 index 00000000000..cd13c1a5ebc --- /dev/null +++ b/regression/cprover/large_step/function_calls/function_pointer1.desc @@ -0,0 +1,8 @@ +CORE +function_pointer1.c +--safety +^EXIT=10$ +^SIGNAL=0$ +^\[main\.pointer_dereference\.1\] line \d+ dereferenced function pointer must be my_function: SUCCESS$ +^\[main\.pointer_dereference\.2\] line \d+ dereferenced function pointer must be my_function: REFUTED$ +-- diff --git a/regression/cprover/large_step/function_calls/no_main1.c b/regression/cprover/large_step/function_calls/no_main1.c new file mode 100644 index 00000000000..7ca7977eaeb --- /dev/null +++ b/regression/cprover/large_step/function_calls/no_main1.c @@ -0,0 +1,4 @@ +void my_function(int parameter) +{ + // nothing here +} diff --git a/regression/cprover/large_step/function_calls/no_main1.desc b/regression/cprover/large_step/function_calls/no_main1.desc new file mode 100644 index 00000000000..40e6abdd858 --- /dev/null +++ b/regression/cprover/large_step/function_calls/no_main1.desc @@ -0,0 +1,7 @@ +CORE +no_main1.c + +^EXIT=6$ +^SIGNAL=0$ +^error: The program has no entry point$ +-- diff --git a/regression/cprover/large_step/function_calls/recursion1.c b/regression/cprover/large_step/function_calls/recursion1.c new file mode 100644 index 00000000000..14db6eba800 --- /dev/null +++ b/regression/cprover/large_step/function_calls/recursion1.c @@ -0,0 +1,9 @@ +void foo() +{ + foo(); +} + +int main() +{ + foo(); +} diff --git a/regression/cprover/large_step/function_calls/recursion1.desc b/regression/cprover/large_step/function_calls/recursion1.desc new file mode 100644 index 00000000000..82f4a6600f3 --- /dev/null +++ b/regression/cprover/large_step/function_calls/recursion1.desc @@ -0,0 +1,6 @@ +CORE +recursion1.c + +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/function_calls/va_args1.c b/regression/cprover/large_step/function_calls/va_args1.c new file mode 100644 index 00000000000..de6aad7af37 --- /dev/null +++ b/regression/cprover/large_step/function_calls/va_args1.c @@ -0,0 +1,19 @@ +#include + +int sum(int first, ...) +{ + va_list ap; + va_start(ap, first); + + int result = first; + result += va_arg(ap, int); + result += va_arg(ap, int); + return result; +} + +int main() +{ + int total; + total = sum(1, 2, 3); + __CPROVER_assert(total == 1 + 2 + 3, "property 1"); +} diff --git a/regression/cprover/large_step/function_calls/va_args1.desc b/regression/cprover/large_step/function_calls/va_args1.desc new file mode 100644 index 00000000000..d85bd0bd489 --- /dev/null +++ b/regression/cprover/large_step/function_calls/va_args1.desc @@ -0,0 +1,7 @@ +KNOWNBUG +va_args1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/function_calls/va_args2.c b/regression/cprover/large_step/function_calls/va_args2.c new file mode 100644 index 00000000000..be3b42fe29b --- /dev/null +++ b/regression/cprover/large_step/function_calls/va_args2.c @@ -0,0 +1,18 @@ +#include + +void f(int first, ...) +{ + va_list ap; + va_start(ap, first); + + int second; + second = va_arg(ap, int); + + __CPROVER_assert(first == 1, "property 1"); + __CPROVER_assert(second == 2, "property 2"); +} + +int main() +{ + f(1, 2); +} diff --git a/regression/cprover/large_step/function_calls/va_args2.desc b/regression/cprover/large_step/function_calls/va_args2.desc new file mode 100644 index 00000000000..0874117d3cb --- /dev/null +++ b/regression/cprover/large_step/function_calls/va_args2.desc @@ -0,0 +1,8 @@ +KNOWNBUG +va_args2.c + +^EXIT=0$ +^SIGNAL=0$ +^\[f\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[f\.assertion\.2\] line \d+ property 2: SUCCESS$ +-- diff --git a/regression/cprover/large_step/function_calls/va_args3.c b/regression/cprover/large_step/function_calls/va_args3.c new file mode 100644 index 00000000000..c09a4c78752 --- /dev/null +++ b/regression/cprover/large_step/function_calls/va_args3.c @@ -0,0 +1,22 @@ +#include + +void f(int first, ...) +{ + va_list ap; + va_start(ap, first); + + int second; + second = va_arg(ap, int); + + int third; + third = va_arg(ap, int); + + __CPROVER_assert(first == 1, "property 1"); + __CPROVER_assert(second == 2, "property 2"); + __CPROVER_assert(third == 3, "property 3"); +} + +int main() +{ + f(1, 2, 3); +} diff --git a/regression/cprover/large_step/function_calls/va_args3.desc b/regression/cprover/large_step/function_calls/va_args3.desc new file mode 100644 index 00000000000..3face4e5475 --- /dev/null +++ b/regression/cprover/large_step/function_calls/va_args3.desc @@ -0,0 +1,9 @@ +KNOWNBUG +va_args3.c + +^EXIT=0$ +^SIGNAL=0$ +^\[f\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[f\.assertion\.2\] line \d+ property 2: SUCCESS$ +^\[f\.assertion\.3\] line \d+ property 3: SUCCESS$ +-- diff --git a/regression/cprover/large_step/function_pointers/malloc_wrapper.c b/regression/cprover/large_step/function_pointers/malloc_wrapper.c new file mode 100644 index 00000000000..f0b96c94607 --- /dev/null +++ b/regression/cprover/large_step/function_pointers/malloc_wrapper.c @@ -0,0 +1,13 @@ +void *malloc(__CPROVER_size_t); + +struct my_allocatort +{ + void *(*allocate)(__CPROVER_size_t); +}; + +int main() +{ + struct my_allocatort allocator = {malloc}; + void *p = allocator.allocate(1); + __CPROVER_assert(__CPROVER_rw_ok(p, 1), "property 1"); +} diff --git a/regression/cprover/large_step/function_pointers/malloc_wrapper.desc b/regression/cprover/large_step/function_pointers/malloc_wrapper.desc new file mode 100644 index 00000000000..b0673e1213c --- /dev/null +++ b/regression/cprover/large_step/function_pointers/malloc_wrapper.desc @@ -0,0 +1,7 @@ +CORE +malloc_wrapper.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/lists/sentinel_dll1.c b/regression/cprover/large_step/lists/sentinel_dll1.c new file mode 100644 index 00000000000..34960415f46 --- /dev/null +++ b/regression/cprover/large_step/lists/sentinel_dll1.c @@ -0,0 +1,28 @@ +// Modeled after the AWS C common doubly linked list. +// https://github.com/awslabs/aws-c-common/blob/main/include/aws/common/linked_list.h +// https://github.com/awslabs/aws-c-common/blob/main/include/aws/common/linked_list.inl + +// The 'head' and 'tail' nodes are sentinel nodes, indicating the +// beginning and end of the list. + +#include + +struct List +{ + struct List *n, *p; +}; + +int main() +{ + struct List head, tail; + + // setup the empty list + head.n = &tail; + head.p = 0; + tail.n = 0; + tail.p = &head; + + __CPROVER_assert(__CPROVER_is_sentinel_dll(&head, &tail), "property 1"); + + return 0; +} diff --git a/regression/cprover/large_step/lists/sentinel_dll1.desc b/regression/cprover/large_step/lists/sentinel_dll1.desc new file mode 100644 index 00000000000..ca8d3e3d2b2 --- /dev/null +++ b/regression/cprover/large_step/lists/sentinel_dll1.desc @@ -0,0 +1,7 @@ +CORE +sentinel_dll1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/lists/sentinel_dll2.c b/regression/cprover/large_step/lists/sentinel_dll2.c new file mode 100644 index 00000000000..526b2705f44 --- /dev/null +++ b/regression/cprover/large_step/lists/sentinel_dll2.c @@ -0,0 +1,34 @@ +// Modeled after the AWS C common doubly linked list. +// https://github.com/awslabs/aws-c-common/blob/main/include/aws/common/linked_list.h +// https://github.com/awslabs/aws-c-common/blob/main/include/aws/common/linked_list.inl + +// The 'head' and 'tail' nodes are sentinel nodes, indicating the +// beginning and end of the list. + +#include + +struct List +{ + struct List *n, *p; +}; + +int main() +{ + struct List head, tail; + + // setup the empty list + head.n = &tail; + tail.p = &head; + + // now add one node at the end + struct List new_node; + new_node.n = &tail; + new_node.p = tail.p; + tail.p->n = &new_node; + + // check it's a node + __CPROVER_assert( + __CPROVER_is_sentinel_dll(&head, &tail, &new_node), "property 1"); + + return 0; +} diff --git a/regression/cprover/large_step/lists/sentinel_dll2.desc b/regression/cprover/large_step/lists/sentinel_dll2.desc new file mode 100644 index 00000000000..2aad648b5a5 --- /dev/null +++ b/regression/cprover/large_step/lists/sentinel_dll2.desc @@ -0,0 +1,7 @@ +KNOWNBUG +sentinel_dll2.c + +^EXIT=0$ +^SIGNAL=0$ +^program is safe / function main is safe / line .* property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/lists/sentinel_dll3.c b/regression/cprover/large_step/lists/sentinel_dll3.c new file mode 100644 index 00000000000..e54d37a1af3 --- /dev/null +++ b/regression/cprover/large_step/lists/sentinel_dll3.c @@ -0,0 +1,35 @@ +// Modeled after the AWS C common doubly linked list. +// https://github.com/awslabs/aws-c-common/blob/main/include/aws/common/linked_list.h +// https://github.com/awslabs/aws-c-common/blob/main/include/aws/common/linked_list.inl + +// The 'head' and 'tail' nodes are sentinel nodes, indicating the +// beginning and end of the list. + +#include + +struct List +{ + struct List *n, *p; +}; + +int main() +{ + struct List head, tail; + + // Assume we've got a node in this list! + struct List *node; + __CPROVER_assume(__CPROVER_is_sentinel_dll(&head, &tail, node)); + + // we are either at the end or have another node + if(node->n == &tail) + { + } + else + { + // check it's a node + __CPROVER_assert( + __CPROVER_is_sentinel_dll(&head, &tail, node->n), "property 1"); + } + + return 0; +} diff --git a/regression/cprover/large_step/lists/sentinel_dll3.desc b/regression/cprover/large_step/lists/sentinel_dll3.desc new file mode 100644 index 00000000000..d4f3753f661 --- /dev/null +++ b/regression/cprover/large_step/lists/sentinel_dll3.desc @@ -0,0 +1,7 @@ +KNOWNBUG +sentinel_dll3.c +--no-memory-check +^EXIT=0$ +^SIGNAL=0$ +^program is safe / function main is safe / line .* property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/lists/sentinel_dll4.c b/regression/cprover/large_step/lists/sentinel_dll4.c new file mode 100644 index 00000000000..4649a80c63c --- /dev/null +++ b/regression/cprover/large_step/lists/sentinel_dll4.c @@ -0,0 +1,32 @@ +// Modeled after the AWS C common doubly linked list. +// https://github.com/awslabs/aws-c-common/blob/main/include/aws/common/linked_list.h +// https://github.com/awslabs/aws-c-common/blob/main/include/aws/common/linked_list.inl + +// The 'head' and 'tail' nodes are sentinel nodes, indicating the +// beginning and end of the list. + +#include + +struct List +{ + struct List *n, *p; +}; + +int main() +{ + struct List head, tail; + + // Assume we've got a node in this list! + struct List *node; + __CPROVER_assume(__CPROVER_is_sentinel_dll(&head, &tail, node)); + + // do unrelated assignments + int i = 123; + int *q = &i; + *q = 456; + + // check it's still a node + __CPROVER_assert(__CPROVER_is_sentinel_dll(&head, &tail, node), "property 1"); + + return 0; +} diff --git a/regression/cprover/large_step/lists/sentinel_dll4.desc b/regression/cprover/large_step/lists/sentinel_dll4.desc new file mode 100644 index 00000000000..a8f06001473 --- /dev/null +++ b/regression/cprover/large_step/lists/sentinel_dll4.desc @@ -0,0 +1,7 @@ +CORE +sentinel_dll4.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/lists/sentinel_dll5.c b/regression/cprover/large_step/lists/sentinel_dll5.c new file mode 100644 index 00000000000..3292ca8214c --- /dev/null +++ b/regression/cprover/large_step/lists/sentinel_dll5.c @@ -0,0 +1,30 @@ +// Modeled after the AWS C common doubly linked list. +// https://github.com/awslabs/aws-c-common/blob/main/include/aws/common/linked_list.h +// https://github.com/awslabs/aws-c-common/blob/main/include/aws/common/linked_list.inl + +// The 'head' and 'tail' nodes are sentinel nodes, indicating the +// beginning and end of the list. + +#include + +struct List +{ + struct List *n, *p; +}; + +int main() +{ + struct List head, tail; + + // Assume we've got a node in this list! + struct List *node; + __CPROVER_assume(__CPROVER_is_sentinel_dll(&head, &tail, node)); + + // do unrelated assignment, but to a node type + struct List *other_node = 0; + + // check it's still a node + __CPROVER_assert(__CPROVER_is_sentinel_dll(&head, &tail, node), "property 1"); + + return 0; +} diff --git a/regression/cprover/large_step/lists/sentinel_dll5.desc b/regression/cprover/large_step/lists/sentinel_dll5.desc new file mode 100644 index 00000000000..781f53c5ea8 --- /dev/null +++ b/regression/cprover/large_step/lists/sentinel_dll5.desc @@ -0,0 +1,7 @@ +KNOWNBUG +sentinel_dll5.c + +^EXIT=0$ +^SIGNAL=0$ +^program is safe / function main is safe / line .* property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/loops/assigns1.c b/regression/cprover/large_step/loops/assigns1.c new file mode 100644 index 00000000000..cbeebe4902a --- /dev/null +++ b/regression/cprover/large_step/loops/assigns1.c @@ -0,0 +1,11 @@ +int main() +{ + int x = 123; + + for(int i = 0; i < 10; i++) + { + // does not assign x + } + + __CPROVER_assert(x == 123, "property 1"); // passes +} diff --git a/regression/cprover/large_step/loops/assigns1.desc b/regression/cprover/large_step/loops/assigns1.desc new file mode 100644 index 00000000000..dc513565cac --- /dev/null +++ b/regression/cprover/large_step/loops/assigns1.desc @@ -0,0 +1,8 @@ +CORE +assigns1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- +-- diff --git a/regression/cprover/large_step/loops/assigns2.c b/regression/cprover/large_step/loops/assigns2.c new file mode 100644 index 00000000000..89f26aac8bf --- /dev/null +++ b/regression/cprover/large_step/loops/assigns2.c @@ -0,0 +1,12 @@ +int main() +{ + int x = 123; + + // The loops do not assign x. + for(int i = 0; i < 10; i++) + ; + for(int i = 0; i < 10; i++) + ; + + __CPROVER_assert(x == 123, "property 1"); // passes +} diff --git a/regression/cprover/large_step/loops/assigns2.desc b/regression/cprover/large_step/loops/assigns2.desc new file mode 100644 index 00000000000..f5761f45d38 --- /dev/null +++ b/regression/cprover/large_step/loops/assigns2.desc @@ -0,0 +1,8 @@ +CORE +assigns2.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- +-- diff --git a/regression/cprover/large_step/loops/block_loop.c b/regression/cprover/large_step/loops/block_loop.c new file mode 100644 index 00000000000..a5b98d7b83b --- /dev/null +++ b/regression/cprover/large_step/loops/block_loop.c @@ -0,0 +1,17 @@ +#define BLOCK_SIZE 128 + +int main() +{ + unsigned n; + + unsigned block_count = n / BLOCK_SIZE; + + for(unsigned i = 0; i < block_count; i++) + // clang-format off + __CPROVER_loop_invariant(block_count == n / BLOCK_SIZE) + { + __CPROVER_assert(i * BLOCK_SIZE < n, "property 1"); + __CPROVER_assert(i * BLOCK_SIZE + BLOCK_SIZE - 1 < n, "property 2"); + } + // clang-format on +} diff --git a/regression/cprover/large_step/loops/block_loop.desc b/regression/cprover/large_step/loops/block_loop.desc new file mode 100644 index 00000000000..908056c0ffc --- /dev/null +++ b/regression/cprover/large_step/loops/block_loop.desc @@ -0,0 +1,6 @@ +CORE +block_loop.c + +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/loops/copy1.c b/regression/cprover/large_step/loops/copy1.c new file mode 100644 index 00000000000..de0924e4ef5 --- /dev/null +++ b/regression/cprover/large_step/loops/copy1.c @@ -0,0 +1,22 @@ +int main() +{ + char *input, *output; + __CPROVER_size_t size; + + __CPROVER_assume(__CPROVER_r_ok(input, size)); + __CPROVER_assume(__CPROVER_POINTER_OFFSET(input) == 0); + __CPROVER_assume(__CPROVER_w_ok(output, size)); + __CPROVER_assume(__CPROVER_POINTER_OFFSET(output) == 0); + + for(__CPROVER_size_t i = 0; i < size; i++) + // clang-format off + __CPROVER_loop_invariant(i >= 0 && i <= size) + __CPROVER_loop_invariant(__CPROVER_r_ok(input, size)) + __CPROVER_loop_invariant(__CPROVER_POINTER_OFFSET(input) == 0) + __CPROVER_loop_invariant(__CPROVER_w_ok(output, size)) + __CPROVER_loop_invariant(__CPROVER_POINTER_OFFSET(output) == 0) + // clang-format on + { + output[i] = input[i]; + } +} diff --git a/regression/cprover/large_step/loops/copy1.desc b/regression/cprover/large_step/loops/copy1.desc new file mode 100644 index 00000000000..c8902de8fb1 --- /dev/null +++ b/regression/cprover/large_step/loops/copy1.desc @@ -0,0 +1,14 @@ +CORE +copy1.c +--safety +^EXIT=0$ +^SIGNAL=0$ +^\[main\.invariant\.1\] line \d+ loop invariant: SUCCESS$ +^\[main\.invariant\.2\] line \d+ loop invariant: SUCCESS$ +^\[main\.invariant\.3\] line \d+ loop invariant: SUCCESS$ +^\[main\.invariant\.4\] line \d+ loop invariant: SUCCESS$ +^\[main\.invariant\.5\] line \d+ loop invariant: SUCCESS$ +^\[main\.pointer\.1\] line \d+ pointer output \+ .*i safe: SUCCESS$ +^\[main\.pointer\.2\] line \d+ pointer input \+ .*i safe: SUCCESS$ +-- +-- diff --git a/regression/cprover/large_step/loops/count_up1.c b/regression/cprover/large_step/loops/count_up1.c new file mode 100644 index 00000000000..1911fa1701e --- /dev/null +++ b/regression/cprover/large_step/loops/count_up1.c @@ -0,0 +1,18 @@ +_Bool nondet_bool(); + +int main() +{ + int i, j; + + i = j; + + while(nondet_bool()) + { + i++; + j++; + } + + __CPROVER_assert(i == j, "property 1"); // passes + + return 0; +} diff --git a/regression/cprover/large_step/loops/count_up1.desc b/regression/cprover/large_step/loops/count_up1.desc new file mode 100644 index 00000000000..6fc992c6cbd --- /dev/null +++ b/regression/cprover/large_step/loops/count_up1.desc @@ -0,0 +1,8 @@ +CORE +count_up1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- +-- diff --git a/regression/cprover/large_step/loops/count_up2.c b/regression/cprover/large_step/loops/count_up2.c new file mode 100644 index 00000000000..013c86c19dc --- /dev/null +++ b/regression/cprover/large_step/loops/count_up2.c @@ -0,0 +1,16 @@ +_Bool nondet_bool(); + +int main() +{ + int i, j; + + while(nondet_bool()) + { + i++; + j++; + } + + __CPROVER_assert(i == j, "property 1"); // fails + + return 0; +} diff --git a/regression/cprover/large_step/loops/count_up2.desc b/regression/cprover/large_step/loops/count_up2.desc new file mode 100644 index 00000000000..e00072ac85d --- /dev/null +++ b/regression/cprover/large_step/loops/count_up2.desc @@ -0,0 +1,8 @@ +CORE +count_up2.c + +^EXIT=10$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: REFUTED$ +-- +-- diff --git a/regression/cprover/large_step/loops/count_up3.c b/regression/cprover/large_step/loops/count_up3.c new file mode 100644 index 00000000000..cba62d52c1a --- /dev/null +++ b/regression/cprover/large_step/loops/count_up3.c @@ -0,0 +1,21 @@ +_Bool nondet_bool(); + +int main() +{ + unsigned int i, size; + + __CPROVER_assume(size % 2 == 0); + __CPROVER_assume(size < (0u - 2)); + + for(i = 0; i < size; i += 2) + // clang-format off + __CPROVER_loop_invariant( + i >= 0 && i <= size && i % 2 == 0 && size < (0u - 2) && size % 2 == 0) + { + } + // clang-format on + + __CPROVER_assert(i == size, "property 1"); // passes + + return 0; +} diff --git a/regression/cprover/large_step/loops/count_up3.desc b/regression/cprover/large_step/loops/count_up3.desc new file mode 100644 index 00000000000..1e48bf2f89e --- /dev/null +++ b/regression/cprover/large_step/loops/count_up3.desc @@ -0,0 +1,9 @@ +CORE +count_up3.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.invariant\.1\] line \d+ loop invariant: SUCCESS$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- +-- diff --git a/regression/cprover/large_step/loops/count_up4.c b/regression/cprover/large_step/loops/count_up4.c new file mode 100644 index 00000000000..0ae272678fb --- /dev/null +++ b/regression/cprover/large_step/loops/count_up4.c @@ -0,0 +1,20 @@ +_Bool nondet_bool(); + +int main() +{ + unsigned int i, j, size; + + __CPROVER_assume(size % 2 == 0); + __CPROVER_assume(size < (0u - 2)); + + j = 0; + for(i = 0; i < size; i += 2, j++) + // clang-format off + __CPROVER_loop_invariant(i >= 0 && i <= size && size < (0u-2) && size % 2 == 0 && i == j * 2) + { + __CPROVER_assert(j < size / 2, "property 1"); + } + // clang-format on + + return 0; +} diff --git a/regression/cprover/large_step/loops/count_up4.desc b/regression/cprover/large_step/loops/count_up4.desc new file mode 100644 index 00000000000..fec4514e2f4 --- /dev/null +++ b/regression/cprover/large_step/loops/count_up4.desc @@ -0,0 +1,9 @@ +CORE +count_up4.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.invariant\.1\] line \d+ loop invariant: SUCCESS$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- +-- diff --git a/regression/cprover/large_step/loops/do_while1.c b/regression/cprover/large_step/loops/do_while1.c new file mode 100644 index 00000000000..72dce5eb63f --- /dev/null +++ b/regression/cprover/large_step/loops/do_while1.c @@ -0,0 +1,15 @@ +int x; + +int main() +{ + x = 10; + + do + { + x = 20; + } while(x != 20); + + __CPROVER_assert(x == 20, "property 1"); // passes + + return 0; +} diff --git a/regression/cprover/large_step/loops/do_while1.desc b/regression/cprover/large_step/loops/do_while1.desc new file mode 100644 index 00000000000..a9c0d5d99e8 --- /dev/null +++ b/regression/cprover/large_step/loops/do_while1.desc @@ -0,0 +1,14 @@ +CORE +do_while1.c +--text --solve --inline +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S10\(ς\) ⇒ S11\(ς\[❝x❞:=10\]\)$ +^\(\d+\) ∀ ς : state \. S13T\(ς\) ⇒ S12in\(ς\)$ +^\(\d+\) ∀ ς : state \. S11\(ς\) ⇒ S12in\(ς\)$ +^\(\d+\) ∀ ς : state \. S12in\(ς\) ⇒ S12\(ς\[❝x❞:=20\]\)$ +^\(\d+\) ∀ ς : state . \(S12\(ς\) ∧ ς\(❝x❞\) ≠ 20\) ⇒ S13T\(ς\)$ +^\(\d+\) ∀ ς : state . \(S12\(ς\) ∧ ¬\(ς\(❝x❞\) ≠ 20\)\) ⇒ S13\(ς\)$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- +-- diff --git a/regression/cprover/large_step/loops/do_while_false.c b/regression/cprover/large_step/loops/do_while_false.c new file mode 100644 index 00000000000..9fa7643d459 --- /dev/null +++ b/regression/cprover/large_step/loops/do_while_false.c @@ -0,0 +1,13 @@ +int x; + +int main() +{ + do + { + x = 123; + } while(0); + + __CPROVER_assert(x == 123, "property 1"); // passes + + return 0; +} diff --git a/regression/cprover/large_step/loops/do_while_false.desc b/regression/cprover/large_step/loops/do_while_false.desc new file mode 100644 index 00000000000..52f0db837c9 --- /dev/null +++ b/regression/cprover/large_step/loops/do_while_false.desc @@ -0,0 +1,8 @@ +CORE +do_while_false.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- +-- diff --git a/regression/cprover/large_step/loops/failure1.c b/regression/cprover/large_step/loops/failure1.c new file mode 100644 index 00000000000..1baaa64996b --- /dev/null +++ b/regression/cprover/large_step/loops/failure1.c @@ -0,0 +1,12 @@ +int x; + +int main() +{ + for(x = 0; x != 1000; x++) + { + // deep failure + __CPROVER_assert(x != 100000, "failing assertion"); + } + + return 0; +} diff --git a/regression/cprover/large_step/loops/failure1.desc b/regression/cprover/large_step/loops/failure1.desc new file mode 100644 index 00000000000..fc6648680d9 --- /dev/null +++ b/regression/cprover/large_step/loops/failure1.desc @@ -0,0 +1,8 @@ +CORE +failure1.c + +^EXIT=6$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ failing assertion: DROPPED$ +-- +-- diff --git a/regression/cprover/large_step/loops/for1.c b/regression/cprover/large_step/loops/for1.c new file mode 100644 index 00000000000..0cd4b494a3e --- /dev/null +++ b/regression/cprover/large_step/loops/for1.c @@ -0,0 +1,11 @@ +int main() +{ + int i; + + for(i = 0; i < 10; i++) + ; + + __CPROVER_assert(i == 10, "property 1"); // passes + + return 0; +} diff --git a/regression/cprover/large_step/loops/for1.desc b/regression/cprover/large_step/loops/for1.desc new file mode 100644 index 00000000000..4fbec274ddd --- /dev/null +++ b/regression/cprover/large_step/loops/for1.desc @@ -0,0 +1,16 @@ +CORE +for1.c +--text --solve --inline +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S15\(ς\) ⇒ S12in\(ς\)$ +^\(\d+\) ∀ ς : state \. S11\(ς\) ⇒ S12in\(ς\)$ +^\(\d+\) ∀ ς : state \. \(S12in\(ς\) ∧ ¬\(ς\(❝main::1::i❞\) < 10\)\) ⇒ S12T\(ς\)$ +^\(\d+\) ∀ ς : state \. \(S12in\(ς\) ∧ ς\(❝main::1::i❞\) < 10\) ⇒ S12\(ς\)$ +^\(\d+\) S13 = S12$ +^\(\d+\) ∀ ς : state \. S13\(ς\) ⇒ S14\(ς\[❝main::1::i❞:=ς\(❝main::1::i❞\) \+ 1\]\)$ +^\(\d+\) S15 = S14$ +^\(\d+\) S16 = S12T$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- +-- diff --git a/regression/cprover/large_step/loops/for2.c b/regression/cprover/large_step/loops/for2.c new file mode 100644 index 00000000000..3a78abfd0aa --- /dev/null +++ b/regression/cprover/large_step/loops/for2.c @@ -0,0 +1,10 @@ +int main() +{ + for(int x = 0; x != 10; x++) + { + } + + __CPROVER_assert(0, "property 1"); // should fail + + return 0; +} diff --git a/regression/cprover/large_step/loops/for2.desc b/regression/cprover/large_step/loops/for2.desc new file mode 100644 index 00000000000..8414e0762a2 --- /dev/null +++ b/regression/cprover/large_step/loops/for2.desc @@ -0,0 +1,14 @@ +KNOWNBUG +for2.c +--text --solve --unwind 10 --inline +^EXIT=10$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S15\(ς\) ⇒ S12in\(ς\)$ +^\(\d+\) ∀ ς : state \. S11\(ς\) ⇒ S12in\(ς\)$ +^\(\d+\) ∀ ς : state \. \(S12in\(ς\) ∧ ¬\(ς\(❝main::1::1::x❞\) ≠ 10\)\) ⇒ S12T\(ς\)$ +^\(\d+\) ∀ ς : state \. \(S12in\(ς\) ∧ ς\(❝main::1::1::x❞\) ≠ 10\) ⇒ S12\(ς\)$ +^\(\d+\) S13 = S12$ +^\(\d+\) ∀ ς : state \. S13\(ς\) ⇒ S14\(ς\[❝main::1::1::x❞:=ς\(❝main::1::1::x❞\) \+ 1\]\)$ +^\[main\.assertion\.1\] line \d+ property 1: REFUTED$ +-- +-- diff --git a/regression/cprover/large_step/loops/for_loop1.c b/regression/cprover/large_step/loops/for_loop1.c new file mode 100644 index 00000000000..a83b0e31d83 --- /dev/null +++ b/regression/cprover/large_step/loops/for_loop1.c @@ -0,0 +1,14 @@ +int x; + +int main() +{ + for(x = 0; x < 100; x++) + { + int z = 123; + __CPROVER_assert( + z >= 0, "property 1"); // true independently of loop entry state + __CPROVER_assert(0, "property 2"); // fails + } + + return 0; +} diff --git a/regression/cprover/large_step/loops/for_loop1.desc b/regression/cprover/large_step/loops/for_loop1.desc new file mode 100644 index 00000000000..8c15e5606d9 --- /dev/null +++ b/regression/cprover/large_step/loops/for_loop1.desc @@ -0,0 +1,8 @@ +CORE +for_loop1.c + +^EXIT=10$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: REFUTED$ +-- diff --git a/regression/cprover/large_step/loops/for_loop2.c b/regression/cprover/large_step/loops/for_loop2.c new file mode 100644 index 00000000000..26e60eb247d --- /dev/null +++ b/regression/cprover/large_step/loops/for_loop2.c @@ -0,0 +1,16 @@ +int x; + +int main() +{ + for(x = 0; x < 100; x++) + { + __CPROVER_assert(0, "property 1"); // fails + } + + int z = 123; + + // true independently of loop exit state + __CPROVER_assert(z >= 0, "property 2"); + + return 0; +} diff --git a/regression/cprover/large_step/loops/for_loop2.desc b/regression/cprover/large_step/loops/for_loop2.desc new file mode 100644 index 00000000000..27e9ed5d836 --- /dev/null +++ b/regression/cprover/large_step/loops/for_loop2.desc @@ -0,0 +1,8 @@ +CORE +for_loop2.c + +^EXIT=10$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: REFUTED$ +^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$ +-- diff --git a/regression/cprover/large_step/loops/for_loop3.c b/regression/cprover/large_step/loops/for_loop3.c new file mode 100644 index 00000000000..8d2ed0c4fae --- /dev/null +++ b/regression/cprover/large_step/loops/for_loop3.c @@ -0,0 +1,14 @@ +int x; + +int main() +{ + for(x = 0; x < 100; x++) + { + __CPROVER_assert(0, "property 1"); // fails + } + + // implied by loop condition + __CPROVER_assert(x >= 100, "property 2"); + + return 0; +} diff --git a/regression/cprover/large_step/loops/for_loop3.desc b/regression/cprover/large_step/loops/for_loop3.desc new file mode 100644 index 00000000000..625059f4e91 --- /dev/null +++ b/regression/cprover/large_step/loops/for_loop3.desc @@ -0,0 +1,8 @@ +CORE +for_loop3.c + +^EXIT=10$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: REFUTED$ +^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$ +-- diff --git a/regression/cprover/large_step/loops/forward1.c b/regression/cprover/large_step/loops/forward1.c new file mode 100644 index 00000000000..b0542688657 --- /dev/null +++ b/regression/cprover/large_step/loops/forward1.c @@ -0,0 +1,12 @@ +int main() +{ + int x = 123; + int y = 0; + + while(1) + { + // forward-propagating x==123 and y==0 suffices + __CPROVER_assert(x != 0, "property 1"); + x += y; + } +} diff --git a/regression/cprover/large_step/loops/forward1.desc b/regression/cprover/large_step/loops/forward1.desc new file mode 100644 index 00000000000..d260a6ac5ea --- /dev/null +++ b/regression/cprover/large_step/loops/forward1.desc @@ -0,0 +1,7 @@ +KNOWNBUG +forward1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/loops/given_invariant1.c b/regression/cprover/large_step/loops/given_invariant1.c new file mode 100644 index 00000000000..be05cd35806 --- /dev/null +++ b/regression/cprover/large_step/loops/given_invariant1.c @@ -0,0 +1,14 @@ +int x; + +int main() +{ + for(x = 0; x != 100; x++) + // clang-format off + __CPROVER_loop_invariant(x>=0 && x<=100) + { + __CPROVER_assert(x != 1000, "non-inductive invariant"); + } + // clang-format on + + return 0; +} diff --git a/regression/cprover/large_step/loops/given_invariant1.desc b/regression/cprover/large_step/loops/given_invariant1.desc new file mode 100644 index 00000000000..d7bc6c1bab4 --- /dev/null +++ b/regression/cprover/large_step/loops/given_invariant1.desc @@ -0,0 +1,9 @@ +CORE +given_invariant1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.invariant\.1\] line \d+ loop invariant: SUCCESS$ +^\[main\.assertion\.1\] line \d+ non-inductive invariant: SUCCESS$ +-- +-- diff --git a/regression/cprover/large_step/loops/given_invariant2.c b/regression/cprover/large_step/loops/given_invariant2.c new file mode 100644 index 00000000000..86dab3ccded --- /dev/null +++ b/regression/cprover/large_step/loops/given_invariant2.c @@ -0,0 +1,14 @@ +int x; + +int main() +{ + for(x = 0; x != 100; x++) + // clang-format off + __CPROVER_loop_invariant(x>=0 && x<=10) // this is wrong + { + __CPROVER_assert(x != 1000, "non-inductive invariant"); + } + // clang-format on + + return 0; +} diff --git a/regression/cprover/large_step/loops/given_invariant2.desc b/regression/cprover/large_step/loops/given_invariant2.desc new file mode 100644 index 00000000000..3b6b5e02c82 --- /dev/null +++ b/regression/cprover/large_step/loops/given_invariant2.desc @@ -0,0 +1,9 @@ +CORE +given_invariant2.c + +^EXIT=6$ +^SIGNAL=0$ +^\[main\.invariant\.1\] line \d+ loop invariant: DROPPED$ +^\[main\.assertion\.1\] line \d+ non-inductive invariant: DROPPED$ +-- +-- diff --git a/regression/cprover/large_step/loops/given_invariant3.c b/regression/cprover/large_step/loops/given_invariant3.c new file mode 100644 index 00000000000..ab8ec890e57 --- /dev/null +++ b/regression/cprover/large_step/loops/given_invariant3.c @@ -0,0 +1,16 @@ +int x; + +int main() +{ + for(x = 0; x < 100; x++) + // clang-format off + __CPROVER_loop_invariant(x>=0 && x<=100) // should pass + { + // whatnot + } + // clang-format on + + __CPROVER_assert(x == 100, "non-inductive property"); // should pass + + return 0; +} diff --git a/regression/cprover/large_step/loops/given_invariant3.desc b/regression/cprover/large_step/loops/given_invariant3.desc new file mode 100644 index 00000000000..ed66401ae9f --- /dev/null +++ b/regression/cprover/large_step/loops/given_invariant3.desc @@ -0,0 +1,9 @@ +CORE +given_invariant3.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.invariant\.1\] line \d+ loop invariant: SUCCESS$ +^\[main\.assertion\.1\] line \d+ non-inductive property: SUCCESS$ +-- +-- diff --git a/regression/cprover/large_step/loops/given_invariant4.c b/regression/cprover/large_step/loops/given_invariant4.c new file mode 100644 index 00000000000..0ad8e73cde2 --- /dev/null +++ b/regression/cprover/large_step/loops/given_invariant4.c @@ -0,0 +1,16 @@ +int main() +{ + int i; + + __CPROVER_assume(i >= 0); + + while(i != 10000) + // clang-format off + __CPROVER_loop_invariant(i>=0) // should pass + { + __CPROVER_assert(i >= 0, "property 1"); // should pass + } + // clang-format on + + return 0; +} diff --git a/regression/cprover/large_step/loops/given_invariant4.desc b/regression/cprover/large_step/loops/given_invariant4.desc new file mode 100644 index 00000000000..615a9caf612 --- /dev/null +++ b/regression/cprover/large_step/loops/given_invariant4.desc @@ -0,0 +1,9 @@ +CORE +given_invariant4.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.invariant\.1\] line \d+ loop invariant: SUCCESS$ +-- +-- diff --git a/regression/cprover/large_step/loops/given_invariant5.c b/regression/cprover/large_step/loops/given_invariant5.c new file mode 100644 index 00000000000..dec1c85a138 --- /dev/null +++ b/regression/cprover/large_step/loops/given_invariant5.c @@ -0,0 +1,16 @@ +int x; + +int main() +{ + x = -1; + + for(; x != 100; x++) + // clang-format off + __CPROVER_loop_invariant(x>=0 && x<=100) // fails base case + { + __CPROVER_assert(x < 100, "non-inductive invariant"); + } + // clang-format on + + return 0; +} diff --git a/regression/cprover/large_step/loops/given_invariant5.desc b/regression/cprover/large_step/loops/given_invariant5.desc new file mode 100644 index 00000000000..a8fbb9b4f1b --- /dev/null +++ b/regression/cprover/large_step/loops/given_invariant5.desc @@ -0,0 +1,9 @@ +CORE +given_invariant5.c + +^EXIT=10$ +^SIGNAL=0$ +^\[main\.invariant\.1\] line \d+ loop invariant: REFUTED$ +^\[main\.assertion\.1\] line \d+ non-inductive invariant: SUCCESS$ +-- +-- diff --git a/regression/cprover/large_step/loops/given_invariant6.c b/regression/cprover/large_step/loops/given_invariant6.c new file mode 100644 index 00000000000..fc9d0c34317 --- /dev/null +++ b/regression/cprover/large_step/loops/given_invariant6.c @@ -0,0 +1,12 @@ +int main() +{ + for(int x = 0; x != 100; x++) + // clang-format off + __CPROVER_loop_invariant(0) // fails base case + { + __CPROVER_assert(0, "property 1"); + } + // clang-format on + + return 0; +} diff --git a/regression/cprover/large_step/loops/given_invariant6.desc b/regression/cprover/large_step/loops/given_invariant6.desc new file mode 100644 index 00000000000..cc52774241e --- /dev/null +++ b/regression/cprover/large_step/loops/given_invariant6.desc @@ -0,0 +1,9 @@ +CORE +given_invariant6.c + +^EXIT=10$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: REFUTED$ +^\[main\.invariant\.1\] line \d+ loop invariant: REFUTED$ +-- +-- diff --git a/regression/cprover/large_step/loops/given_invariant7.c b/regression/cprover/large_step/loops/given_invariant7.c new file mode 100644 index 00000000000..dbe3ef84b1b --- /dev/null +++ b/regression/cprover/large_step/loops/given_invariant7.c @@ -0,0 +1,16 @@ +#define N 100 + +int main() +{ + int array[N]; + + for(int i = 0; i != N; i++) + // clang-format off + __CPROVER_loop_invariant(i >= 0 && i <= N) // passes + { + array[i] = 0; // safe and passes + } + // clang-format on + + return 0; +} diff --git a/regression/cprover/large_step/loops/given_invariant7.desc b/regression/cprover/large_step/loops/given_invariant7.desc new file mode 100644 index 00000000000..b9c816c1cfc --- /dev/null +++ b/regression/cprover/large_step/loops/given_invariant7.desc @@ -0,0 +1,9 @@ +CORE +given_invariant7.c +--safety +^EXIT=0$ +^SIGNAL=0$ +^\[main\.invariant\.1\] line \d+ loop invariant: SUCCESS$ +^\[main\.array_bounds\.1\] line \d+ array bounds in array\[.*i\]: SUCCESS$ +-- +-- diff --git a/regression/cprover/large_step/loops/given_invariant8.c b/regression/cprover/large_step/loops/given_invariant8.c new file mode 100644 index 00000000000..fbdee28134f --- /dev/null +++ b/regression/cprover/large_step/loops/given_invariant8.c @@ -0,0 +1,17 @@ +int main() +{ + char n; + __CPROVER_assume(n >= 0); + int array[n]; + + for(int i = 0; i != n; i++) + // clang-format off + __CPROVER_loop_invariant( + i >= 0 && i <= n && sizeof(array) == sizeof(int) * n) // passes + { + array[i] = 0; // safe and passes + } + // clang-format on + + return 0; +} diff --git a/regression/cprover/large_step/loops/given_invariant8.desc b/regression/cprover/large_step/loops/given_invariant8.desc new file mode 100644 index 00000000000..fd06d220c47 --- /dev/null +++ b/regression/cprover/large_step/loops/given_invariant8.desc @@ -0,0 +1,9 @@ +CORE +given_invariant8.c +--safety +^EXIT=0$ +^SIGNAL=0$ +^\[main\.invariant\.1\] line \d+ loop invariant: SUCCESS$ +^\[main\.array_bounds\.1\] line \d+ array bounds in array\[.*i\]: SUCCESS$ +-- +-- diff --git a/regression/cprover/large_step/loops/given_invariant9.c b/regression/cprover/large_step/loops/given_invariant9.c new file mode 100644 index 00000000000..1b386ddc60d --- /dev/null +++ b/regression/cprover/large_step/loops/given_invariant9.c @@ -0,0 +1,19 @@ +void *malloc(__CPROVER_size_t); + +int main() +{ + char n; + __CPROVER_assume(n >= 0); + int *array = malloc(sizeof(int) * n); + + for(int i = 0; i != n; i++) + // clang-format off + __CPROVER_loop_invariant(i >= 0 && i <= n) + __CPROVER_loop_invariant(__CPROVER_r_ok(array, sizeof(int) * n)) + { + array[i] = 0; // safe and passes + } + // clang-format on + + return 0; +} diff --git a/regression/cprover/large_step/loops/given_invariant9.desc b/regression/cprover/large_step/loops/given_invariant9.desc new file mode 100644 index 00000000000..b132b12320c --- /dev/null +++ b/regression/cprover/large_step/loops/given_invariant9.desc @@ -0,0 +1,10 @@ +CORE +given_invariant9.c +--safety +^EXIT=0$ +^SIGNAL=0$ +^\[main\.invariant\.1\] line \d+ loop invariant: SUCCESS$ +^\[main\.invariant\.2\] line \d+ loop invariant: SUCCESS$ +^\[main\.pointer\.1\] line \d+ pointer .* safe: SUCCESS$ +-- +-- diff --git a/regression/cprover/large_step/loops/nondet_loop1.c b/regression/cprover/large_step/loops/nondet_loop1.c new file mode 100644 index 00000000000..43ec63ff9d5 --- /dev/null +++ b/regression/cprover/large_step/loops/nondet_loop1.c @@ -0,0 +1,12 @@ +int nondet_int(); + +int main() +{ + int i; + int array[2]; + + for(i = 0; i < 2; i++) + array[i] = nondet_int(); + + __CPROVER_assert(array[0] == array[1], "property 1"); // fails +} diff --git a/regression/cprover/large_step/loops/nondet_loop1.desc b/regression/cprover/large_step/loops/nondet_loop1.desc new file mode 100644 index 00000000000..01bedb6f69b --- /dev/null +++ b/regression/cprover/large_step/loops/nondet_loop1.desc @@ -0,0 +1,7 @@ +KNOWNBUG +nondet_loop1.c + +^EXIT=10$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 2: REFUTED$ +-- diff --git a/regression/cprover/large_step/loops/while-break1.c b/regression/cprover/large_step/loops/while-break1.c new file mode 100644 index 00000000000..0bee5fd80d3 --- /dev/null +++ b/regression/cprover/large_step/loops/while-break1.c @@ -0,0 +1,12 @@ +int main() +{ + int x = 0; + while(1) + { + if(x == 0) + break; + else + break; + } + __CPROVER_assert(x == 0, "property 1"); +} diff --git a/regression/cprover/large_step/loops/while-break1.desc b/regression/cprover/large_step/loops/while-break1.desc new file mode 100644 index 00000000000..fb089d04d42 --- /dev/null +++ b/regression/cprover/large_step/loops/while-break1.desc @@ -0,0 +1,17 @@ +CORE +while-break1.c +--text --solve --inline +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S15T\(ς\) ⇒ S12in\(ς\)$ +^\(\d+\) ∀ ς : state \. S11\(ς\) ⇒ S12in\(ς\)$ +^\(\d+\) ∀ ς : state \. \(S12in\(ς\) ∧ ¬\(1 ≠ 0\)\) ⇒ S12T\(ς\)$ +^\(\d+\) ∀ ς : state \. \(S12in\(ς\) ∧ 1 ≠ 0\) ⇒ S12\(ς\)$ +^\(\d+\) ∀ ς : state \. \(S12\(ς\) ∧ ς\(❝main::1::x❞\) = 0\) ⇒ S13T\(ς\)$ +^\(\d+\) ∀ ς : state \. \(S12\(ς\) ∧ ¬\(ς\(❝main::1::x❞\) = 0\)\) ⇒ S13\(ς\)$ +^\(\d+\) ∀ ς : state \. S12T\(ς\) ⇒ S17in\(ς\)$ +^\(\d+\) ∀ ς : state \. S13T\(ς\) ⇒ S17in\(ς\)$ +^\(\d+\) ∀ ς : state \. S16\(ς\) ⇒ S17in\(ς\)$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- +-- diff --git a/regression/cprover/large_step/loops/while-true1.c b/regression/cprover/large_step/loops/while-true1.c new file mode 100644 index 00000000000..9e89c2392f6 --- /dev/null +++ b/regression/cprover/large_step/loops/while-true1.c @@ -0,0 +1,8 @@ +int main() +{ + while(1) + { + } + + __CPROVER_assert(0, "property 1"); +} diff --git a/regression/cprover/large_step/loops/while-true1.desc b/regression/cprover/large_step/loops/while-true1.desc new file mode 100644 index 00000000000..407fe011c8c --- /dev/null +++ b/regression/cprover/large_step/loops/while-true1.desc @@ -0,0 +1,8 @@ +CORE +while-true1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- +-- diff --git a/regression/cprover/large_step/loops/while_loop1.c b/regression/cprover/large_step/loops/while_loop1.c new file mode 100644 index 00000000000..37f9f314918 --- /dev/null +++ b/regression/cprover/large_step/loops/while_loop1.c @@ -0,0 +1,17 @@ +int x; + +int main() +{ + x = 0; + + while(x < 100) + { + int z = 123; + __CPROVER_assert( + z >= 0, "property 1"); // true independently of loop entry state + __CPROVER_assert(0, "property 2"); // fails + x++; + } + + return 0; +} diff --git a/regression/cprover/large_step/loops/while_loop1.desc b/regression/cprover/large_step/loops/while_loop1.desc new file mode 100644 index 00000000000..e39f075f692 --- /dev/null +++ b/regression/cprover/large_step/loops/while_loop1.desc @@ -0,0 +1,8 @@ +CORE +while_loop1.c + +^EXIT=10$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: REFUTED$ +-- diff --git a/regression/cprover/large_step/loops/while_loop2.c b/regression/cprover/large_step/loops/while_loop2.c new file mode 100644 index 00000000000..9414b8696e6 --- /dev/null +++ b/regression/cprover/large_step/loops/while_loop2.c @@ -0,0 +1,11 @@ +int nondet_int(); + +int main() +{ + int N = nondet_int(); + int x = 0; + while(x < N) + x++; + + __CPROVER_assert(x == N, "property 1"); // fails +} diff --git a/regression/cprover/large_step/loops/while_loop2.desc b/regression/cprover/large_step/loops/while_loop2.desc new file mode 100644 index 00000000000..bec032f14db --- /dev/null +++ b/regression/cprover/large_step/loops/while_loop2.desc @@ -0,0 +1,7 @@ +CORE +while_loop2.c + +^EXIT=10$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: REFUTED$ +-- diff --git a/regression/cprover/large_step/pointers/aliasing1.c b/regression/cprover/large_step/pointers/aliasing1.c new file mode 100644 index 00000000000..784883d28c1 --- /dev/null +++ b/regression/cprover/large_step/pointers/aliasing1.c @@ -0,0 +1,12 @@ +int main(void) +{ + int *p; + __CPROVER_assume(__CPROVER_rw_ok(p)); + + int i; + __CPROVER_assert(__CPROVER_rw_ok(p), "property 1"); // should pass + + p = &i; // take address of i + + return 0; +} diff --git a/regression/cprover/large_step/pointers/aliasing1.desc b/regression/cprover/large_step/pointers/aliasing1.desc new file mode 100644 index 00000000000..212796a26ba --- /dev/null +++ b/regression/cprover/large_step/pointers/aliasing1.desc @@ -0,0 +1,7 @@ +CORE +aliasing1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/aliasing2.c b/regression/cprover/large_step/pointers/aliasing2.c new file mode 100644 index 00000000000..a0f9636d388 --- /dev/null +++ b/regression/cprover/large_step/pointers/aliasing2.c @@ -0,0 +1,12 @@ +int main() +{ + int *in, *out; + __CPROVER_assume(__CPROVER_rw_ok(in) && __CPROVER_rw_ok(out)); + __CPROVER_assume(!__CPROVER_same_object(in, out)); + int old_in = *in; + + *out = *in; + *in = 0; // overwrite + + __CPROVER_assert(*out == old_in, "property 1"); +} diff --git a/regression/cprover/large_step/pointers/aliasing2.desc b/regression/cprover/large_step/pointers/aliasing2.desc new file mode 100644 index 00000000000..f70c642850b --- /dev/null +++ b/regression/cprover/large_step/pointers/aliasing2.desc @@ -0,0 +1,7 @@ +CORE +aliasing2.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/char_pointers1.c b/regression/cprover/large_step/pointers/char_pointers1.c new file mode 100644 index 00000000000..bca51e72289 --- /dev/null +++ b/regression/cprover/large_step/pointers/char_pointers1.c @@ -0,0 +1,10 @@ +int main() +{ + int x; + char *p = (char *)&x; + p[0] = 0; + p[1] = 0; + p[2] = 0; + p[3] = 0; + __CPROVER_assert(x == 0, "property 1"); +} diff --git a/regression/cprover/large_step/pointers/char_pointers1.desc b/regression/cprover/large_step/pointers/char_pointers1.desc new file mode 100644 index 00000000000..d41af4f1c84 --- /dev/null +++ b/regression/cprover/large_step/pointers/char_pointers1.desc @@ -0,0 +1,7 @@ +KNOWNBUG +char_pointers1.c +--text --solve +^EXIT=0$ +^SIGNAL=0$ +^program is safe / function main is safe / line .* property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/char_pointers2.c b/regression/cprover/large_step/pointers/char_pointers2.c new file mode 100644 index 00000000000..6f4bcad1539 --- /dev/null +++ b/regression/cprover/large_step/pointers/char_pointers2.c @@ -0,0 +1,12 @@ +int main() +{ + int x = 0x01020304; + char *p = (char *)&x; + + // passes on little endinan + __CPROVER_assert(p[0] == 0x04, "property 1"); + __CPROVER_assert(p[1] == 0x03, "property 2"); + __CPROVER_assert(p[2] == 0x02, "property 3"); + __CPROVER_assert(p[3] == 0x01, "property 4"); + return 0; +} diff --git a/regression/cprover/large_step/pointers/char_pointers2.desc b/regression/cprover/large_step/pointers/char_pointers2.desc new file mode 100644 index 00000000000..155a35cc6c1 --- /dev/null +++ b/regression/cprover/large_step/pointers/char_pointers2.desc @@ -0,0 +1,20 @@ +KNOWNBUG +char_pointers2.c +--text --solve +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S20\(ς\) ⇒ S21\(ς\[❝main::1::x❞:=16909060\]\)$ +^\(\d+\) S22 = S21$ +^\(\d+\) ∀ ς : state \. S22\(ς\) ⇒ S23\(ς\[❝main::1::p❞:=cast\(❝main::1::x❞, signedbv\[8\]\*\)\]\) +^\(\d+\) ∀ ς : state \. S23\(ς\) ⇒ \(cast\(ς\(ς\(❝main::1::p❞\) \+ cast\(0, signedbv\[64\]\)\), signedbv\[32\]\) = 4\)$ +^\(\d+\) S24 = S23$ +^\(\d+\) ∀ ς : state \. S24\(ς\) ⇒ \(cast\(ς\(ς\(❝main::1::p❞\) \+ cast\(1, signedbv\[64\]\)\), signedbv\[32\]\) = 3\)$ +^\(\d+\) S25 = S24$ +^\(\d+\) ∀ ς : state \. S25\(ς\) ⇒ \(cast\(ς\(ς\(❝main::1::p❞\) \+ cast\(2, signedbv\[64\]\)\), signedbv\[32\]\) = 2\)$ +^\(\d+\) S26 = S25$ +^\(\d+\) ∀ ς : state \. S26\(ς\) ⇒ \(cast\(ς\(ς\(❝main::1::p❞\) \+ cast\(3, signedbv\[64\]\)\), signedbv\[32\]\) = 1\)$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$ +^\[main\.assertion\.3\] line \d+ property 3: SUCCESS$ +^\[main\.assertion\.4\] line \d+ property 4: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/const1.c b/regression/cprover/large_step/pointers/const1.c new file mode 100644 index 00000000000..d4f7222e9cb --- /dev/null +++ b/regression/cprover/large_step/pointers/const1.c @@ -0,0 +1,9 @@ +const int months = 12; + +int main() +{ + char *p; + __CPROVER_assume(__CPROVER_w_ok(p, 1)); + *p = 123; // should not alias 'months', as we are writing + __CPROVER_assert(months == 12, "property 1"); +} diff --git a/regression/cprover/large_step/pointers/const1.desc b/regression/cprover/large_step/pointers/const1.desc new file mode 100644 index 00000000000..82f1e868d70 --- /dev/null +++ b/regression/cprover/large_step/pointers/const1.desc @@ -0,0 +1,7 @@ +CORE +const1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/const2.c b/regression/cprover/large_step/pointers/const2.c new file mode 100644 index 00000000000..28ad9094d98 --- /dev/null +++ b/regression/cprover/large_step/pointers/const2.c @@ -0,0 +1,8 @@ +const int months = 12; + +int main() +{ + char *p; + __CPROVER_assume(__CPROVER_WRITEABLE_OBJECT(p)); + __CPROVER_assert(!__CPROVER_same_object(p, &months), "property 1"); // passes +} diff --git a/regression/cprover/large_step/pointers/const2.desc b/regression/cprover/large_step/pointers/const2.desc new file mode 100644 index 00000000000..64826994747 --- /dev/null +++ b/regression/cprover/large_step/pointers/const2.desc @@ -0,0 +1,7 @@ +CORE +const2.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/disjoint1.c b/regression/cprover/large_step/pointers/disjoint1.c new file mode 100644 index 00000000000..23762074ccc --- /dev/null +++ b/regression/cprover/large_step/pointers/disjoint1.c @@ -0,0 +1,12 @@ +int unrelated = 123; + +int main() +{ + char *output; + + __CPROVER_assume(__CPROVER_w_ok(output)); + __CPROVER_assume(!__CPROVER_same_object(output, &unrelated)); + *output = 'x'; + + __CPROVER_assert(unrelated == 123, "property 1"); +} diff --git a/regression/cprover/large_step/pointers/disjoint1.desc b/regression/cprover/large_step/pointers/disjoint1.desc new file mode 100644 index 00000000000..72791ffa328 --- /dev/null +++ b/regression/cprover/large_step/pointers/disjoint1.desc @@ -0,0 +1,7 @@ +CORE +disjoint1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/hex_encode.c b/regression/cprover/large_step/pointers/hex_encode.c new file mode 100644 index 00000000000..83c62570796 --- /dev/null +++ b/regression/cprover/large_step/pointers/hex_encode.c @@ -0,0 +1,43 @@ +const char *HEX_CHARS = "0123456789abcdef"; + +int main() +{ + __CPROVER_size_t input_size; + unsigned char *input; + char *output; + + __CPROVER_assume(input_size < 100); + __CPROVER_assume(__CPROVER_r_ok(input, input_size)); + __CPROVER_assume(__CPROVER_POINTER_OFFSET(input) == 0); + __CPROVER_assume(__CPROVER_w_ok(output, input_size * 2)); + __CPROVER_assume(__CPROVER_POINTER_OFFSET(output) == 0); + + __CPROVER_assert(__CPROVER_r_ok(HEX_CHARS, 16), "property 1"); + __CPROVER_assert(__CPROVER_POINTER_OFFSET(HEX_CHARS) == 0, "property 2"); + + __CPROVER_assume(!__CPROVER_same_object(&HEX_CHARS, output)); + + __CPROVER_size_t written = 0; + for(__CPROVER_size_t i = 0; i < input_size; ++i) + // clang-format off + __CPROVER_loop_invariant(input_size < 100) + __CPROVER_loop_invariant(i >= 0 && i <= input_size) + __CPROVER_loop_invariant(__CPROVER_r_ok(input, input_size)) + __CPROVER_loop_invariant(__CPROVER_POINTER_OFFSET(input) == 0) + __CPROVER_loop_invariant(__CPROVER_r_ok(HEX_CHARS, 16)) + __CPROVER_loop_invariant(__CPROVER_POINTER_OFFSET(HEX_CHARS) == 0) + __CPROVER_loop_invariant(written == i * 2) + __CPROVER_loop_invariant(__CPROVER_w_ok(output, input_size * 2)) + __CPROVER_loop_invariant(__CPROVER_POINTER_OFFSET(output) == 0) + __CPROVER_loop_invariant(!__CPROVER_same_object(&HEX_CHARS, output)) + // clang-format on + { + unsigned char ch = input[i]; + char hex0 = HEX_CHARS[ch >> 4 & 0x0f]; + char hex1 = HEX_CHARS[ch & 0x0f]; + output[written++] = hex0; + output[written++] = hex1; + } + + return 0; +} diff --git a/regression/cprover/large_step/pointers/hex_encode.desc b/regression/cprover/large_step/pointers/hex_encode.desc new file mode 100644 index 00000000000..58dee5c5422 --- /dev/null +++ b/regression/cprover/large_step/pointers/hex_encode.desc @@ -0,0 +1,6 @@ +CORE +hex_encode.c +--safety +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/pointers/local1.c b/regression/cprover/large_step/pointers/local1.c new file mode 100644 index 00000000000..ce19f07d07a --- /dev/null +++ b/regression/cprover/large_step/pointers/local1.c @@ -0,0 +1,12 @@ +void myfunc(int *p) +{ + int x = 1; + *p = 2; // can't point to x + __CPROVER_assert(x == 1, "property 1"); +} + +int main() +{ + int *p; + myfunc(p); +} diff --git a/regression/cprover/large_step/pointers/local1.desc b/regression/cprover/large_step/pointers/local1.desc new file mode 100644 index 00000000000..bef9b60154c --- /dev/null +++ b/regression/cprover/large_step/pointers/local1.desc @@ -0,0 +1,7 @@ +CORE +malloc1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/malloc1.c b/regression/cprover/large_step/pointers/malloc1.c new file mode 100644 index 00000000000..d4ae4d03f61 --- /dev/null +++ b/regression/cprover/large_step/pointers/malloc1.c @@ -0,0 +1,11 @@ +void *malloc(__CPROVER_size_t); + +int *p; + +int main() +{ + p = malloc(sizeof(int) * 10); + p[2] = 123; + __CPROVER_assert(p[2] == 123, "property 1"); + return 0; +} diff --git a/regression/cprover/large_step/pointers/malloc1.desc b/regression/cprover/large_step/pointers/malloc1.desc new file mode 100644 index 00000000000..3b957873d6c --- /dev/null +++ b/regression/cprover/large_step/pointers/malloc1.desc @@ -0,0 +1,8 @@ +CORE +malloc1.c +--text --solve --inline +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S11\(ς\) ⇒ S12\(ς\[❝main::\$tmp::return_value_malloc❞:=allocate\(ς, 4 \* cast\(10, unsignedbv\[\d+\]\)\)\]\)$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/malloc2.c b/regression/cprover/large_step/pointers/malloc2.c new file mode 100644 index 00000000000..f75ecf28c39 --- /dev/null +++ b/regression/cprover/large_step/pointers/malloc2.c @@ -0,0 +1,12 @@ +void *malloc(__CPROVER_size_t); + +int *p; + +#define N (sizeof(int) * 10) + +int main() +{ + p = malloc(N); + __CPROVER_assert(__CPROVER_OBJECT_SIZE(p) == N, "property 1"); + return 0; +} diff --git a/regression/cprover/large_step/pointers/malloc2.desc b/regression/cprover/large_step/pointers/malloc2.desc new file mode 100644 index 00000000000..997b9889fd5 --- /dev/null +++ b/regression/cprover/large_step/pointers/malloc2.desc @@ -0,0 +1,7 @@ +CORE +malloc2.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/malloc3.c b/regression/cprover/large_step/pointers/malloc3.c new file mode 100644 index 00000000000..102bdbe9e23 --- /dev/null +++ b/regression/cprover/large_step/pointers/malloc3.c @@ -0,0 +1,9 @@ +void *malloc(__CPROVER_size_t); +void free(void *); + +int main() +{ + int *p = malloc(sizeof(int)); + int *q = malloc(sizeof(int)); + __CPROVER_assert(!__CPROVER_same_object(p, q), "property 1"); // should pass +} diff --git a/regression/cprover/large_step/pointers/malloc3.desc b/regression/cprover/large_step/pointers/malloc3.desc new file mode 100644 index 00000000000..4664edc4a3d --- /dev/null +++ b/regression/cprover/large_step/pointers/malloc3.desc @@ -0,0 +1,7 @@ +KNOWNBUG +malloc3.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/pointer_array1.c b/regression/cprover/large_step/pointers/pointer_array1.c new file mode 100644 index 00000000000..af0bc6f92df --- /dev/null +++ b/regression/cprover/large_step/pointers/pointer_array1.c @@ -0,0 +1,12 @@ +int some_int = 123; +void *ptr_array[10] = {&some_int}; + +int main() +{ + __CPROVER_assert(ptr_array[0] == &some_int, "property 1"); + + void **array_pointer = ptr_array; + + __CPROVER_assert(array_pointer[0] == &some_int, "property 2"); + __CPROVER_assert(*((int *)(array_pointer[0])) == 123, "property 3"); +} diff --git a/regression/cprover/large_step/pointers/pointer_array1.desc b/regression/cprover/large_step/pointers/pointer_array1.desc new file mode 100644 index 00000000000..78ec08c4c6e --- /dev/null +++ b/regression/cprover/large_step/pointers/pointer_array1.desc @@ -0,0 +1,9 @@ +CORE +pointer_array1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$ +^\[main\.assertion\.3\] line \d+ property 3: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/pointer_into_struct1.c b/regression/cprover/large_step/pointers/pointer_into_struct1.c new file mode 100644 index 00000000000..f8e997edb44 --- /dev/null +++ b/regression/cprover/large_step/pointers/pointer_into_struct1.c @@ -0,0 +1,12 @@ +struct my_struct +{ + int x, y; +} S = {1, 2}; + +int main() +{ + int *p = &S.y; + int my_struct_data = *p; + __CPROVER_assert(my_struct_data == 2, "property 1"); // should pass + return 0; +} diff --git a/regression/cprover/large_step/pointers/pointer_into_struct1.desc b/regression/cprover/large_step/pointers/pointer_into_struct1.desc new file mode 100644 index 00000000000..6636ca99e7a --- /dev/null +++ b/regression/cprover/large_step/pointers/pointer_into_struct1.desc @@ -0,0 +1,7 @@ +CORE +pointer_into_struct1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/pointer_logic1.c b/regression/cprover/large_step/pointers/pointer_logic1.c new file mode 100644 index 00000000000..df8a3cfa547 --- /dev/null +++ b/regression/cprover/large_step/pointers/pointer_logic1.c @@ -0,0 +1,14 @@ +int main() +{ + char *p; + __CPROVER_size_t offset; + + p = (char *)0 + offset; + + __CPROVER_assert( + __CPROVER_POINTER_OBJECT(p) == 0, "property 1"); // should pass + __CPROVER_assert( + __CPROVER_POINTER_OFFSET(p) == offset, "property 2"); // should pass + + return 0; +} diff --git a/regression/cprover/large_step/pointers/pointer_logic1.desc b/regression/cprover/large_step/pointers/pointer_logic1.desc new file mode 100644 index 00000000000..52e5efce3b3 --- /dev/null +++ b/regression/cprover/large_step/pointers/pointer_logic1.desc @@ -0,0 +1,8 @@ +CORE +pointer_logic1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/pointer_logic2.c b/regression/cprover/large_step/pointers/pointer_logic2.c new file mode 100644 index 00000000000..75153481217 --- /dev/null +++ b/regression/cprover/large_step/pointers/pointer_logic2.c @@ -0,0 +1,16 @@ +int main() +{ + int x; + char *p; + __CPROVER_size_t offset; + + p = ((char *)&x) + offset; + + __CPROVER_assert( + __CPROVER_POINTER_OBJECT(p) == __CPROVER_POINTER_OBJECT(&x), + "property 1"); // should pass + __CPROVER_assert( + __CPROVER_POINTER_OFFSET(p) == offset, "property 2"); // should pass + + return 0; +} diff --git a/regression/cprover/large_step/pointers/pointer_logic2.desc b/regression/cprover/large_step/pointers/pointer_logic2.desc new file mode 100644 index 00000000000..42e28455323 --- /dev/null +++ b/regression/cprover/large_step/pointers/pointer_logic2.desc @@ -0,0 +1,8 @@ +CORE +pointer_logic2.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/pointer_logic3.c b/regression/cprover/large_step/pointers/pointer_logic3.c new file mode 100644 index 00000000000..eed04791b48 --- /dev/null +++ b/regression/cprover/large_step/pointers/pointer_logic3.c @@ -0,0 +1,19 @@ +int main() +{ + char *base, *p; + __CPROVER_size_t size, offset; + + __CPROVER_assume(__CPROVER_r_ok(base, size)); + + if(offset < size) + { + p = base + offset; + + __CPROVER_assert( + __CPROVER_same_object(base, p), "property 1"); // should pass + __CPROVER_assert(base <= p, "property 2"); // should pass + __CPROVER_assert(p < base + size, "property 3"); // should pass + } + + return 0; +} diff --git a/regression/cprover/large_step/pointers/pointer_logic3.desc b/regression/cprover/large_step/pointers/pointer_logic3.desc new file mode 100644 index 00000000000..4730793ce71 --- /dev/null +++ b/regression/cprover/large_step/pointers/pointer_logic3.desc @@ -0,0 +1,9 @@ +CORE +pointer_logic3.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$ +^\[main\.assertion\.3\] line \d+ property 3: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/pointer_to_local1.c b/regression/cprover/large_step/pointers/pointer_to_local1.c new file mode 100644 index 00000000000..d59132f78dc --- /dev/null +++ b/regression/cprover/large_step/pointers/pointer_to_local1.c @@ -0,0 +1,8 @@ +void foo(int *p) __CPROVER_requires(__CPROVER_w_ok(p)) __CPROVER_assigns(*p) +{ + int i; + + i = 123; + *p = 456; // p cannot point to i as i is local + __CPROVER_assert(i == 123, "property 1"); // should pass +} diff --git a/regression/cprover/large_step/pointers/pointer_to_local1.desc b/regression/cprover/large_step/pointers/pointer_to_local1.desc new file mode 100644 index 00000000000..12c2dec529a --- /dev/null +++ b/regression/cprover/large_step/pointers/pointer_to_local1.desc @@ -0,0 +1,7 @@ +CORE +pointer_to_local1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[foo\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/pointer_to_pointer1.c b/regression/cprover/large_step/pointers/pointer_to_pointer1.c new file mode 100644 index 00000000000..1ee82851c3c --- /dev/null +++ b/regression/cprover/large_step/pointers/pointer_to_pointer1.c @@ -0,0 +1,12 @@ +#include + +int *p; +void **p_ptr; + +int main() +{ + p = malloc(1); + p_ptr = &p; + __CPROVER_assert(__CPROVER_LIVE_OBJECT(*p_ptr), "property 1"); + return 0; +} diff --git a/regression/cprover/large_step/pointers/pointer_to_pointer1.desc b/regression/cprover/large_step/pointers/pointer_to_pointer1.desc new file mode 100644 index 00000000000..ed67f31ef59 --- /dev/null +++ b/regression/cprover/large_step/pointers/pointer_to_pointer1.desc @@ -0,0 +1,7 @@ +CORE +pointer_to_pointer1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/pointers0.c b/regression/cprover/large_step/pointers/pointers0.c new file mode 100644 index 00000000000..421dcdc2a26 --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers0.c @@ -0,0 +1,7 @@ +int main() +{ + int x, *p; + p = &x; + __CPROVER_assert(*p == x, "property 1"); // should pass + return 0; +} diff --git a/regression/cprover/large_step/pointers/pointers0.desc b/regression/cprover/large_step/pointers/pointers0.desc new file mode 100644 index 00000000000..71485440798 --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers0.desc @@ -0,0 +1,9 @@ +CORE +pointers0.c +--text --solve --inline --no-safety +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S11\(ς\) ⇒ S12\(ς\[❝main::1::p❞:=❝main::1::x❞\]\)$ +^\(\d+\) ∀ ς : state \. S12\(ς\) ⇒ \(ς\(ς\(❝main::1::p❞\)\) = ς\(❝main::1::x❞\)\)$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/pointers1.c b/regression/cprover/large_step/pointers/pointers1.c new file mode 100644 index 00000000000..3dab14e327e --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers1.c @@ -0,0 +1,11 @@ +int x, y, *p; + +int main() +{ + x = 10; + p = &x; + y = *p; + __CPROVER_assert(y == 10, "property 1"); // should pass + + return 0; +} diff --git a/regression/cprover/large_step/pointers/pointers1.desc b/regression/cprover/large_step/pointers/pointers1.desc new file mode 100644 index 00000000000..fd69542b9f5 --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers1.desc @@ -0,0 +1,11 @@ +CORE +pointers1.c +--text --solve --inline --no-safety +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S12\(ς\) ⇒ S13\(ς\[❝x❞:=10\]\)$ +^\(\d+\) ∀ ς : state \. S13\(ς\) ⇒ S14\(ς\[❝p❞:=❝x❞\]\)$ +^\(\d+\) ∀ ς : state \. S14\(ς\) ⇒ S15\(ς\[❝y❞:=ς\(ς\(❝p❞\)\)\]\)$ +^\(\d+\) ∀ ς : state \. S15\(ς\) ⇒ \(ς\(❝y❞\) = 10\)$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/pointers10.c b/regression/cprover/large_step/pointers/pointers10.c new file mode 100644 index 00000000000..ceac0e98c79 --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers10.c @@ -0,0 +1,13 @@ +int main() +{ + int *p; // unconstrained + int x; + + if(p == &x) // address taken + { + *p = 123; + __CPROVER_assert(x == 123, "property 1"); // should pass + } + + return 0; +} diff --git a/regression/cprover/large_step/pointers/pointers10.desc b/regression/cprover/large_step/pointers/pointers10.desc new file mode 100644 index 00000000000..9bd77e62df5 --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers10.desc @@ -0,0 +1,7 @@ +CORE +pointers10.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/pointers11.c b/regression/cprover/large_step/pointers/pointers11.c new file mode 100644 index 00000000000..e4f3e8a94f7 --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers11.c @@ -0,0 +1,7 @@ +int main() +{ + int *p; + *p = 123; + __CPROVER_assert(*p == 123, "property 1"); // should pass + return 0; +} diff --git a/regression/cprover/large_step/pointers/pointers11.desc b/regression/cprover/large_step/pointers/pointers11.desc new file mode 100644 index 00000000000..c85aca8cc9b --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers11.desc @@ -0,0 +1,7 @@ +CORE +pointers11.c +--no-safety +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/pointers12.c b/regression/cprover/large_step/pointers/pointers12.c new file mode 100644 index 00000000000..9d4e1ae6dfa --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers12.c @@ -0,0 +1,9 @@ +int x = 123; + +int main() +{ + int *p; // might alias x + *p = 456; + __CPROVER_assert(x == 123, "property 1"); // should fail + return 0; +} diff --git a/regression/cprover/large_step/pointers/pointers12.desc b/regression/cprover/large_step/pointers/pointers12.desc new file mode 100644 index 00000000000..b7bdbdb0f21 --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers12.desc @@ -0,0 +1,7 @@ +CORE +pointers12.c + +^EXIT=10$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: REFUTED$ +-- diff --git a/regression/cprover/large_step/pointers/pointers2.c b/regression/cprover/large_step/pointers/pointers2.c new file mode 100644 index 00000000000..c12967179c7 --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers2.c @@ -0,0 +1,12 @@ +int x, *p; + +int main() +{ + x = 10; + p = &x; + *p = 20; + __CPROVER_assert(x == 20, "property 1"); // passes + __CPROVER_assert(x == 10, "property 2"); // fails + + return 0; +} diff --git a/regression/cprover/large_step/pointers/pointers2.desc b/regression/cprover/large_step/pointers/pointers2.desc new file mode 100644 index 00000000000..94398531679 --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers2.desc @@ -0,0 +1,14 @@ +CORE +pointers2.c +--text --solve --inline --no-safety +^EXIT=10$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S11\(ς\) ⇒ S12\(ς\[❝x❞:=10\]\)$ +^\(\d+\) ∀ ς : state \. S12\(ς\) ⇒ S13\(ς\[❝p❞:=❝x❞\]\)$ +^\(\d+\) ∀ ς : state \. S13\(ς\) ⇒ S14\(ς\[ς\(❝p❞\):=20\]\)$ +^\(\d+\) ∀ ς : state \. S14\(ς\) ⇒ \(ς\(❝x❞\) = 20\)$ +^\(\d+\) S15 = S14$ +^\(\d+\) ∀ ς : state \. S15\(ς\) ⇒ \(ς\(❝x❞\) = 10\)$ +^\[main\.assertion\.1] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2] line \d+ property 2: REFUTED$ +-- diff --git a/regression/cprover/large_step/pointers/pointers3.c b/regression/cprover/large_step/pointers/pointers3.c new file mode 100644 index 00000000000..06bc93e3beb --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers3.c @@ -0,0 +1,6 @@ +int main() +{ + int *p; + __CPROVER_assume(*p == 10); + __CPROVER_assert(*p == 10, "property 1"); // passes +} diff --git a/regression/cprover/large_step/pointers/pointers3.desc b/regression/cprover/large_step/pointers/pointers3.desc new file mode 100644 index 00000000000..2ba664b3702 --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers3.desc @@ -0,0 +1,9 @@ +CORE +pointers3.c +--text --solve --inline --no-safety +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. \(S10\(ς\) ∧ ς\(ς\(❝main::1::p❞\)\) = 10\) ⇒ S11\(ς\)$ +^\(\d+\) ∀ ς : state \. S11\(ς\) ⇒ \(ς\(ς\(❝main::1::p❞\)\) = 10\)$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/pointers4.c b/regression/cprover/large_step/pointers/pointers4.c new file mode 100644 index 00000000000..05e396d25bd --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers4.c @@ -0,0 +1,12 @@ +int x; + +int main() +{ + int *p; + __CPROVER_assume(*p == 10); + p = &x; + // not provable, since p may have pointed elsewhere + __CPROVER_assert(*p == 10, "property 1"); + + return 0; +} diff --git a/regression/cprover/large_step/pointers/pointers4.desc b/regression/cprover/large_step/pointers/pointers4.desc new file mode 100644 index 00000000000..72cfaa2cff2 --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers4.desc @@ -0,0 +1,11 @@ +CORE +pointers4.c +--text --solve --inline --no-safety +^EXIT=10$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S7\(ς\) ⇒ S8\(ς\[❝x❞:=0\]\)$ +^\(\d+\) ∀ ς : state \. \(S11\(ς\) ∧ ς\(ς\(❝main::1::p❞\)\) = 10\) ⇒ S12\(ς\)$ +^\(\d+\) ∀ ς : state \. S12\(ς\) ⇒ S13\(ς\[❝main::1::p❞:=❝x❞\]\)$ +^\(\d+\) ∀ ς : state \. S13\(ς\) ⇒ \(ς\(ς\(❝main::1::p❞\)\) = 10\)$ +^\[main\.assertion\.1\] line \d+ property 1: REFUTED$ +-- diff --git a/regression/cprover/large_step/pointers/pointers5.c b/regression/cprover/large_step/pointers/pointers5.c new file mode 100644 index 00000000000..d90530ca3a8 --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers5.c @@ -0,0 +1,11 @@ +int x; + +int main() +{ + int *p, *q; + + __CPROVER_assume(p == q); + __CPROVER_assert(*p == *q, "property 1"); // passes + + return 0; +} diff --git a/regression/cprover/large_step/pointers/pointers5.desc b/regression/cprover/large_step/pointers/pointers5.desc new file mode 100644 index 00000000000..128b13fe12d --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers5.desc @@ -0,0 +1,9 @@ +CORE +pointers5.c +--text --solve --inline --no-safety +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. \(S12\(ς\) ∧ ς\(❝main::1::p❞\) = ς\(❝main::1::q❞\)\) ⇒ S13\(ς\)$ +^\(\d+\) ∀ ς : state \. S13\(ς\) ⇒ \(ς\(ς\(❝main::1::p❞\)\) = ς\(ς\(❝main::1::q❞\)\)\)$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/pointers6.c b/regression/cprover/large_step/pointers/pointers6.c new file mode 100644 index 00000000000..3461a8c87b4 --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers6.c @@ -0,0 +1,12 @@ +int x; + +int main() +{ + int *p, *q; + p = &x; + *p = 10; + q = &x; + __CPROVER_assert(*q == 10, "property 1"); // passes + + return 0; +} diff --git a/regression/cprover/large_step/pointers/pointers6.desc b/regression/cprover/large_step/pointers/pointers6.desc new file mode 100644 index 00000000000..36d9b6e4082 --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers6.desc @@ -0,0 +1,11 @@ +CORE +pointers6.c +--text --solve --inline --no-safety +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S12\(ς\) ⇒ S13\(ς\[❝main::1::p❞:=❝x❞\]\)$ +^\(\d+\) ∀ ς : state \. S13\(ς\) ⇒ S14\(ς\[ς\(❝main::1::p❞\):=10\]\)$ +^\(\d+\) ∀ ς : state \. S14\(ς\) ⇒ S15\(ς\[❝main::1::q❞:=❝x❞\]\)$ +^\(\d+\) ∀ ς : state \. S15\(ς\) ⇒ \(ς\(ς\(❝main::1::q❞\)\) = 10\)$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/pointers7.c b/regression/cprover/large_step/pointers/pointers7.c new file mode 100644 index 00000000000..0e1a9d92add --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers7.c @@ -0,0 +1,11 @@ +int x, y, *p; + +int main() +{ + x = 10; + p = &y; + *p = 20; // unrelated to 'x' + __CPROVER_assert(x == 10, "property 1"); // should pass + + return 0; +} diff --git a/regression/cprover/large_step/pointers/pointers7.desc b/regression/cprover/large_step/pointers/pointers7.desc new file mode 100644 index 00000000000..540d64f133b --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers7.desc @@ -0,0 +1,16 @@ +CORE +pointers7.c +--text --solve --inline --no-safety +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S7\(ς\) ⇒ S8\(ς\[❝p❞:=NULL\]\)$ +^\(\d+\) ∀ ς : state \. S8\(ς\) ⇒ S9\(ς\[❝x❞:=0\]\)$ +^\(\d+\) ∀ ς : state \. S9\(ς\) ⇒ S10\(ς\[❝y❞:=0\]\)$ +^\(\d+\) S11 = S10$ +^\(\d+\) S12 = S11$ +^\(\d+\) ∀ ς : state \. S12\(ς\) ⇒ S13\(ς\[❝x❞:=10\]\)$ +^\(\d+\) ∀ ς : state \. S13\(ς\) ⇒ S14\(ς\[❝p❞:=❝y❞\]\)$ +^\(\d+\) ∀ ς : state \. S14\(ς\) ⇒ S15\(ς\[ς\(❝p❞\):=20\]\)$ +^\(\d+\) ∀ ς : state \. S15\(ς\) ⇒ \(ς\(❝x❞\) = 10\)$ +^\[main\.assertion\.1\] line \d property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/pointers8.c b/regression/cprover/large_step/pointers/pointers8.c new file mode 100644 index 00000000000..e2a62ea7efa --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers8.c @@ -0,0 +1,11 @@ +int main() +{ + int *p; // unconstrained, might point to itself! + + //__CPROVER_assume(!__CPROVER_same_object(p, &p)); + *p = 123; // can't point to itself + int p_value = *p; + __CPROVER_assert(p_value == 123, "property 1"); // should pass + + return 0; +} diff --git a/regression/cprover/large_step/pointers/pointers8.desc b/regression/cprover/large_step/pointers/pointers8.desc new file mode 100644 index 00000000000..13588c91baa --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers8.desc @@ -0,0 +1,10 @@ +CORE +pointers8.c +--text --solve --inline --no-safety +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S10\(ς\) ⇒ S11\(ς\[ς\(❝main::1::p❞\):=123\]\)$ +^\(\d+\) ∀ ς : state \. S12\(ς\) ⇒ S13\(ς\[❝main::1::p_value❞:=ς\(ς\(❝main::1::p❞\)\)\]\)$ +^\(\d+\) ∀ ς : state \. S13\(ς\) ⇒ \(ς\(❝main::1::p_value❞\) = 123\)$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/pointers9.c b/regression/cprover/large_step/pointers/pointers9.c new file mode 100644 index 00000000000..11bb1df48a2 --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers9.c @@ -0,0 +1,10 @@ +int main() +{ + int *p; // unconstrained + int x = 123; + + if(p == &x) + __CPROVER_assert(*p == 123, "property 1"); // should pass + + return 0; +} diff --git a/regression/cprover/large_step/pointers/pointers9.desc b/regression/cprover/large_step/pointers/pointers9.desc new file mode 100644 index 00000000000..54ee6653588 --- /dev/null +++ b/regression/cprover/large_step/pointers/pointers9.desc @@ -0,0 +1,11 @@ +CORE +pointers9.c +--text --solve --inline --no-safety +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S11\(ς\) ⇒ S12\(ς\[❝main::1::x❞:=123\]\)$ +^\(\d+\) ∀ ς : state \. \(S12\(ς\) ∧ ¬\(ς\(❝main::1::p❞\) = ❝main::1::x❞\)\) ⇒ S13T\(ς\)$ +^\(\d+\) ∀ ς : state \. \(S12\(ς\) ∧ ς\(❝main::1::p❞\) = ❝main::1::x❞\) ⇒ S13\(ς\)$ +^\(\d+\) ∀ ς : state \. S13\(ς\) ⇒ \(ς\(ς\(❝main::1::p❞\)\) = 123\)$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/posix_memalign1.c b/regression/cprover/large_step/pointers/posix_memalign1.c new file mode 100644 index 00000000000..07309a88bd5 --- /dev/null +++ b/regression/cprover/large_step/pointers/posix_memalign1.c @@ -0,0 +1,9 @@ +int posix_memalign(void **, __CPROVER_size_t, __CPROVER_size_t); + +int main() +{ + void *ptr; + posix_memalign(&ptr, sizeof(void *), sizeof(int)); + __CPROVER_assert(__CPROVER_r_ok(ptr, sizeof(int)), "property 1"); + return 0; +} diff --git a/regression/cprover/large_step/pointers/posix_memalign1.desc b/regression/cprover/large_step/pointers/posix_memalign1.desc new file mode 100644 index 00000000000..36bf94ef3d8 --- /dev/null +++ b/regression/cprover/large_step/pointers/posix_memalign1.desc @@ -0,0 +1,7 @@ +CORE +posix_memalign1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/struct_pointer1.c b/regression/cprover/large_step/pointers/struct_pointer1.c new file mode 100644 index 00000000000..7c19aabe93e --- /dev/null +++ b/regression/cprover/large_step/pointers/struct_pointer1.c @@ -0,0 +1,14 @@ +struct my_struct +{ + int data; +}; + +int main() +{ + struct my_struct *my_struct_ptr; // not constrained + // __CPROVER_assume(!__CPROVER_same_object(my_struct_ptr, &my_struct_ptr)); + my_struct_ptr->data = 123; + int my_struct_data = my_struct_ptr->data; + __CPROVER_assert(my_struct_data == 123, "property 1"); // should pass + return 0; +} diff --git a/regression/cprover/large_step/pointers/struct_pointer1.desc b/regression/cprover/large_step/pointers/struct_pointer1.desc new file mode 100644 index 00000000000..f8d09cb004a --- /dev/null +++ b/regression/cprover/large_step/pointers/struct_pointer1.desc @@ -0,0 +1,10 @@ +CORE +struct_pointer1.c +--text --solve --inline --no-safety +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S10\(ς\) ⇒ S11\(ς\[ς\(❝main::1::my_struct_ptr❞\)\.❝data❞:=123\]\)$ +^\(\d+\) ∀ ς : state \. S12\(ς\) ⇒ S13\(ς\[❝main::1::my_struct_data❞:=ς\(ς\(❝main::1::my_struct_ptr❞\)\.❝data❞\)\]\)$ +^\(\d+\) ∀ ς : state \. S13\(ς\) ⇒ \(ς\(❝main::1::my_struct_data❞\) = 123\)$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/struct_pointer2.c b/regression/cprover/large_step/pointers/struct_pointer2.c new file mode 100644 index 00000000000..a6f85af0190 --- /dev/null +++ b/regression/cprover/large_step/pointers/struct_pointer2.c @@ -0,0 +1,15 @@ +struct my_struct +{ + int data; +}; + +int main() +{ + struct my_struct my_struct; + struct my_struct *my_struct_ptr = &my_struct; + + my_struct_ptr->data = 123; + __CPROVER_assert(my_struct.data == 123, "property 1"); // should pass + + return 0; +} diff --git a/regression/cprover/large_step/pointers/struct_pointer2.desc b/regression/cprover/large_step/pointers/struct_pointer2.desc new file mode 100644 index 00000000000..9e6b0d11273 --- /dev/null +++ b/regression/cprover/large_step/pointers/struct_pointer2.desc @@ -0,0 +1,10 @@ +CORE +struct_pointer2.c +--text --solve --inline --no-safety +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S11\(ς\) ⇒ S12\(ς\[❝main::1::my_struct_ptr❞:=❝main::1::my_struct❞\]\)$ +^\(\d+\) ∀ ς : state \. S12\(ς\) ⇒ S13\(ς\[ς\(❝main::1::my_struct_ptr❞\)\.❝data❞:=123\]\)$ +^\(\d+\) ∀ ς : state \. S13\(ς\) ⇒ \(ς\(❝main::1::my_struct❞\.❝data❞\) = 123\)$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/struct_pointer3.c b/regression/cprover/large_step/pointers/struct_pointer3.c new file mode 100644 index 00000000000..139ed6ca101 --- /dev/null +++ b/regression/cprover/large_step/pointers/struct_pointer3.c @@ -0,0 +1,12 @@ +struct S +{ + int x, y; +}; + +int main() +{ + struct S a; + struct S *p = &a; + __CPROVER_assert(p->x == a.x, "property 1"); // should pass + return 0; +} diff --git a/regression/cprover/large_step/pointers/struct_pointer3.desc b/regression/cprover/large_step/pointers/struct_pointer3.desc new file mode 100644 index 00000000000..d67a291119d --- /dev/null +++ b/regression/cprover/large_step/pointers/struct_pointer3.desc @@ -0,0 +1,7 @@ +CORE +struct_pointer3.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/struct_pointer4.c b/regression/cprover/large_step/pointers/struct_pointer4.c new file mode 100644 index 00000000000..b5acec0331e --- /dev/null +++ b/regression/cprover/large_step/pointers/struct_pointer4.c @@ -0,0 +1,13 @@ +struct S +{ + int x, y; +}; + +int main() +{ + struct S a, b; + struct S *p = &a; + *p = b; // copy entire struct + __CPROVER_assert(a.x == b.x, "property 1"); // should pass + return 0; +} diff --git a/regression/cprover/large_step/pointers/struct_pointer4.desc b/regression/cprover/large_step/pointers/struct_pointer4.desc new file mode 100644 index 00000000000..1c94169c51c --- /dev/null +++ b/regression/cprover/large_step/pointers/struct_pointer4.desc @@ -0,0 +1,7 @@ +CORE +struct_pointer4.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/struct_pointer5.c b/regression/cprover/large_step/pointers/struct_pointer5.c new file mode 100644 index 00000000000..0ce42304ea6 --- /dev/null +++ b/regression/cprover/large_step/pointers/struct_pointer5.c @@ -0,0 +1,13 @@ +struct S +{ + int x, y; +}; + +int main() +{ + struct S a; + int *p = &a.y; + *p = 123; + __CPROVER_assert(a.y == 123, "property 1"); // should pass + return 0; +} diff --git a/regression/cprover/large_step/pointers/struct_pointer5.desc b/regression/cprover/large_step/pointers/struct_pointer5.desc new file mode 100644 index 00000000000..7a974b8a34b --- /dev/null +++ b/regression/cprover/large_step/pointers/struct_pointer5.desc @@ -0,0 +1,7 @@ +CORE +struct_pointer5.c +--no-safety +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/pointers/struct_pointer6.c b/regression/cprover/large_step/pointers/struct_pointer6.c new file mode 100644 index 00000000000..17714e09766 --- /dev/null +++ b/regression/cprover/large_step/pointers/struct_pointer6.c @@ -0,0 +1,16 @@ +struct buf +{ + __CPROVER_size_t len; +}; + +int main() +{ + struct buf *b; + __CPROVER_assume(__CPROVER_r_ok(b)); // must not alias with x + __CPROVER_assume(b->len == 456); + + __CPROVER_size_t x, *size_t_ptr = &x; + *size_t_ptr = 123; + + __CPROVER_assert(b->len == 456, "property 1"); +} diff --git a/regression/cprover/large_step/pointers/struct_pointer6.desc b/regression/cprover/large_step/pointers/struct_pointer6.desc new file mode 100644 index 00000000000..dcd12aacda4 --- /dev/null +++ b/regression/cprover/large_step/pointers/struct_pointer6.desc @@ -0,0 +1,7 @@ +CORE +struct_pointer6.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/quantifiers/exists1.c b/regression/cprover/large_step/quantifiers/exists1.c new file mode 100644 index 00000000000..2fc67165c91 --- /dev/null +++ b/regression/cprover/large_step/quantifiers/exists1.c @@ -0,0 +1,5 @@ +int main() +{ + __CPROVER_assert(∃ int i; i == 100, "100 exists"); // passes + __CPROVER_assert(∃ int i; 0, "'false' does not exist"); // fails +} diff --git a/regression/cprover/large_step/quantifiers/exists1.desc b/regression/cprover/large_step/quantifiers/exists1.desc new file mode 100644 index 00000000000..daf85c282a9 --- /dev/null +++ b/regression/cprover/large_step/quantifiers/exists1.desc @@ -0,0 +1,10 @@ +KNOWNBUG +exists1.c +--text --solve +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S19\(ς\) ⇒ ∃ main::1::1::i : signedbv\[32\] \. main::1::1::i = 100$ +^\(\d+\) ∀ ς : state \. S20\(ς\) ⇒ ∃ main::1::2::i : signedbv\[32] \. 0 ≠ 0$ +^\[main\.assertion\.1\] line \d+ 100 exists: REFUTED$ +^\[main\.assertion\.2\] line \d+ 'false' does not exist: REFUTED$ +-- diff --git a/regression/cprover/large_step/quantifiers/forall1.c b/regression/cprover/large_step/quantifiers/forall1.c new file mode 100644 index 00000000000..4f07b3473b6 --- /dev/null +++ b/regression/cprover/large_step/quantifiers/forall1.c @@ -0,0 +1,8 @@ +int main() +{ + __CPROVER_assert(∀ int i; i == 100, "all ints are 100"); // fails + __CPROVER_assert(∀ int i; 1, "true holds for all i"); // passes + __CPROVER_assert(∀ unsigned char ch; + ch <= 255, "all chars are ≤255"); // passes + return 0; +} diff --git a/regression/cprover/large_step/quantifiers/forall1.desc b/regression/cprover/large_step/quantifiers/forall1.desc new file mode 100644 index 00000000000..d466b9afc06 --- /dev/null +++ b/regression/cprover/large_step/quantifiers/forall1.desc @@ -0,0 +1,12 @@ +KNOWNBUG +forall1.c +--text --solve +^EXIT=10$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S19\(ς\) ⇒ ∀ main::1::1::i : signedbv\[32\] \. main::1::1::i = 100$ +^\(\d+\) ∀ ς : state \. S20\(ς\) ⇒ ∀ main::1::2::i : signedbv\[32\] \. 1 ≠ 0$ +^\(\d+\) ∀ ς : state \. S21\(ς\) ⇒ ∀ main::1::3::ch : unsignedbv\[8\] \. cast\(main::1::3::ch, signedbv\[32\]\) ≤ 255$ +^\[main\.assertion\.1\] line \d+ all ints are 100: REFUTED$ +^\[main\.assertion\.2\] line \d+ true holds for all i: SUCCESS$ +^\[main\.assertion\.3\] line \d+ all chars are ≤255: SUCCESS$ +-- diff --git a/regression/cprover/large_step/quantifiers/zeros1.c b/regression/cprover/large_step/quantifiers/zeros1.c new file mode 100644 index 00000000000..3233f40d0f7 --- /dev/null +++ b/regression/cprover/large_step/quantifiers/zeros1.c @@ -0,0 +1,10 @@ +int main() +{ + char array[10]; + + __CPROVER_assume(∀ int i; i >= 0 && i array[i] == 0); + + __CPROVER_assert(array[3] == 0, "property 1"); + + return 0; +} diff --git a/regression/cprover/large_step/quantifiers/zeros1.desc b/regression/cprover/large_step/quantifiers/zeros1.desc new file mode 100644 index 00000000000..08f04994e1f --- /dev/null +++ b/regression/cprover/large_step/quantifiers/zeros1.desc @@ -0,0 +1,7 @@ +KNOWNBUG +forall1.c + +^EXIT=0$ +^SIGNAL=0$ +^program is safe / function main is safe / line .* property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/safety/array_bounds1.c b/regression/cprover/large_step/safety/array_bounds1.c new file mode 100644 index 00000000000..d7d6876a596 --- /dev/null +++ b/regression/cprover/large_step/safety/array_bounds1.c @@ -0,0 +1,8 @@ +int array[100]; + +int main() +{ + int x = array[10]; // safe + int y = array[100]; // unsafe + int z = array[-1]; // unsafe +} diff --git a/regression/cprover/large_step/safety/array_bounds1.desc b/regression/cprover/large_step/safety/array_bounds1.desc new file mode 100644 index 00000000000..59241c8ee25 --- /dev/null +++ b/regression/cprover/large_step/safety/array_bounds1.desc @@ -0,0 +1,9 @@ +CORE +array_bounds1.c +--safety +^EXIT=10$ +^SIGNAL=0$ +^\[main\.array_bounds\.1\] line \d+ array bounds in array\[.*10\]: SUCCESS$ +^\[main\.array_bounds\.2\] line \d+ array bounds in array\[.*100\]: REFUTED$ +^\[main\.array_bounds\.3\] line \d+ array bounds in array\[.*-1\]: REFUTED$ +-- diff --git a/regression/cprover/large_step/safety/array_bounds2.c b/regression/cprover/large_step/safety/array_bounds2.c new file mode 100644 index 00000000000..a5383e97681 --- /dev/null +++ b/regression/cprover/large_step/safety/array_bounds2.c @@ -0,0 +1,9 @@ +int array[100]; + +int main() +{ + int *p = array; + int x = p[10]; // safe + int y = p[100]; // unsafe + int z = p[-1]; // unsafe +} diff --git a/regression/cprover/large_step/safety/array_bounds2.desc b/regression/cprover/large_step/safety/array_bounds2.desc new file mode 100644 index 00000000000..00b48326845 --- /dev/null +++ b/regression/cprover/large_step/safety/array_bounds2.desc @@ -0,0 +1,9 @@ +CORE +array_bounds2.c +--safety +^EXIT=10$ +^SIGNAL=0$ +^\[main\.pointer\.1\] line \d+ pointer .* safe: SUCCESS$ +^\[main\.pointer\.2\] line \d+ pointer .* safe: REFUTED$ +^\[main\.pointer\.3\] line \d+ pointer .* safe: REFUTED$ +-- diff --git a/regression/cprover/large_step/safety/array_bounds3.c b/regression/cprover/large_step/safety/array_bounds3.c new file mode 100644 index 00000000000..3d943816bf4 --- /dev/null +++ b/regression/cprover/large_step/safety/array_bounds3.c @@ -0,0 +1,12 @@ +int main() +{ + const __CPROVER_size_t array_len; + const unsigned char *array_bytes; + + __CPROVER_assume(__CPROVER_LIVE_OBJECT(array_bytes)); + __CPROVER_assume(array_len >= 1); + __CPROVER_assume(__CPROVER_OBJECT_SIZE(array_bytes) == array_len); + __CPROVER_assume(__CPROVER_POINTER_OFFSET(array_bytes) == 0); + + array_bytes[0]; +} diff --git a/regression/cprover/large_step/safety/array_bounds3.desc b/regression/cprover/large_step/safety/array_bounds3.desc new file mode 100644 index 00000000000..3b258df73fd --- /dev/null +++ b/regression/cprover/large_step/safety/array_bounds3.desc @@ -0,0 +1,7 @@ +CORE +array_bounds3.c +--safety +^EXIT=0$ +^SIGNAL=0$ +^\[main\.pointer\.1\] line \d+ pointer .* safe: SUCCESS$ +-- diff --git a/regression/cprover/large_step/safety/array_bounds4.c b/regression/cprover/large_step/safety/array_bounds4.c new file mode 100644 index 00000000000..61f0ad33efe --- /dev/null +++ b/regression/cprover/large_step/safety/array_bounds4.c @@ -0,0 +1,11 @@ +int array[100]; + +int main() +{ + unsigned long int index; + + // safe owing to shortcircuit semantics + if(index < 100 && array[index] != 123) + { + } +} diff --git a/regression/cprover/large_step/safety/array_bounds4.desc b/regression/cprover/large_step/safety/array_bounds4.desc new file mode 100644 index 00000000000..fb0d4826702 --- /dev/null +++ b/regression/cprover/large_step/safety/array_bounds4.desc @@ -0,0 +1,7 @@ +CORE +array_bounds4.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.array_bounds\.1\] line \d+ array bounds in array\[.*index\]: SUCCESS$ +-- diff --git a/regression/cprover/large_step/safety/const1.c b/regression/cprover/large_step/safety/const1.c new file mode 100644 index 00000000000..91bd80272b3 --- /dev/null +++ b/regression/cprover/large_step/safety/const1.c @@ -0,0 +1,8 @@ +const int months = 12; + +int main() +{ + int *p; + p = (int *)&months; + *p = 123; // unsafe, since 'months' is const +} diff --git a/regression/cprover/large_step/safety/const1.desc b/regression/cprover/large_step/safety/const1.desc new file mode 100644 index 00000000000..77a03f63d94 --- /dev/null +++ b/regression/cprover/large_step/safety/const1.desc @@ -0,0 +1,7 @@ +CORE +const1.c +--safety +^EXIT=10$ +^SIGNAL=0$ +^\[main\.pointer\.1\] line \d+ pointer p safe: REFUTED$ +-- diff --git a/regression/cprover/large_step/safety/division_by_zero.c b/regression/cprover/large_step/safety/division_by_zero.c new file mode 100644 index 00000000000..31f0a7b11ac --- /dev/null +++ b/regression/cprover/large_step/safety/division_by_zero.c @@ -0,0 +1,9 @@ +int main() +{ + int x, y, z; + + z = 10 / x; // unsafe + + if(y != 0) + z = 10 / y; // safe +} diff --git a/regression/cprover/large_step/safety/division_by_zero.desc b/regression/cprover/large_step/safety/division_by_zero.desc new file mode 100644 index 00000000000..84da044b758 --- /dev/null +++ b/regression/cprover/large_step/safety/division_by_zero.desc @@ -0,0 +1,8 @@ +CORE +division_by_zero.c +--safety +^EXIT=10$ +^SIGNAL=0$ +^\[main\.division-by-zero\.1\] line \d+ division by zero in 10 / x: REFUTED$ +^\[main\.division-by-zero\.2\] line \d+ division by zero in 10 / y: SUCCESS$ +-- diff --git a/regression/cprover/large_step/safety/division_by_zero2.c b/regression/cprover/large_step/safety/division_by_zero2.c new file mode 100644 index 00000000000..958c0fd06b9 --- /dev/null +++ b/regression/cprover/large_step/safety/division_by_zero2.c @@ -0,0 +1,11 @@ +int main() +{ + int x; + + if(x > 0 && 0xffffffff / x > 0) // safe + { + } + else + { + } +} diff --git a/regression/cprover/large_step/safety/division_by_zero2.desc b/regression/cprover/large_step/safety/division_by_zero2.desc new file mode 100644 index 00000000000..c15922bdf37 --- /dev/null +++ b/regression/cprover/large_step/safety/division_by_zero2.desc @@ -0,0 +1,7 @@ +CORE +division_by_zero2.c +--safety +^EXIT=0$ +^SIGNAL=0$ +^\[main\.division-by-zero\.1\] line \d+ division by zero in .*: SUCCESS$ +-- diff --git a/regression/cprover/large_step/safety/double_free1.c b/regression/cprover/large_step/safety/double_free1.c new file mode 100644 index 00000000000..c1b7b488c61 --- /dev/null +++ b/regression/cprover/large_step/safety/double_free1.c @@ -0,0 +1,8 @@ +#include + +int main() +{ + int *p = malloc(sizeof(int)); + free(p); // safe + free(p); // unsafe +} diff --git a/regression/cprover/large_step/safety/double_free1.desc b/regression/cprover/large_step/safety/double_free1.desc new file mode 100644 index 00000000000..c767252dad3 --- /dev/null +++ b/regression/cprover/large_step/safety/double_free1.desc @@ -0,0 +1,8 @@ +CORE +double_free1.c +--safety +^EXIT=10$ +^SIGNAL=0$ +^\[main\.free\.1\] line \d+ free argument must be valid dynamic object: SUCCESS$ +^\[main\.free\.2\] line \d+ free argument must be valid dynamic object: REFUTED$ +-- diff --git a/regression/cprover/large_step/safety/dynamic_object1.c b/regression/cprover/large_step/safety/dynamic_object1.c new file mode 100644 index 00000000000..683af1084e3 --- /dev/null +++ b/regression/cprover/large_step/safety/dynamic_object1.c @@ -0,0 +1,13 @@ +int main() +{ + char *p, *q; + // functional consistency of dynamic_object + __CPROVER_assume(p == q); + + __CPROVER_assert( + __CPROVER_DYNAMIC_OBJECT(p) == __CPROVER_DYNAMIC_OBJECT(q), "property 1"); + + __CPROVER_assert( + __CPROVER_DYNAMIC_OBJECT(p) == __CPROVER_DYNAMIC_OBJECT(q + 1), + "property 2"); +} diff --git a/regression/cprover/large_step/safety/dynamic_object1.desc b/regression/cprover/large_step/safety/dynamic_object1.desc new file mode 100644 index 00000000000..75cead585fb --- /dev/null +++ b/regression/cprover/large_step/safety/dynamic_object1.desc @@ -0,0 +1,8 @@ +CORE +dynamic_object1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$ +-- diff --git a/regression/cprover/large_step/safety/free1.c b/regression/cprover/large_step/safety/free1.c new file mode 100644 index 00000000000..cb2f949f9a9 --- /dev/null +++ b/regression/cprover/large_step/safety/free1.c @@ -0,0 +1,10 @@ +void *malloc(__CPROVER_size_t); +void free(void *); + +int main() +{ + int *p = malloc(sizeof(int)); + __CPROVER_assert(__CPROVER_LIVE_OBJECT(p), "property 1"); // passes + free(p); + __CPROVER_assert(__CPROVER_LIVE_OBJECT(p), "property 2"); // fails +} diff --git a/regression/cprover/large_step/safety/free1.desc b/regression/cprover/large_step/safety/free1.desc new file mode 100644 index 00000000000..00b290ff5cc --- /dev/null +++ b/regression/cprover/large_step/safety/free1.desc @@ -0,0 +1,8 @@ +CORE +free1.c +--safety +^EXIT=10$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: REFUTED$ +-- diff --git a/regression/cprover/large_step/safety/free2.c b/regression/cprover/large_step/safety/free2.c new file mode 100644 index 00000000000..7c89b31da08 --- /dev/null +++ b/regression/cprover/large_step/safety/free2.c @@ -0,0 +1,9 @@ +void *malloc(__CPROVER_size_t); +void free(void *); + +int main() +{ + int *p = malloc(sizeof(int)); + p++; + free(p); // fails, offset is not zero +} diff --git a/regression/cprover/large_step/safety/free2.desc b/regression/cprover/large_step/safety/free2.desc new file mode 100644 index 00000000000..1d74597b0d4 --- /dev/null +++ b/regression/cprover/large_step/safety/free2.desc @@ -0,0 +1,7 @@ +CORE +free2.c +--safety +^EXIT=10$ +^SIGNAL=0$ +^\[main\.free\.1\] line \d+ free argument must be valid dynamic object: REFUTED$ +-- diff --git a/regression/cprover/large_step/safety/free3.c b/regression/cprover/large_step/safety/free3.c new file mode 100644 index 00000000000..f598ab8b4e4 --- /dev/null +++ b/regression/cprover/large_step/safety/free3.c @@ -0,0 +1,11 @@ +void *malloc(__CPROVER_size_t); +void free(void *); + +int main() +{ + int *p = malloc(sizeof(int)); + int *q = malloc(sizeof(int)); + free(p); + __CPROVER_assert(!__CPROVER_LIVE_OBJECT(p), "property 1"); // should pass + __CPROVER_assert(__CPROVER_LIVE_OBJECT(q), "property 2"); // should pass +} diff --git a/regression/cprover/large_step/safety/free3.desc b/regression/cprover/large_step/safety/free3.desc new file mode 100644 index 00000000000..f56f44e6e44 --- /dev/null +++ b/regression/cprover/large_step/safety/free3.desc @@ -0,0 +1,6 @@ +KNOWNBUG +free3.c + +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/safety/free4.c b/regression/cprover/large_step/safety/free4.c new file mode 100644 index 00000000000..2148ccd73cb --- /dev/null +++ b/regression/cprover/large_step/safety/free4.c @@ -0,0 +1,20 @@ +void *malloc(__CPROVER_size_t); +void free(void *); + +struct List +{ + char *data; +}; + +void *p; + +int main() +{ + struct List *list; + __CPROVER_assume(__CPROVER_rw_ok(list)); + + p = malloc(123); + free(p); + + __CPROVER_assert(__CPROVER_rw_ok(list), "property 1"); +} diff --git a/regression/cprover/large_step/safety/free4.desc b/regression/cprover/large_step/safety/free4.desc new file mode 100644 index 00000000000..ef72c904989 --- /dev/null +++ b/regression/cprover/large_step/safety/free4.desc @@ -0,0 +1,6 @@ +KNOWNBUG +free4.c + +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/regression/cprover/large_step/safety/free_null1.c b/regression/cprover/large_step/safety/free_null1.c new file mode 100644 index 00000000000..7c405f54cf2 --- /dev/null +++ b/regression/cprover/large_step/safety/free_null1.c @@ -0,0 +1,7 @@ +#include + +int main() +{ + free(0); // safe + free((char *)0 + 1); // unsafe +} diff --git a/regression/cprover/large_step/safety/free_null1.desc b/regression/cprover/large_step/safety/free_null1.desc new file mode 100644 index 00000000000..5f7e90745cd --- /dev/null +++ b/regression/cprover/large_step/safety/free_null1.desc @@ -0,0 +1,8 @@ +CORE +free_null1.c +--safety +^EXIT=10$ +^SIGNAL=0$ +^\[main\.free\.1\] line \d+ free argument must be valid dynamic object: SUCCESS$ +^\[main\.free\.2\] line \d+ free argument must be valid dynamic object: REFUTED$ +-- diff --git a/regression/cprover/large_step/safety/live_object1.c b/regression/cprover/large_step/safety/live_object1.c new file mode 100644 index 00000000000..29f5929a77b --- /dev/null +++ b/regression/cprover/large_step/safety/live_object1.c @@ -0,0 +1,9 @@ +int main() +{ + char *p, *q; + // functional consistency of live_object + __CPROVER_assume(__CPROVER_LIVE_OBJECT(p)); + __CPROVER_assume(p == q); + __CPROVER_assert(__CPROVER_LIVE_OBJECT(q), "property 1"); + __CPROVER_assert(__CPROVER_LIVE_OBJECT(q + 1), "property 2"); +} diff --git a/regression/cprover/large_step/safety/live_object1.desc b/regression/cprover/large_step/safety/live_object1.desc new file mode 100644 index 00000000000..ca7bf546a88 --- /dev/null +++ b/regression/cprover/large_step/safety/live_object1.desc @@ -0,0 +1,8 @@ +CORE +live_object1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$ +-- diff --git a/regression/cprover/large_step/safety/local_out_of_scope1.c b/regression/cprover/large_step/safety/local_out_of_scope1.c new file mode 100644 index 00000000000..49879d6ddbc --- /dev/null +++ b/regression/cprover/large_step/safety/local_out_of_scope1.c @@ -0,0 +1,12 @@ +int main() +{ + int *p; + + { + int x; + p = &x; + *p; // ok + } + + // *p; // unsafe +} diff --git a/regression/cprover/large_step/safety/local_out_of_scope1.desc b/regression/cprover/large_step/safety/local_out_of_scope1.desc new file mode 100644 index 00000000000..b046bb139a4 --- /dev/null +++ b/regression/cprover/large_step/safety/local_out_of_scope1.desc @@ -0,0 +1,8 @@ +KNOWNBUG +local_out_of_scope1.c + +^EXIT=10$ +^SIGNAL=0$ +^\[main\.pointer\.1\] line \d+ pointer p safe: SUCCESS$ +^\[main\.pointer\.2\] line \d+ pointer p safe: REFUTED$ +-- diff --git a/regression/cprover/large_step/safety/local_out_of_scope2.c b/regression/cprover/large_step/safety/local_out_of_scope2.c new file mode 100644 index 00000000000..b65792b9685 --- /dev/null +++ b/regression/cprover/large_step/safety/local_out_of_scope2.c @@ -0,0 +1,11 @@ +int main() +{ + void *p; + __CPROVER_assume(__CPROVER_LIVE_OBJECT(p)); + + { + void *q; // unrelated to p + } + + __CPROVER_assert(__CPROVER_LIVE_OBJECT(p), "property 1"); // passes +} diff --git a/regression/cprover/large_step/safety/local_out_of_scope2.desc b/regression/cprover/large_step/safety/local_out_of_scope2.desc new file mode 100644 index 00000000000..3f3277c6e60 --- /dev/null +++ b/regression/cprover/large_step/safety/local_out_of_scope2.desc @@ -0,0 +1,7 @@ +CORE +local_out_of_scope2.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/safety/local_out_of_scope3.c b/regression/cprover/large_step/safety/local_out_of_scope3.c new file mode 100644 index 00000000000..fd3e4a6459e --- /dev/null +++ b/regression/cprover/large_step/safety/local_out_of_scope3.c @@ -0,0 +1,10 @@ +int main() +{ + int *p; + __CPROVER_assume(__CPROVER_r_ok(p)); + { + int x; + __CPROVER_assert(p != &x, "property 1"); // passes + } + __CPROVER_assert(__CPROVER_r_ok(p), "property 2"); // passes +} diff --git a/regression/cprover/large_step/safety/local_out_of_scope3.desc b/regression/cprover/large_step/safety/local_out_of_scope3.desc new file mode 100644 index 00000000000..cd9891e67d8 --- /dev/null +++ b/regression/cprover/large_step/safety/local_out_of_scope3.desc @@ -0,0 +1,8 @@ +CORE +local_out_of_scope3.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$ +-- diff --git a/regression/cprover/large_step/safety/malloc1.c b/regression/cprover/large_step/safety/malloc1.c new file mode 100644 index 00000000000..8a450655a5b --- /dev/null +++ b/regression/cprover/large_step/safety/malloc1.c @@ -0,0 +1,15 @@ +void *malloc(__CPROVER_size_t); + +int main() +{ + int *p = malloc(sizeof(int)); + + __CPROVER_assert(__CPROVER_LIVE_OBJECT(p), "property 1"); // safe + __CPROVER_assert( + __CPROVER_OBJECT_SIZE(p) == sizeof(int), "property 2"); // safe + __CPROVER_assert(__CPROVER_POINTER_OFFSET(p) == 0, "property 3"); // safe + __CPROVER_assert(__CPROVER_r_ok(p), "property 4"); // safe + __CPROVER_assert(__CPROVER_r_ok(p + 1), "property 5"); // unsafe + + return 0; +} diff --git a/regression/cprover/large_step/safety/malloc1.desc b/regression/cprover/large_step/safety/malloc1.desc new file mode 100644 index 00000000000..f3f9890f4b3 --- /dev/null +++ b/regression/cprover/large_step/safety/malloc1.desc @@ -0,0 +1,11 @@ +CORE +malloc1.c +--safety +^EXIT=10$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$ +^\[main\.assertion\.3\] line \d+ property 3: SUCCESS$ +^\[main\.assertion\.4\] line \d+ property 4: SUCCESS$ +^\[main\.assertion\.5\] line \d+ property 5: REFUTED$ +-- diff --git a/regression/cprover/large_step/safety/memchr1.c b/regression/cprover/large_step/safety/memchr1.c new file mode 100644 index 00000000000..956a42b57fa --- /dev/null +++ b/regression/cprover/large_step/safety/memchr1.c @@ -0,0 +1,8 @@ +void *memchr(const void *, int, __CPROVER_size_t n); + +int main() +{ + int x; + memchr(&x, 123, sizeof x); // safe + memchr(&x, 123, (sizeof x) + 1); // unsafe +} diff --git a/regression/cprover/large_step/safety/memchr1.desc b/regression/cprover/large_step/safety/memchr1.desc new file mode 100644 index 00000000000..03608afb65d --- /dev/null +++ b/regression/cprover/large_step/safety/memchr1.desc @@ -0,0 +1,8 @@ +CORE +memchr1.c +--safety +^EXIT=10$ +^SIGNAL=0$ +^\[main\.memchr\.1\] line \d+ memchr source must be valid: SUCCESS$ +^\[main\.memchr\.2\] line \d+ memchr source must be valid: REFUTED$ +-- diff --git a/regression/cprover/large_step/safety/memcmp1.c b/regression/cprover/large_step/safety/memcmp1.c new file mode 100644 index 00000000000..0aec94717fc --- /dev/null +++ b/regression/cprover/large_step/safety/memcmp1.c @@ -0,0 +1,8 @@ +int memcmp(const void *, const void *, __CPROVER_size_t); + +int main() +{ + int x; + memcmp(&x, &x, sizeof x); // safe + memcmp(&x, &x, (sizeof x) + 1); // unsafe +} diff --git a/regression/cprover/large_step/safety/memcmp1.desc b/regression/cprover/large_step/safety/memcmp1.desc new file mode 100644 index 00000000000..678ac6b7e0e --- /dev/null +++ b/regression/cprover/large_step/safety/memcmp1.desc @@ -0,0 +1,8 @@ +CORE +memcmp1.c +--safety +^EXIT=10$ +^SIGNAL=0$ +^\[main\.memcmp\.1\] line \d+ memcmp regions must be valid: SUCCESS$ +^\[main\.memcmp\.2\] line \d+ memcmp regions must be valid: REFUTED$ +-- diff --git a/regression/cprover/large_step/safety/memset1.c b/regression/cprover/large_step/safety/memset1.c new file mode 100644 index 00000000000..b83a47c1909 --- /dev/null +++ b/regression/cprover/large_step/safety/memset1.c @@ -0,0 +1,8 @@ +void *memset(void *, int, __CPROVER_size_t); + +int main() +{ + int x; + memset(&x, 0, sizeof x); // safe + memset(&x, 0, (sizeof x) + 1); // unsafe +} diff --git a/regression/cprover/large_step/safety/memset1.desc b/regression/cprover/large_step/safety/memset1.desc new file mode 100644 index 00000000000..a5dcccdf744 --- /dev/null +++ b/regression/cprover/large_step/safety/memset1.desc @@ -0,0 +1,8 @@ +CORE +memset1.c +--safety +^EXIT=10$ +^SIGNAL=0$ +^\[main\.memset\.1\] line \d+ memset destination must be valid: SUCCESS$ +^\[main\.memset\.2\] line \d+ memset destination must be valid: REFUTED$ +-- diff --git a/regression/cprover/large_step/safety/memset2.c b/regression/cprover/large_step/safety/memset2.c new file mode 100644 index 00000000000..d4fd8390e25 --- /dev/null +++ b/regression/cprover/large_step/safety/memset2.c @@ -0,0 +1,8 @@ +#include + +int main() +{ + int x; + memset(&x, 0, sizeof x); // safe + memset(&x, 0, (sizeof x) + 1); // unsafe +} diff --git a/regression/cprover/large_step/safety/memset2.desc b/regression/cprover/large_step/safety/memset2.desc new file mode 100644 index 00000000000..ab99b8dccef --- /dev/null +++ b/regression/cprover/large_step/safety/memset2.desc @@ -0,0 +1,8 @@ +CORE +memset2.c +--safety +^EXIT=10$ +^SIGNAL=0$ +^\[main\.memset\.1\] line \d+ memset destination must be valid: SUCCESS$ +^\[main\.memset\.2\] line \d+ memset destination must be valid: REFUTED$ +-- diff --git a/regression/cprover/large_step/safety/null_dereference1.c b/regression/cprover/large_step/safety/null_dereference1.c new file mode 100644 index 00000000000..a2cbd729210 --- /dev/null +++ b/regression/cprover/large_step/safety/null_dereference1.c @@ -0,0 +1,6 @@ +int main() +{ + int *p = 0; + + int x = *p; // unsafe +} diff --git a/regression/cprover/large_step/safety/null_dereference1.desc b/regression/cprover/large_step/safety/null_dereference1.desc new file mode 100644 index 00000000000..2e5a3d9e360 --- /dev/null +++ b/regression/cprover/large_step/safety/null_dereference1.desc @@ -0,0 +1,7 @@ +CORE +null_dereference1.c +--safety +^EXIT=10$ +^SIGNAL=0$ +^\[main\.pointer\.1\] line \d+ pointer p safe: REFUTED$ +-- diff --git a/regression/cprover/large_step/safety/null_object1.c b/regression/cprover/large_step/safety/null_object1.c new file mode 100644 index 00000000000..83659515c0c --- /dev/null +++ b/regression/cprover/large_step/safety/null_object1.c @@ -0,0 +1,6 @@ +int main() +{ + int *p = 0; + p++; // still 'null object' + int x = *p; // unsafe +} diff --git a/regression/cprover/large_step/safety/null_object1.desc b/regression/cprover/large_step/safety/null_object1.desc new file mode 100644 index 00000000000..2fda5d3de6f --- /dev/null +++ b/regression/cprover/large_step/safety/null_object1.desc @@ -0,0 +1,7 @@ +CORE +null_object1.c +--safety +^EXIT=10$ +^SIGNAL=0$ +^\[main\.pointer\.1\] line \d+ pointer p safe: REFUTED$ +-- diff --git a/regression/cprover/large_step/safety/object_size1.c b/regression/cprover/large_step/safety/object_size1.c new file mode 100644 index 00000000000..93a3a4db63c --- /dev/null +++ b/regression/cprover/large_step/safety/object_size1.c @@ -0,0 +1,12 @@ +int main() +{ + char *p, *q; + // functional consistency of object_size + __CPROVER_assume(p == q); + + __CPROVER_assert( + __CPROVER_OBJECT_SIZE(p) == __CPROVER_OBJECT_SIZE(q), "property 1"); + + __CPROVER_assert( + __CPROVER_OBJECT_SIZE(p) == __CPROVER_OBJECT_SIZE(q + 1), "property 2"); +} diff --git a/regression/cprover/large_step/safety/object_size1.desc b/regression/cprover/large_step/safety/object_size1.desc new file mode 100644 index 00000000000..7b9f30e1274 --- /dev/null +++ b/regression/cprover/large_step/safety/object_size1.desc @@ -0,0 +1,8 @@ +CORE +object_size1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$ +-- diff --git a/regression/cprover/large_step/safety/pointer_to_pointer1.c b/regression/cprover/large_step/safety/pointer_to_pointer1.c new file mode 100644 index 00000000000..b9a8fd845e0 --- /dev/null +++ b/regression/cprover/large_step/safety/pointer_to_pointer1.c @@ -0,0 +1,13 @@ +#include + +int *p, *q; +void **p_ptr; + +int main() +{ + p = malloc(1); + p_ptr = &p; + q = malloc(2); + free(*p_ptr); + return 0; +} diff --git a/regression/cprover/large_step/safety/pointer_to_pointer1.desc b/regression/cprover/large_step/safety/pointer_to_pointer1.desc new file mode 100644 index 00000000000..69955ac40e0 --- /dev/null +++ b/regression/cprover/large_step/safety/pointer_to_pointer1.desc @@ -0,0 +1,8 @@ +CORE +pointer_to_pointer1.c +--safety +^EXIT=0$ +^SIGNAL=0$ +^\[main\.pointer\.1\] line \d+ pointer p_ptr safe: SUCCESS$ +^\[main\.free\.1\] line \d+ free argument must be valid dynamic object: SUCCESS$ +-- diff --git a/regression/cprover/large_step/safety/r_ok1.c b/regression/cprover/large_step/safety/r_ok1.c new file mode 100644 index 00000000000..5a260e3bea0 --- /dev/null +++ b/regression/cprover/large_step/safety/r_ok1.c @@ -0,0 +1,9 @@ +int main() +{ + int *p; + __CPROVER_assume(__CPROVER_r_ok(p)); + *p; // safe + *(p + 1); // unsafe + + return 0; +} diff --git a/regression/cprover/large_step/safety/r_ok1.desc b/regression/cprover/large_step/safety/r_ok1.desc new file mode 100644 index 00000000000..ca4129b3898 --- /dev/null +++ b/regression/cprover/large_step/safety/r_ok1.desc @@ -0,0 +1,8 @@ +CORE +r_ok1.c +--safety +^EXIT=10$ +^SIGNAL=0$ +^\[main\.pointer\.1\] line \d+ pointer p safe: SUCCESS$ +^\[main\.pointer\.2\] line \d+ pointer .* safe: REFUTED$ +-- diff --git a/regression/cprover/large_step/safety/r_ok2.c b/regression/cprover/large_step/safety/r_ok2.c new file mode 100644 index 00000000000..1e26a9eaded --- /dev/null +++ b/regression/cprover/large_step/safety/r_ok2.c @@ -0,0 +1,26 @@ +void int_assignment(int *p) __CPROVER_requires(__CPROVER_r_ok(p)) +{ + *p; // safe + + int i = 123; // unrelated assignment + + *p; // still safe +} + +void int_pointer_assignment(int *p) __CPROVER_requires(__CPROVER_r_ok(p)) +{ + *p; // safe + + int *q = p; // unrelated assignment + + *p; // still safe +} + +void pointer_assignment(int *p) __CPROVER_requires(__CPROVER_r_ok(p)) +{ + *p; // safe + + p = 0; // wreck it + + *p; // not safe +} diff --git a/regression/cprover/large_step/safety/r_ok2.desc b/regression/cprover/large_step/safety/r_ok2.desc new file mode 100644 index 00000000000..7da360c6ff3 --- /dev/null +++ b/regression/cprover/large_step/safety/r_ok2.desc @@ -0,0 +1,12 @@ +CORE +r_ok2.c +--safety +^EXIT=10$ +^SIGNAL=0$ +^\[int_assignment\.pointer\.1\] line \d+ pointer p safe: SUCCESS$ +^\[int_assignment\.pointer\.2\] line \d+ pointer p safe: SUCCESS$ +^\[int_pointer_assignment\.pointer\.1\] line \d+ pointer p safe: SUCCESS$ +^\[int_pointer_assignment\.pointer\.2\] line \d+ pointer p safe: SUCCESS$ +^\[pointer_assignment\.pointer\.1\] line \d+ pointer p safe: SUCCESS$ +^\[pointer_assignment\.pointer\.2\] line \d+ pointer p safe: REFUTED$ +-- diff --git a/regression/cprover/large_step/safety/r_ok3.c b/regression/cprover/large_step/safety/r_ok3.c new file mode 100644 index 00000000000..e2102820d06 --- /dev/null +++ b/regression/cprover/large_step/safety/r_ok3.c @@ -0,0 +1,13 @@ +#include + +int main() +{ + int x; + int *p = malloc(sizeof(int)); + + __CPROVER_assert(__CPROVER_r_ok(&x), "&x ok to read"); + __CPROVER_assert(__CPROVER_r_ok("foo", 4), "string literal ok to read"); + __CPROVER_assert(__CPROVER_r_ok(p), "p ok to read"); + + return 0; +} diff --git a/regression/cprover/large_step/safety/r_ok3.desc b/regression/cprover/large_step/safety/r_ok3.desc new file mode 100644 index 00000000000..a691591baf0 --- /dev/null +++ b/regression/cprover/large_step/safety/r_ok3.desc @@ -0,0 +1,9 @@ +CORE +r_ok3.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ &x ok to read: SUCCESS$ +^\[main\.assertion\.2\] line \d+ string literal ok to read: SUCCESS$ +^\[main\.assertion\.3\] line \d+ p ok to read: SUCCESS$ +-- diff --git a/regression/cprover/large_step/safety/r_ok4.c b/regression/cprover/large_step/safety/r_ok4.c new file mode 100644 index 00000000000..79f0c3a219c --- /dev/null +++ b/regression/cprover/large_step/safety/r_ok4.c @@ -0,0 +1,8 @@ +int main() +{ + int *p; + __CPROVER_assume(__CPROVER_r_ok(p)); + __CPROVER_assert(p != 0, "p is not null"); + + return 0; +} diff --git a/regression/cprover/large_step/safety/r_ok4.desc b/regression/cprover/large_step/safety/r_ok4.desc new file mode 100644 index 00000000000..30251465ac4 --- /dev/null +++ b/regression/cprover/large_step/safety/r_ok4.desc @@ -0,0 +1,7 @@ +CORE +r_ok4.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ p is not null: SUCCESS$ +-- diff --git a/regression/cprover/large_step/safety/r_ok5.c b/regression/cprover/large_step/safety/r_ok5.c new file mode 100644 index 00000000000..b13e0e7a3f1 --- /dev/null +++ b/regression/cprover/large_step/safety/r_ok5.c @@ -0,0 +1,7 @@ +int x; + +int main() +{ + __CPROVER_assert(__CPROVER_r_ok(&x), "property 1"); + return 0; +} diff --git a/regression/cprover/large_step/safety/r_ok5.desc b/regression/cprover/large_step/safety/r_ok5.desc new file mode 100644 index 00000000000..cf9e18f0df4 --- /dev/null +++ b/regression/cprover/large_step/safety/r_ok5.desc @@ -0,0 +1,7 @@ +CORE +r_ok5.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/safety/r_ok6.c b/regression/cprover/large_step/safety/r_ok6.c new file mode 100644 index 00000000000..869727b3c2d --- /dev/null +++ b/regression/cprover/large_step/safety/r_ok6.c @@ -0,0 +1,9 @@ +int main() +{ + const __CPROVER_size_t array_len; + const unsigned char *array_bytes; + + __CPROVER_assume(array_len >= 1); + __CPROVER_assume(__CPROVER_r_ok(array_bytes, array_len)); + __CPROVER_assert(__CPROVER_r_ok(array_bytes, 1), "property 1"); +} diff --git a/regression/cprover/large_step/safety/r_ok6.desc b/regression/cprover/large_step/safety/r_ok6.desc new file mode 100644 index 00000000000..6027f60122e --- /dev/null +++ b/regression/cprover/large_step/safety/r_ok6.desc @@ -0,0 +1,7 @@ +CORE +r_ok6.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/safety/r_ok7.c b/regression/cprover/large_step/safety/r_ok7.c new file mode 100644 index 00000000000..4cf9ac6c554 --- /dev/null +++ b/regression/cprover/large_step/safety/r_ok7.c @@ -0,0 +1,10 @@ +int main() +{ + const __CPROVER_size_t array_len, i; + const unsigned char *array_bytes; + + __CPROVER_assume(i < array_len); + __CPROVER_assume(__CPROVER_POINTER_OFFSET(array_bytes) == 0); + __CPROVER_assume(__CPROVER_r_ok(array_bytes, array_len)); + __CPROVER_assert(__CPROVER_r_ok(array_bytes + i, 1), "property 1"); +} diff --git a/regression/cprover/large_step/safety/r_ok7.desc b/regression/cprover/large_step/safety/r_ok7.desc new file mode 100644 index 00000000000..8be2b681854 --- /dev/null +++ b/regression/cprover/large_step/safety/r_ok7.desc @@ -0,0 +1,7 @@ +CORE +r_ok7.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/safety/r_ok8.c b/regression/cprover/large_step/safety/r_ok8.c new file mode 100644 index 00000000000..732ed5f1193 --- /dev/null +++ b/regression/cprover/large_step/safety/r_ok8.c @@ -0,0 +1,9 @@ +char ch; + +int main() +{ + __CPROVER_assert(__CPROVER_r_ok(&ch, 1), "property 1"); // passes + __CPROVER_assert(__CPROVER_r_ok(&ch + 1, 1), "property 2"); // fails + __CPROVER_assert(__CPROVER_r_ok(&ch + 1, 0), "property 3"); // passes + __CPROVER_assert(__CPROVER_r_ok(&ch + 2, 0), "property 4"); // fails +} diff --git a/regression/cprover/large_step/safety/r_ok8.desc b/regression/cprover/large_step/safety/r_ok8.desc new file mode 100644 index 00000000000..58e4cf52f65 --- /dev/null +++ b/regression/cprover/large_step/safety/r_ok8.desc @@ -0,0 +1,10 @@ +CORE +r_ok8.c + +^EXIT=10$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: REFUTED$ +^\[main\.assertion\.3\] line \d+ property 3: SUCCESS$ +^\[main\.assertion\.4\] line \d+ property 4: REFUTED$ +-- diff --git a/regression/cprover/large_step/safety/r_ok_is_function1.c b/regression/cprover/large_step/safety/r_ok_is_function1.c new file mode 100644 index 00000000000..2b8697a7f61 --- /dev/null +++ b/regression/cprover/large_step/safety/r_ok_is_function1.c @@ -0,0 +1,10 @@ +int main() +{ + int *p, *q; + + if(p == q) + __CPROVER_assert( + __CPROVER_r_ok(p, 1) == __CPROVER_r_ok(q, 1), "property 1"); + + return 0; +} diff --git a/regression/cprover/large_step/safety/r_ok_is_function1.desc b/regression/cprover/large_step/safety/r_ok_is_function1.desc new file mode 100644 index 00000000000..fe1a07e592c --- /dev/null +++ b/regression/cprover/large_step/safety/r_ok_is_function1.desc @@ -0,0 +1,7 @@ +CORE +r_ok_is_function1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/safety/realloc1.c b/regression/cprover/large_step/safety/realloc1.c new file mode 100644 index 00000000000..4e4df0e04d6 --- /dev/null +++ b/regression/cprover/large_step/safety/realloc1.c @@ -0,0 +1,13 @@ +void *malloc(__CPROVER_size_t); +void *realloc(void *, __CPROVER_size_t); +void free(void *); + +int main() +{ + int *p = malloc(sizeof(int)); + int *q = realloc(p, sizeof(int) * 2); + __CPROVER_assert(__CPROVER_LIVE_OBJECT(q), "property 1"); // passes + __CPROVER_assert( + __CPROVER_OBJECT_SIZE(q) == sizeof(int) * 2, "property 2"); // passes + free(p); +} diff --git a/regression/cprover/large_step/safety/realloc1.desc b/regression/cprover/large_step/safety/realloc1.desc new file mode 100644 index 00000000000..e1b11e8c159 --- /dev/null +++ b/regression/cprover/large_step/safety/realloc1.desc @@ -0,0 +1,10 @@ +CORE +realloc1.c +--safety +^EXIT=0$ +^SIGNAL=0$ +^\[main\.realloc\.1\] line \d+ realloc argument must be valid dynamic object: SUCCESS$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$ +^\[main\.free\.1\] line \d+ free argument must be valid dynamic object: SUCCESS$ +-- diff --git a/regression/cprover/large_step/safety/realloc2.c b/regression/cprover/large_step/safety/realloc2.c new file mode 100644 index 00000000000..3f22f9196ab --- /dev/null +++ b/regression/cprover/large_step/safety/realloc2.c @@ -0,0 +1,9 @@ +void *malloc(__CPROVER_size_t); +void *realloc(void *, __CPROVER_size_t); + +int main() +{ + int *p = malloc(sizeof(int)); + p++; + int *q = realloc(p, sizeof(int) * 2); // fails, offset not zero +} diff --git a/regression/cprover/large_step/safety/realloc2.desc b/regression/cprover/large_step/safety/realloc2.desc new file mode 100644 index 00000000000..da8fedb42b9 --- /dev/null +++ b/regression/cprover/large_step/safety/realloc2.desc @@ -0,0 +1,7 @@ +CORE +realloc2.c +--safety +^EXIT=10$ +^SIGNAL=0$ +^\[main\.realloc\.1\] line \d+ realloc argument must be valid dynamic object: REFUTED$ +-- diff --git a/regression/cprover/large_step/safety/shifts1.c b/regression/cprover/large_step/safety/shifts1.c new file mode 100644 index 00000000000..0254f2e4ef8 --- /dev/null +++ b/regression/cprover/large_step/safety/shifts1.c @@ -0,0 +1,9 @@ +int main() +{ + 1 << 1; // safe + 1 << -1; // unsafe, shift distance negative + 1 >> -1; // unsafe, shift distance negative + 1 << (sizeof(1) * 8); // unsafe, shift distance too large + 1 << (sizeof(1) * 8 - 2); // safe + 1u << (sizeof(1u) * 8 - 1); // safe +} diff --git a/regression/cprover/large_step/safety/shifts1.desc b/regression/cprover/large_step/safety/shifts1.desc new file mode 100644 index 00000000000..4429b6a35ee --- /dev/null +++ b/regression/cprover/large_step/safety/shifts1.desc @@ -0,0 +1,9 @@ +KNOWNBUG +shifts1.c +--safety +^EXIT=10$ +^SIGNAL=0$ +^\[main\.undefined-shift\.3\] line \d+ shift distance is negative in 1 << -1: REFUTED$ +^\[main\.undefined-shift\.6\] line \d+ shift distance is negative in 1 >> -1: REFUTED$ +^\[main\.undefined-shift\.8\] line \d+ shift distance too large in 1 << sizeof.*: REFUTED$ +-- diff --git a/regression/cprover/large_step/safety/simple_equality1.c b/regression/cprover/large_step/safety/simple_equality1.c new file mode 100644 index 00000000000..bfb69aeb8ab --- /dev/null +++ b/regression/cprover/large_step/safety/simple_equality1.c @@ -0,0 +1,9 @@ +int main() +{ + int x, *p; + p = &x; + *p; // ok + p++; + *p; // not ok, out of bounds + return 0; +} diff --git a/regression/cprover/large_step/safety/simple_equality1.desc b/regression/cprover/large_step/safety/simple_equality1.desc new file mode 100644 index 00000000000..a4ab94d561a --- /dev/null +++ b/regression/cprover/large_step/safety/simple_equality1.desc @@ -0,0 +1,8 @@ +CORE +simple_equality1.c +--safety +^EXIT=10$ +^SIGNAL=0$ +^\[main\.pointer\.1\] line \d+ pointer p safe: SUCCESS$ +^\[main\.pointer\.2\] line \d+ pointer p safe: REFUTED$ +-- diff --git a/regression/cprover/large_step/safety/use_after_free1.c b/regression/cprover/large_step/safety/use_after_free1.c new file mode 100644 index 00000000000..d6776289d3c --- /dev/null +++ b/regression/cprover/large_step/safety/use_after_free1.c @@ -0,0 +1,9 @@ +#include + +int main() +{ + int *p = malloc(sizeof(int)); + int x = *p; // safe + free(p); + int y = *p; // unsafe +} diff --git a/regression/cprover/large_step/safety/use_after_free1.desc b/regression/cprover/large_step/safety/use_after_free1.desc new file mode 100644 index 00000000000..e6cd066a3cd --- /dev/null +++ b/regression/cprover/large_step/safety/use_after_free1.desc @@ -0,0 +1,8 @@ +CORE +use_after_free1.c +--text --inline --no-safety +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state . S11\(ς\) ⇒ S12\(ς\[❝main::\$tmp::return_value_malloc❞:=allocate\(ς, 4\)\]\)$ +^\(\d+\) ∀ ς : state . S16\(ς\) ⇒ S17\(deallocate_state\(ς, cast\(ς\(❝main::1::p❞\), empty\*\)\)\)$ +-- diff --git a/regression/cprover/large_step/safety/writeable1.c b/regression/cprover/large_step/safety/writeable1.c new file mode 100644 index 00000000000..4460b619363 --- /dev/null +++ b/regression/cprover/large_step/safety/writeable1.c @@ -0,0 +1,14 @@ +const int months = 12; +int x; + +void *malloc(__CPROVER_size_t); + +int main() +{ + __CPROVER_assert(__CPROVER_WRITEABLE_OBJECT(&x), "property 1"); // holds + __CPROVER_assert(!__CPROVER_WRITEABLE_OBJECT(&months), "property 2"); // holds + __CPROVER_assert( + !__CPROVER_WRITEABLE_OBJECT("foobar"), "property 3"); // holds + __CPROVER_assert( + __CPROVER_WRITEABLE_OBJECT(malloc(1)), "property 1"); // holds +} diff --git a/regression/cprover/large_step/safety/writeable1.desc b/regression/cprover/large_step/safety/writeable1.desc new file mode 100644 index 00000000000..04aa8aafa26 --- /dev/null +++ b/regression/cprover/large_step/safety/writeable1.desc @@ -0,0 +1,9 @@ +CORE +writeable1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$ +^\[main\.assertion\.3\] line \d+ property 3: SUCCESS$ +-- diff --git a/regression/cprover/large_step/structs/nondet_struct1.c b/regression/cprover/large_step/structs/nondet_struct1.c new file mode 100644 index 00000000000..86cb847307c --- /dev/null +++ b/regression/cprover/large_step/structs/nondet_struct1.c @@ -0,0 +1,12 @@ +struct S +{ + int x, y; +} s; + +struct S nondet_S(); + +int main() +{ + s = nondet_S(); + return 0; +} diff --git a/regression/cprover/large_step/structs/nondet_struct1.desc b/regression/cprover/large_step/structs/nondet_struct1.desc new file mode 100644 index 00000000000..a8fa2b39dc7 --- /dev/null +++ b/regression/cprover/large_step/structs/nondet_struct1.desc @@ -0,0 +1,7 @@ +CORE +nondet_struct1.c +--text --inline +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state, nondet::S11-0 : signedbv\[32\], nondet::S11-1 : signedbv\[32\] \. S10\(ς\) ⇒ S11\(ς\[❝s❞\.❝x❞:=nondet::S11-0\]\[❝s❞\.❝y❞:=nondet::S11-1\]\)$ +-- diff --git a/regression/cprover/large_step/structs/struct1.c b/regression/cprover/large_step/structs/struct1.c new file mode 100644 index 00000000000..0703c045632 --- /dev/null +++ b/regression/cprover/large_step/structs/struct1.c @@ -0,0 +1,10 @@ +struct S +{ + int x, y; +} s; + +int main() +{ + s.x = 1; + __CPROVER_assert(s.x == 1, "property 1"); +} diff --git a/regression/cprover/large_step/structs/struct1.desc b/regression/cprover/large_step/structs/struct1.desc new file mode 100644 index 00000000000..042328e9bb5 --- /dev/null +++ b/regression/cprover/large_step/structs/struct1.desc @@ -0,0 +1,9 @@ +CORE +struct1.c +--text --solve --inline +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S10\(ς\) ⇒ S11\(ς\[❝s❞.❝x❞:=1\]\)$ +^\(\d+\) ∀ ς : state \. S11\(ς\) ⇒ \(ς\(❝s❞.❝x❞\) = 1\)$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/structs/struct2.c b/regression/cprover/large_step/structs/struct2.c new file mode 100644 index 00000000000..e47da2dc124 --- /dev/null +++ b/regression/cprover/large_step/structs/struct2.c @@ -0,0 +1,12 @@ +struct S +{ + int x, y; +} s; + +int main() +{ + s.x = 1; + s.y = 2; + __CPROVER_assert(s.x == 1, "property 1"); + __CPROVER_assert(s.y == 2, "property 2"); +} diff --git a/regression/cprover/large_step/structs/struct2.desc b/regression/cprover/large_step/structs/struct2.desc new file mode 100644 index 00000000000..a470f44c4e5 --- /dev/null +++ b/regression/cprover/large_step/structs/struct2.desc @@ -0,0 +1,12 @@ +CORE +struct2.c +--text --solve --inline +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S10\(ς\) ⇒ S11\(ς\[❝s❞.❝x❞:=1\]\)$ +^\(\d+\) ∀ ς : state \. S11\(ς\) ⇒ S12\(ς\[❝s❞.❝y❞:=2\]\)$ +^\(\d+\) ∀ ς : state \. S12\(ς\) ⇒ \(ς\(❝s❞.❝x❞\) = 1\)$ +^\(\d+\) ∀ ς : state \. S13\(ς\) ⇒ \(ς\(❝s❞.❝y❞\) = 2\)$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$ +-- diff --git a/regression/cprover/large_step/structs/struct3.c b/regression/cprover/large_step/structs/struct3.c new file mode 100644 index 00000000000..9ec1471ef52 --- /dev/null +++ b/regression/cprover/large_step/structs/struct3.c @@ -0,0 +1,14 @@ +struct S +{ + int x, y; +} a, b; + +int main() +{ + a.x = 1; + b = a; // copy entire struct + __CPROVER_assert(a.x == 1, "property 1"); // should pass + __CPROVER_assert(b.x == 1, "property 2"); // should pass + __CPROVER_assert(b.y == a.y, "property 3"); // should pass + return 0; +} diff --git a/regression/cprover/large_step/structs/struct3.desc b/regression/cprover/large_step/structs/struct3.desc new file mode 100644 index 00000000000..53c4bbe1395 --- /dev/null +++ b/regression/cprover/large_step/structs/struct3.desc @@ -0,0 +1,10 @@ +CORE +struct3.c +--text --solve --inline +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S\d+\(ς\) ⇒ S\d+\(ς\[❝b❞\.❝x❞:=ς\(❝a❞\.❝x❞\)\]\[❝b❞\.❝y❞:=ς\(❝a❞\.❝y❞\)\]\)$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$ +^\[main\.assertion\.3\] line \d+ property 3: SUCCESS$ +-- diff --git a/regression/cprover/large_step/structs/struct4.c b/regression/cprover/large_step/structs/struct4.c new file mode 100644 index 00000000000..d22730de2a5 --- /dev/null +++ b/regression/cprover/large_step/structs/struct4.c @@ -0,0 +1,11 @@ +struct S +{ + int x, y; +} a = {.x = 10, .y = 20}; + +int main() +{ + __CPROVER_assert(a.x == 10, "property 1"); // should pass + __CPROVER_assert(a.y == 20, "property 2"); // should pass + return 0; +} diff --git a/regression/cprover/large_step/structs/struct4.desc b/regression/cprover/large_step/structs/struct4.desc new file mode 100644 index 00000000000..6f6a1b31556 --- /dev/null +++ b/regression/cprover/large_step/structs/struct4.desc @@ -0,0 +1,9 @@ +CORE +struct4.c +--text --solve --inline +^EXIT=0$ +^SIGNAL=0$ +^\(\d+\) ∀ ς : state \. S\d+\(ς\) ⇒ S\d+\(ς\[❝a❞\.❝x❞:=10\]\[❝a❞\.❝y❞:=20\]\)$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$ +-- diff --git a/regression/cprover/large_step/structs/struct5.c b/regression/cprover/large_step/structs/struct5.c new file mode 100644 index 00000000000..0cf1104e157 --- /dev/null +++ b/regression/cprover/large_step/structs/struct5.c @@ -0,0 +1,14 @@ +struct S +{ + int x, y; +} a, b; + +int main() +{ + a.x = 1; + a.y = 2; + b.x = 1; + b.y = 2; + __CPROVER_assert(a == b, "property 1"); // should pass + return 0; +} diff --git a/regression/cprover/large_step/structs/struct5.desc b/regression/cprover/large_step/structs/struct5.desc new file mode 100644 index 00000000000..497c967c620 --- /dev/null +++ b/regression/cprover/large_step/structs/struct5.desc @@ -0,0 +1,7 @@ +CORE +struct5.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- diff --git a/regression/cprover/large_step/trace/trace1.c b/regression/cprover/large_step/trace/trace1.c new file mode 100644 index 00000000000..8f9cb492fd6 --- /dev/null +++ b/regression/cprover/large_step/trace/trace1.c @@ -0,0 +1,12 @@ +int main() +{ + int x, y; + + y = 0; + + if(x > y) + { + x++; + __CPROVER_assert(x > y, "property 1"); // fails + } +} diff --git a/regression/cprover/large_step/trace/trace1.desc b/regression/cprover/large_step/trace/trace1.desc new file mode 100644 index 00000000000..0405165c60d --- /dev/null +++ b/regression/cprover/large_step/trace/trace1.desc @@ -0,0 +1,10 @@ +KNOWNBUG +trace1.c +--trace +^EXIT=10$ +^SIGNAL=0$ +^Trace for main\.assertion\.1:$ +^ 3 main::1::x := 2147483647$ +^ 5 main::1::y := 0$ +^ 9 main::1::x := -2147483648$ +-- diff --git a/regression/cprover/large_step/trace/trace3.c b/regression/cprover/large_step/trace/trace3.c new file mode 100644 index 00000000000..2ce40d3a12c --- /dev/null +++ b/regression/cprover/large_step/trace/trace3.c @@ -0,0 +1,10 @@ +int x, y; + +int main() +{ + x = 1; + y = 2; + x = 3; + __CPROVER_assert(0, "property 1"); + return 0; +} diff --git a/regression/cprover/large_step/trace/trace3.desc b/regression/cprover/large_step/trace/trace3.desc new file mode 100644 index 00000000000..35dbd4137d1 --- /dev/null +++ b/regression/cprover/large_step/trace/trace3.desc @@ -0,0 +1,8 @@ +CORE +trace3.c +--trace +^EXIT=10$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: REFUTED$ +^Trace for main\.assertion\.1:$ +-- diff --git a/regression/cprover/large_step/trace/trace_array1.c b/regression/cprover/large_step/trace/trace_array1.c new file mode 100644 index 00000000000..ba19992ade4 --- /dev/null +++ b/regression/cprover/large_step/trace/trace_array1.c @@ -0,0 +1,18 @@ +struct S +{ + int a, b, c; +} x; + +__CPROVER_size_t i = 3; + +int array[10]; + +int main() +{ + x.a = 123; + x.b = x.a; + array[1] = 10; + array[2] = 20; + array[i] = 30; + __CPROVER_assert(0, "property 1"); +} diff --git a/regression/cprover/large_step/trace/trace_array1.desc b/regression/cprover/large_step/trace/trace_array1.desc new file mode 100644 index 00000000000..abba80c7aeb --- /dev/null +++ b/regression/cprover/large_step/trace/trace_array1.desc @@ -0,0 +1,14 @@ +KNOWNBUG +trace_array1.c +--trace +^EXIT=10$ +^SIGNAL=0$ +^Trace for main\.assertion\.1:$ +^ 8 array\[9\] := 0$ +^ 4 x.c := 0$ +^ 12 x.a := 123$ +^ 13 x.b := 123$ +^ 14 array\[1\] := 10$ +^ 15 array\[2\] := 20$ +^ 16 array\[3\] := 30$ +-- diff --git a/regression/cprover/large_step/trace/trace_contract1.c b/regression/cprover/large_step/trace/trace_contract1.c new file mode 100644 index 00000000000..df6d091df1b --- /dev/null +++ b/regression/cprover/large_step/trace/trace_contract1.c @@ -0,0 +1,7 @@ +int my_function(int parameter) + // clang-format off + __CPROVER_ensures(__CPROVER_return_value == 123) +// clang-format on +{ + return parameter; +} diff --git a/regression/cprover/large_step/trace/trace_contract1.desc b/regression/cprover/large_step/trace/trace_contract1.desc new file mode 100644 index 00000000000..e98dc997809 --- /dev/null +++ b/regression/cprover/large_step/trace/trace_contract1.desc @@ -0,0 +1,8 @@ +CORE +trace_contract1.c +--trace +^EXIT=10$ +^SIGNAL=0$ +^Trace for my_function\.postcondition\.1:$ +^ \d+ return_value := ς\(❝my_function::parameter❞\)$ +-- diff --git a/regression/cprover/large_step/trace/trace_function_call1.c b/regression/cprover/large_step/trace/trace_function_call1.c new file mode 100644 index 00000000000..955a3566574 --- /dev/null +++ b/regression/cprover/large_step/trace/trace_function_call1.c @@ -0,0 +1,11 @@ +int foo(int parameter) +{ + return parameter + 1; +} + +int main() +{ + int x; + x = foo(123); + __CPROVER_assert(0, "property 1"); +} diff --git a/regression/cprover/large_step/trace/trace_function_call1.desc b/regression/cprover/large_step/trace/trace_function_call1.desc new file mode 100644 index 00000000000..fce1188a337 --- /dev/null +++ b/regression/cprover/large_step/trace/trace_function_call1.desc @@ -0,0 +1,10 @@ +KNOWNBUG +trace_function_call1.c +--trace +^EXIT=10$ +^SIGNAL=0$ +^Trace for main\.assertion\.1:$ +^ 9 foo::parameter := 123$ +^ 3 return_value := 124$ +^ 9 main::1::x := 124$ +-- diff --git a/regression/cprover/large_step/trace/trace_malloc1.c b/regression/cprover/large_step/trace/trace_malloc1.c new file mode 100644 index 00000000000..7b9592c1f21 --- /dev/null +++ b/regression/cprover/large_step/trace/trace_malloc1.c @@ -0,0 +1,11 @@ +#include + +int main() +{ + int *p = malloc(sizeof(int) * 1000); + + p[10] = 1; + p[20] = 2; + + __CPROVER_assert(0, "property 1"); +} diff --git a/regression/cprover/large_step/trace/trace_malloc1.desc b/regression/cprover/large_step/trace/trace_malloc1.desc new file mode 100644 index 00000000000..325f64e6555 --- /dev/null +++ b/regression/cprover/large_step/trace/trace_malloc1.desc @@ -0,0 +1,11 @@ +KNOWNBUG +trace_malloc1.c +--trace +^EXIT=10$ +^SIGNAL=0$ +^Trace for main\.assertion\.1:$ +^ 5 main::\$tmp::return_value_malloc := address_of\(heap-1\)$ +^ 5 main::1::p := cast\(❝heap-1❞, signedbv\[32\]\*\)$ +^ 7 \[cast\(❝heap-1❞, signedbv\[32\]\*\) \+ 10\] := 1$ +^ 8 \[cast\(❝heap-1❞, signedbv\[32\]\*\) \+ 20\] := 2$ +-- diff --git a/regression/cprover/large_step/trace/trace_malloc2.c b/regression/cprover/large_step/trace/trace_malloc2.c new file mode 100644 index 00000000000..eb97645c98e --- /dev/null +++ b/regression/cprover/large_step/trace/trace_malloc2.c @@ -0,0 +1,11 @@ +#include + +int main() +{ + int *p = malloc(sizeof(int) * 1000); + + p[10] = 1; + p[10]++; + + __CPROVER_assert(0, "property 1"); +} diff --git a/regression/cprover/large_step/trace/trace_malloc2.desc b/regression/cprover/large_step/trace/trace_malloc2.desc new file mode 100644 index 00000000000..bc46bece1ab --- /dev/null +++ b/regression/cprover/large_step/trace/trace_malloc2.desc @@ -0,0 +1,9 @@ +KNOWNBUG +trace_malloc2.c +--trace +^EXIT=10$ +^SIGNAL=0$ +^Trace for main\.assertion\.1:$ +^ 7 \[cast\(❝heap-1❞, signedbv\[32\]\*\) \+ 10\] := 1$ +^ 8 \[cast\(❝heap-1❞, signedbv\[32\]\*\) \+ 10\] := 2$ +-- diff --git a/regression/cprover/large_step/trace/trace_nondet1.c b/regression/cprover/large_step/trace/trace_nondet1.c new file mode 100644 index 00000000000..bd22ed59394 --- /dev/null +++ b/regression/cprover/large_step/trace/trace_nondet1.c @@ -0,0 +1,8 @@ +int nondet_int(); +int x; + +int main() +{ + x = nondet_int(); + __CPROVER_assert(x != 20, "property 1"); // fails +} diff --git a/regression/cprover/large_step/trace/trace_nondet1.desc b/regression/cprover/large_step/trace/trace_nondet1.desc new file mode 100644 index 00000000000..52670170a44 --- /dev/null +++ b/regression/cprover/large_step/trace/trace_nondet1.desc @@ -0,0 +1,8 @@ +KNOWNBUG +trace_nondet1.c +--trace +^EXIT=10$ +^SIGNAL=0$ +^Trace for main\.assertion\.1:$ +^ 6 x := 20$ +-- diff --git a/regression/cprover/large_step/trace/trace_pointer1.c b/regression/cprover/large_step/trace/trace_pointer1.c new file mode 100644 index 00000000000..46609bbe59f --- /dev/null +++ b/regression/cprover/large_step/trace/trace_pointer1.c @@ -0,0 +1,9 @@ +int global; + +int main() +{ + int *x; + __CPROVER_assume(__CPROVER_w_ok(x)); + *x = 123; + __CPROVER_assert(global == 0, "property 1"); +} diff --git a/regression/cprover/large_step/trace/trace_pointer1.desc b/regression/cprover/large_step/trace/trace_pointer1.desc new file mode 100644 index 00000000000..c6e77ae2e45 --- /dev/null +++ b/regression/cprover/large_step/trace/trace_pointer1.desc @@ -0,0 +1,9 @@ +KNOWNBUG +trace_pointer1.c +--trace +^EXIT=10$ +^SIGNAL=0$ +^Trace for main\.assertion\.1:$ +^ 5 main::1::x := address_of\(global\)$ +^ 7 global := 123$ +-- diff --git a/regression/cprover/large_step/trace/trace_pointer2.c b/regression/cprover/large_step/trace/trace_pointer2.c new file mode 100644 index 00000000000..5df4f8f1a1e --- /dev/null +++ b/regression/cprover/large_step/trace/trace_pointer2.c @@ -0,0 +1,9 @@ +int global; + +int main() +{ + int array[100]; + int *x = array; + *(x + 2) = 123; + __CPROVER_assert(0, "property 1"); +} diff --git a/regression/cprover/large_step/trace/trace_pointer2.desc b/regression/cprover/large_step/trace/trace_pointer2.desc new file mode 100644 index 00000000000..7e0e3207bdd --- /dev/null +++ b/regression/cprover/large_step/trace/trace_pointer2.desc @@ -0,0 +1,9 @@ +KNOWNBUG +trace_pointer2.c +--trace +^EXIT=10$ +^SIGNAL=0$ +^Trace for main\.assertion\.1:$ +^ 6 main::1::x := address_of\(main::1::array\[0\]\)$ +^ 7 main::1::array\[2\] := 123$ +-- diff --git a/regression/cprover/large_step/trace/trace_pointer3.c b/regression/cprover/large_step/trace/trace_pointer3.c new file mode 100644 index 00000000000..d95a519a394 --- /dev/null +++ b/regression/cprover/large_step/trace/trace_pointer3.c @@ -0,0 +1,11 @@ +struct S +{ + int a, b, c; +} x; + +int main() +{ + struct S *p = &x; + p->b = 123; + __CPROVER_assert(0, "property 1"); +} diff --git a/regression/cprover/large_step/trace/trace_pointer3.desc b/regression/cprover/large_step/trace/trace_pointer3.desc new file mode 100644 index 00000000000..aada8acca04 --- /dev/null +++ b/regression/cprover/large_step/trace/trace_pointer3.desc @@ -0,0 +1,9 @@ +KNOWNBUG +trace_pointer3.c +--trace +^EXIT=10$ +^SIGNAL=0$ +^Trace for main\.assertion\.1:$ +^ 8 main::1::p := address_of\(x\)$ +^ 9 x\.b := 123$ +-- diff --git a/regression/cprover/large_step/trace/trace_struct1.c b/regression/cprover/large_step/trace/trace_struct1.c new file mode 100644 index 00000000000..3a7e0155497 --- /dev/null +++ b/regression/cprover/large_step/trace/trace_struct1.c @@ -0,0 +1,13 @@ +struct S +{ + int a, b, c; +} x, y; + +int main() +{ + x.a = 123; + x.b = 456; + int *p = &x.c; + *p = 789; + __CPROVER_assert(0, "property 1"); +} diff --git a/regression/cprover/large_step/trace/trace_struct1.desc b/regression/cprover/large_step/trace/trace_struct1.desc new file mode 100644 index 00000000000..948f6d9004b --- /dev/null +++ b/regression/cprover/large_step/trace/trace_struct1.desc @@ -0,0 +1,9 @@ +KNOWNBUG +trace_struct1.c +--trace +^EXIT=10$ +^SIGNAL=0$ +^Trace for main\.assertion\.1:$ +^ 10 main::1::p := address_of\(x\.c\)$ +^ 11 x\.c := 789$ +-- diff --git a/regression/cprover/large_step/unions/union1.c b/regression/cprover/large_step/unions/union1.c new file mode 100644 index 00000000000..f98fa99e285 --- /dev/null +++ b/regression/cprover/large_step/unions/union1.c @@ -0,0 +1,18 @@ +union U +{ + int i; + char ch; +}; + +int main() +{ + union U u; + + u.i = 1; + __CPROVER_assert(u.i == 1, "property 1"); // passes + + u.ch = 2; + __CPROVER_assert(u.ch == 2, "property 2"); // passes + + return 0; +} diff --git a/regression/cprover/large_step/unions/union1.desc b/regression/cprover/large_step/unions/union1.desc new file mode 100644 index 00000000000..07a9c24e1c9 --- /dev/null +++ b/regression/cprover/large_step/unions/union1.desc @@ -0,0 +1,8 @@ +CORE +union1.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$ +-- diff --git a/regression/cprover/large_step/unions/union2.c b/regression/cprover/large_step/unions/union2.c new file mode 100644 index 00000000000..1de535dbd4a --- /dev/null +++ b/regression/cprover/large_step/unions/union2.c @@ -0,0 +1,16 @@ +union U +{ + int i; + char ch; +}; + +int main() +{ + union U u; + + u.i = 0; + u.ch = 1; + __CPROVER_assert(u.i == 1, "property 1"); // passes on little endian + + return 0; +} diff --git a/regression/cprover/large_step/unions/union2.desc b/regression/cprover/large_step/unions/union2.desc new file mode 100644 index 00000000000..4d3d8ec3731 --- /dev/null +++ b/regression/cprover/large_step/unions/union2.desc @@ -0,0 +1,7 @@ +KNOWNBUG +union2.c + +^EXIT=0$ +^SIGNAL=0$ +^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$ +-- From 8df40d16cee8d61bd15a064a61a9bd3114f6675e Mon Sep 17 00:00:00 2001 From: Yakir Vizel Date: Tue, 29 Oct 2024 13:56:30 +0200 Subject: [PATCH 13/20] Some comments and minor modifications --- src/cprover/chc_large_step.h | 21 ++++++++++++++++----- src/cprover/chc_wto.h | 21 ++++++++++++++++++++- src/cprover/cutpoint_graph.h | 11 +++++++++++ 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/src/cprover/chc_large_step.h b/src/cprover/chc_large_step.h index 143c0fc33ea..7c14039c247 100644 --- a/src/cprover/chc_large_step.h +++ b/src/cprover/chc_large_step.h @@ -9,9 +9,9 @@ #include #include -/* - * Traverses the clauses in order and resolving all predicates (symbols) - * that are not a head (e.g. a head of a loop). +/** + * Traverses the clauses in order (wto) and resolving all predicates (symbols) + * that are not a head of a component (e.g. a head of a loop). * This is similar to variable elimination in SAT. */ class resolution_visitort : public wto_element_visitort @@ -38,8 +38,11 @@ class resolution_visitort : public wto_element_visitort { const symbol_exprt* head = comp.head(); m_heads.insert(head->hash()); - std::string str = head->get_identifier().c_str(); - std::cout << "Head: " << str << "\n"; + if (m_verbose) + { + std::string str = head->get_identifier().c_str(); + std::cout << "Head: " << str << "\n"; + } for (auto it = comp.begin(); it != comp.end(); it++) { it->get()->accept(this); @@ -47,6 +50,7 @@ class resolution_visitort : public wto_element_visitort eliminate(head); } + // Create the new CHC db after eliminating uninterpreted predicates. void populate_new_db() { std::vector rels; @@ -131,6 +135,13 @@ class resolution_visitort : public wto_element_visitort } } + /** Assuming the following shapes: + * c1 := Sxx(ς) ∧ ς(COND1) ⇒ Syy(ς[update1]) + * c2 := Syy(ς) ∧ ς(COND2) ⇒ Szz(ς[update2]) + * In this case, Syy(ς) is eliminated and we use substitution for c2 such + * that it "operates" over ς[update1]. This results in: + * Sxx(ς) ∧ ς(COND1) ∧ ς[update1](COND2) ⇒ Szz(ς[update1][update2]) + */ forall_exprt resolve_clauses(const horn_clauset & c1, const horn_clauset & c2) { const exprt &body1 = *c1.body(); diff --git a/src/cprover/chc_wto.h b/src/cprover/chc_wto.h index 3b9ed31e2c4..15c03381ef5 100644 --- a/src/cprover/chc_wto.h +++ b/src/cprover/chc_wto.h @@ -17,6 +17,22 @@ class wto_singletont; class wto_componentt; +/** + * Bourdoncle Components over the cut-point graph of CHCs is a weak topological + * ordering (wto) on cut-points. This is mainly known from the work on + * widening operations in abstract interpretation. The most common intuition + * is an ordering of graph vertices with well-formed (aka well-matched) + * parentheses that mark components. + * + * For example, 1 (2 (3 4 5 6) 7) 8 is a wto with two components, where the + * inner componenet includes vertices 3-6, the outter component includes + * vertices 2 and 7. In this simple example, vertex 1 is the entry point, and + * vertex 8 is the exit point. Vertex 2 can be though of as the head of the + * outer loop, while vertex 3 is the head of the inner loop. + * + * The wto is used to guide the elimination step. + */ + class wto_element_visitort { public: @@ -171,7 +187,6 @@ class chc_wtot } inf_numt visit(const symbol_exprt* v, std::deque &partition) { - std::string name = as_string(v->get_identifier()); m_stack.push_back(v); m_dfn[v->hash()] = m_cur_dfn_num++; auto head = get_dfn(v); @@ -276,6 +291,10 @@ class chc_wtot } }; +/** + * Simple Visitor prints the components of the WTO with well-formed + * parentheses. + */ class simple_visitort : public wto_element_visitort { virtual void visit(const wto_singletont & s) diff --git a/src/cprover/cutpoint_graph.h b/src/cprover/cutpoint_graph.h index a54a5255653..ed0dadaaffa 100644 --- a/src/cprover/cutpoint_graph.h +++ b/src/cprover/cutpoint_graph.h @@ -14,11 +14,16 @@ * 1. Entry node * 2. Exit node * 3. Every node that has a back-edge - namely, a loop head. + * This graph is used for large-step encoding of CHCs. Uninterpreted predicates + * are only needed where there are cut-points. */ class cutpoint_grapht; class cutpointt; +/** + * A class that represents an edge in the graph + */ class cutpoint_edget { friend class cutpoint_grapht; @@ -55,6 +60,9 @@ class cutpoint_edget typedef std::shared_ptr cutpoint_edge_ptr; +/** + * A class that represents a cutpoint in the graph + */ class cutpointt { const cutpoint_grapht &m_graph; @@ -87,6 +95,9 @@ class cutpointt } }; +/** + * The graph + */ class cutpoint_grapht { const goto_modelt & m_goto_model; From d4d3835a24cfbaf833e91dc48c37293e45aff476 Mon Sep 17 00:00:00 2001 From: Yakir Vizel Date: Tue, 29 Oct 2024 13:58:36 +0200 Subject: [PATCH 14/20] Removed whitespace --- src/cprover/cprover_parse_options.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cprover/cprover_parse_options.h b/src/cprover/cprover_parse_options.h index a41d9820ae3..5b79da41959 100644 --- a/src/cprover/cprover_parse_options.h +++ b/src/cprover/cprover_parse_options.h @@ -28,7 +28,6 @@ Author: Daniel Kroening, dkr@amazon.com "(large-step)" \ "(verbose)" - class cprover_parse_optionst { public: From d75ddaf9cb890570bafdf18be8a41ad208ded6fc Mon Sep 17 00:00:00 2001 From: Yakir Vizel Date: Tue, 29 Oct 2024 14:00:13 +0200 Subject: [PATCH 15/20] Removed include --- src/cprover/chc_db.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/cprover/chc_db.cpp b/src/cprover/chc_db.cpp index e2b71200827..e613f675fae 100644 --- a/src/cprover/chc_db.cpp +++ b/src/cprover/chc_db.cpp @@ -4,8 +4,6 @@ #include "chc_db.h" -#include - chc_dbt::chc_sett chc_dbt::m_empty_set; std::unordered_set chc_grapht::m_expr_empty_set; From 193da7a56502013928d0ff01b14858b9a3052771 Mon Sep 17 00:00:00 2001 From: Yakir Vizel Date: Wed, 30 Oct 2024 14:48:41 +0200 Subject: [PATCH 16/20] Missing commit --- src/cprover/solver.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cprover/solver.h b/src/cprover/solver.h index 7d6f6460512..33fd525731f 100644 --- a/src/cprover/solver.h +++ b/src/cprover/solver.h @@ -29,6 +29,7 @@ class solver_optionst public: bool trace; bool verbose; + bool large_step; std::size_t loop_limit; }; From aa6df743b39a2c59c47e936762d9b6659c2a3b2a Mon Sep 17 00:00:00 2001 From: Yakir Vizel Date: Sun, 10 Nov 2024 14:48:26 +0200 Subject: [PATCH 17/20] Removing redundant include, and fixing function arguments --- src/cprover/chc_db.cpp | 38 +++++++++++++++++++++++++++++- src/cprover/chc_db.h | 45 ++---------------------------------- src/cprover/chc_large_step.h | 7 +++--- 3 files changed, 42 insertions(+), 48 deletions(-) diff --git a/src/cprover/chc_db.cpp b/src/cprover/chc_db.cpp index e613f675fae..9aae27a02b7 100644 --- a/src/cprover/chc_db.cpp +++ b/src/cprover/chc_db.cpp @@ -7,6 +7,42 @@ chc_dbt::chc_sett chc_dbt::m_empty_set; std::unordered_set chc_grapht::m_expr_empty_set; +void horn_clauset::used_relations(chc_dbt &db, std::vector & out) const +{ + const exprt *body = this->body(); + if (body == nullptr) return; + std::set symbols = find_symbols(*body); + + chc_dbt::is_state_pred filter(db); + for (auto & symb : symbols) { + if (filter(symb)) { + out.push_back(symb); + } + } +} + +void horn_clauset::used_func_app(chc_dbt &db, std::vector & out) const +{ + const exprt *body = this->body(); + if (body == nullptr) return; + + std::unordered_set funcs; + body->visit_pre([&funcs](const exprt &expr) { + if (can_cast_expr(expr)) + { + const function_application_exprt & f = to_function_application_expr(expr); + funcs.insert(f); + } + }); + + chc_dbt::is_state_pred filter(db); + for (auto & f : funcs) { + if (filter(to_symbol_expr(f.function()))) { + out.push_back(f); + } + } +} + void chc_dbt::reset_indices() { m_body_idx.clear(); @@ -28,7 +64,7 @@ void chc_dbt::build_indices() m_head_idx[func].insert(i); std::vector use; - r.used_relations(*this,std::back_inserter(use)); + r.used_relations(*this, use); for (auto & symb : use) { m_body_idx[symb].insert(i); diff --git a/src/cprover/chc_db.h b/src/cprover/chc_db.h index 6534f2655fb..820994046f1 100644 --- a/src/cprover/chc_db.h +++ b/src/cprover/chc_db.h @@ -8,7 +8,6 @@ #include #include #include -#include #include #include @@ -101,10 +100,8 @@ class horn_clauset return m_chc < other.m_chc; } - template - void used_relations(chc_dbt &db, OutputIterator out) const; - template - void used_func_app(chc_dbt &db, OutputIterator out) const; + void used_relations(chc_dbt &db, std::vector & out) const; + void used_func_app(chc_dbt &db, std::vector & out) const; }; /* @@ -192,44 +189,6 @@ class chc_dbt chcst::const_iterator end() const { return m_clauses.end(); } }; -template -void horn_clauset::used_relations(chc_dbt &db, OutputIterator out) const -{ - const exprt *body = this->body(); - if (body == nullptr) return; - std::set symbols = find_symbols(*body); - - chc_dbt::is_state_pred filter(db); - for (auto & symb : symbols) { - if (filter(symb)) { - *out = symb; - } - } -} - -template -void horn_clauset::used_func_app(chc_dbt &db, OutputIterator out) const -{ - const exprt *body = this->body(); - if (body == nullptr) return; - - std::unordered_set funcs; - body->visit_pre([&funcs](const exprt &expr) { - if (can_cast_expr(expr)) - { - const function_application_exprt & f = to_function_application_expr(expr); - funcs.insert(f); - } - }); - - chc_dbt::is_state_pred filter(db); - for (auto & f : funcs) { - if (filter(to_symbol_expr(f.function()))) { - *out = f; - } - } -} - /* * The CHC dependency graph. * Uninterpreted relations are vertices, dependency is based on clauses: diff --git a/src/cprover/chc_large_step.h b/src/cprover/chc_large_step.h index 7c14039c247..bde9580afff 100644 --- a/src/cprover/chc_large_step.h +++ b/src/cprover/chc_large_step.h @@ -58,7 +58,7 @@ class resolution_visitort : public wto_element_visitort { if(clause.is_query()) { - clause.used_relations(m_db, std::back_inserter(rels)); + clause.used_relations(m_db, rels); } } @@ -91,8 +91,7 @@ class resolution_visitort : public wto_element_visitort { auto & clause = m_db.get_clause(idx); std::vector use; - - clause.used_relations(m_db,std::back_inserter(use)); + clause.used_relations(m_db, use); if (use.size() > 1) { throw incorrect_goto_program_exceptiont("Non-linear CHCs not supported yet"); } @@ -150,7 +149,7 @@ class resolution_visitort : public wto_element_visitort const exprt &head2 = *c2.head(); std::vector use2; - c2.used_func_app(m_db,std::back_inserter(use2)); + c2.used_func_app(m_db,use2); INVARIANT(use2.size() == 1, "Only handling linear case"); if (use2.size() != 1) From 0f6a42aa1813d3ca6871e46c5271a0abc330c408 Mon Sep 17 00:00:00 2001 From: yvizel Date: Sun, 9 Feb 2025 09:46:48 +0200 Subject: [PATCH 18/20] Changing user_relations function declaration --- src/cprover/chc_db.cpp | 9 +++++---- src/cprover/chc_db.h | 5 +++-- src/cprover/chc_large_step.h | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/cprover/chc_db.cpp b/src/cprover/chc_db.cpp index 9aae27a02b7..c30dfd7b723 100644 --- a/src/cprover/chc_db.cpp +++ b/src/cprover/chc_db.cpp @@ -7,10 +7,11 @@ chc_dbt::chc_sett chc_dbt::m_empty_set; std::unordered_set chc_grapht::m_expr_empty_set; -void horn_clauset::used_relations(chc_dbt &db, std::vector & out) const +std::vector horn_clauset::used_relations(chc_dbt &db) const { + std::vector out; const exprt *body = this->body(); - if (body == nullptr) return; + if (body == nullptr) return out; std::set symbols = find_symbols(*body); chc_dbt::is_state_pred filter(db); @@ -19,6 +20,7 @@ void horn_clauset::used_relations(chc_dbt &db, std::vector & out) out.push_back(symb); } } + return out; } void horn_clauset::used_func_app(chc_dbt &db, std::vector & out) const @@ -63,8 +65,7 @@ void chc_dbt::build_indices() exprt func = to_function_application_expr(*r.head()).function(); m_head_idx[func].insert(i); - std::vector use; - r.used_relations(*this, use); + std::vector use = r.used_relations(*this); for (auto & symb : use) { m_body_idx[symb].insert(i); diff --git a/src/cprover/chc_db.h b/src/cprover/chc_db.h index 820994046f1..d5268149966 100644 --- a/src/cprover/chc_db.h +++ b/src/cprover/chc_db.h @@ -100,8 +100,9 @@ class horn_clauset return m_chc < other.m_chc; } - void used_relations(chc_dbt &db, std::vector & out) const; - void used_func_app(chc_dbt &db, std::vector & out) const; + std::vector used_relations(chc_dbt &db) const; + void used_func_app(chc_dbt &db, std::vector &out) + const; }; /* diff --git a/src/cprover/chc_large_step.h b/src/cprover/chc_large_step.h index bde9580afff..36d42df1d99 100644 --- a/src/cprover/chc_large_step.h +++ b/src/cprover/chc_large_step.h @@ -58,7 +58,8 @@ class resolution_visitort : public wto_element_visitort { if(clause.is_query()) { - clause.used_relations(m_db, rels); + std::vector r = clause.used_relations(m_db); + rels.insert(rels.end(), r.begin(), r.end()); } } @@ -90,8 +91,7 @@ class resolution_visitort : public wto_element_visitort for (auto idx : m_db.def(*symb)) { auto & clause = m_db.get_clause(idx); - std::vector use; - clause.used_relations(m_db, use); + std::vector use = clause.used_relations(m_db); if (use.size() > 1) { throw incorrect_goto_program_exceptiont("Non-linear CHCs not supported yet"); } From ad717bac9302e99f383dc8109d29325692eb7de4 Mon Sep 17 00:00:00 2001 From: yvizel Date: Sun, 9 Feb 2025 09:49:59 +0200 Subject: [PATCH 19/20] clang format, and minor fixes to is_query, is_fact --- src/cprover/chc_db.h | 166 +++++++++++++++++++++++++++---------------- 1 file changed, 104 insertions(+), 62 deletions(-) diff --git a/src/cprover/chc_db.h b/src/cprover/chc_db.h index d5268149966..443030b21b5 100644 --- a/src/cprover/chc_db.h +++ b/src/cprover/chc_db.h @@ -5,14 +5,16 @@ #ifndef CBMC_CHC_DB_H #define CBMC_CHC_DB_H +#include #include #include -#include -#include +#include "expr_iterator.h" + +#include #include #include -#include +#include class chc_dbt; @@ -30,57 +32,54 @@ class horn_clauset forall_exprt m_chc; public: - horn_clauset(forall_exprt f) : m_chc(f) {} - - horn_clauset(std::vector & vars, exprt clause) : m_chc(vars, clause) { + horn_clauset(forall_exprt f) : m_chc(f) + { + } + horn_clauset(std::vector &vars, exprt clause) + : m_chc(vars, clause) + { } - const forall_exprt & get_chc() const + const forall_exprt &get_chc() const { return m_chc; } - const exprt* body() const { - if (can_cast_expr(m_chc.where())) + const exprt *body() const + { + if(can_cast_expr(m_chc.where())) { return &to_implies_expr(m_chc.where()).op0(); } return &m_chc.where(); } - const exprt* head() const { - if (can_cast_expr(m_chc.where())) + const exprt *head() const + { + if(can_cast_expr(m_chc.where())) { return &to_implies_expr(m_chc.where()).op1(); } return nullptr; } - bool is_fact() const { + bool is_fact() const + { auto b = body(); - bool not_fact = false; - b->visit_pre( - [¬_fact](const exprt &expr) { - if(can_cast_expr(expr)) - { - not_fact = true; - } - }); - return !not_fact; - } - - bool is_query() const { - if (can_cast_expr(m_chc.where())) + const std::function pred = [](const exprt &subexpr) { + return can_cast_expr(subexpr); + }; + auto it = std::find_if(b->depth_begin(), b->depth_end(), pred); + + return (it == b->depth_end()); + } + + bool is_query() const + { + if(can_cast_expr(m_chc.where())) { - auto h = head(); - bool res = true; - h->visit_pre( - [&res](const exprt &expr) { - if(can_cast_expr(expr)) - res = false; - }); - return res; + return (can_cast_expr(*head())); } return false; } @@ -92,7 +91,7 @@ class horn_clauset bool operator!=(const horn_clauset &other) const { - return !(*this==other); + return !(*this == other); } bool operator<(const horn_clauset &other) const @@ -112,12 +111,19 @@ class horn_clauset class chc_dbt { friend class horn_clauset; + public: - struct is_state_pred : public std::__unary_function { + struct is_state_pred : public std::__unary_function + { const chc_dbt &m_db; - is_state_pred(const chc_dbt &db) : m_db(db) {} + is_state_pred(const chc_dbt &db) : m_db(db) + { + } - bool operator()(symbol_exprt state) { return m_db.has_state_pred(state); } + bool operator()(symbol_exprt state) + { + return m_db.has_state_pred(state); + } }; typedef std::unordered_set chc_sett; @@ -136,37 +142,50 @@ class chc_dbt static chc_sett m_empty_set; public: - chc_dbt() {} + chc_dbt() + { + } - void add_state_pred(const symbol_exprt & state) { m_state_preds.insert(state); } - const std::unordered_set &get_state_preds() { return m_state_preds; } - bool has_state_pred(const symbol_exprt & state) const { return m_state_preds.count(state) > 0; } + void add_state_pred(const symbol_exprt &state) + { + m_state_preds.insert(state); + } + const std::unordered_set &get_state_preds() + { + return m_state_preds; + } + bool has_state_pred(const symbol_exprt &state) const + { + return m_state_preds.count(state) > 0; + } void build_indices(); void reset_indices(); - const chc_sett & use(const exprt & state) const { + const chc_sett &use(const exprt &state) const + { auto it = m_body_idx.find(state); - if (it == m_body_idx.end()) + if(it == m_body_idx.end()) return m_empty_set; return it->second; } - const chc_sett & def(const exprt & state) const { + const chc_sett &def(const exprt &state) const + { auto it = m_head_idx.find(state); - if (it == m_head_idx.end()) + if(it == m_head_idx.end()) return m_empty_set; return it->second; } - void add_clause(const forall_exprt & f) + void add_clause(const forall_exprt &f) { - if (f.is_true()) + if(f.is_true()) return; auto new_cls = horn_clauset(f); // Equivalent (semantic) queries may represent // different properties - if (!new_cls.is_query()) + if(!new_cls.is_query()) { for(auto &c : m_clauses) { @@ -178,16 +197,28 @@ class chc_dbt reset_indices(); } - [[nodiscard]] const horn_clauset & get_clause(std::size_t idx) const + [[nodiscard]] const horn_clauset &get_clause(std::size_t idx) const { INVARIANT(idx < m_clauses.size(), "Index in range"); return m_clauses[idx]; } - chcst::iterator begin() { return m_clauses.begin(); } - chcst::iterator end() { return m_clauses.end(); } - chcst::const_iterator begin() const { return m_clauses.begin(); } - chcst::const_iterator end() const { return m_clauses.end(); } + chcst::iterator begin() + { + return m_clauses.begin(); + } + chcst::iterator end() + { + return m_clauses.end(); + } + chcst::const_iterator begin() const + { + return m_clauses.begin(); + } + chcst::const_iterator end() const + { + return m_clauses.end(); + } }; /* @@ -197,7 +228,7 @@ class chc_dbt */ class chc_grapht { - chc_dbt & m_db; + chc_dbt &m_db; typedef std::map> grapht; grapht m_incoming; grapht m_outgoing; @@ -207,25 +238,36 @@ class chc_grapht static std::unordered_set m_expr_empty_set; public: - chc_grapht(chc_dbt & db) : m_db(db), m_entry(nullptr) {} + chc_grapht(chc_dbt &db) : m_db(db), m_entry(nullptr) + { + } void build_graph(); - bool has_entry() const { return m_entry != nullptr; } - const symbol_exprt *entry() const { + bool has_entry() const + { + return m_entry != nullptr; + } + const symbol_exprt *entry() const + { INVARIANT(has_entry(), "Entry must exist."); - return m_entry; } + return m_entry; + } - const std::unordered_set &outgoing(const symbol_exprt &state) const { + const std::unordered_set & + outgoing(const symbol_exprt &state) const + { auto it = m_outgoing.find(state); - if (it == m_outgoing.end()) + if(it == m_outgoing.end()) return m_expr_empty_set; return it->second; } - const std::unordered_set &incoming(const symbol_exprt &state) const { + const std::unordered_set & + incoming(const symbol_exprt &state) const + { auto it = m_incoming.find(state); - if (it == m_incoming.end()) + if(it == m_incoming.end()) return m_expr_empty_set; return it->second; } From fbb21943a4eb0273cdceaed4fafc5f9c29947475 Mon Sep 17 00:00:00 2001 From: yvizel Date: Mon, 24 Feb 2025 15:14:43 +0200 Subject: [PATCH 20/20] Small fix --- src/cprover/chc_db.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cprover/chc_db.h b/src/cprover/chc_db.h index 443030b21b5..bf229796c23 100644 --- a/src/cprover/chc_db.h +++ b/src/cprover/chc_db.h @@ -79,7 +79,7 @@ class horn_clauset { if(can_cast_expr(m_chc.where())) { - return (can_cast_expr(*head())); + return !(can_cast_expr(*head())); } return false; }