Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/hw_cbmc_irep_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ IREP_ID_ONE(F)
IREP_ID_ONE(E)
IREP_ID_ONE(G)
IREP_ID_ONE(X)
IREP_ID_ONE(smv_next)
IREP_ID_ONE(smv_iff)
IREP_ID_TWO(C_smv_iff, "#smv_iff")
IREP_ID_ONE(smv_setin)
Expand Down
8 changes: 4 additions & 4 deletions src/smvlang/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,10 @@ assignment : assignment_head '(' assignment_var ')' BECOMES_Token formula ';'
{
binary($$, $3, ID_equal, $6, bool_typet{});

if(stack_expr($1).id()=="next")
if(stack_expr($1).id()==ID_smv_next)
{
exprt &op=to_binary_expr(stack_expr($$)).op0();
unary_exprt tmp("smv_next", std::move(op));
unary_exprt tmp(ID_smv_next, std::move(op));
tmp.swap(op);
PARSER.module->add_trans(stack_expr($$));
}
Expand All @@ -393,7 +393,7 @@ assignment_var: variable_name
;

assignment_head: init_Token { init($$, ID_init); }
| NEXT_Token { init($$, "next"); }
| NEXT_Token { init($$, ID_smv_next); }
;

defines: define
Expand Down Expand Up @@ -439,7 +439,7 @@ formula : term
;

term : variable_name
| NEXT_Token '(' term ')' { init($$, "smv_next"); mto($$, $3); }
| NEXT_Token '(' term ')' { init($$, ID_smv_next); mto($$, $3); }
| '(' formula ')' { $$=$2; }
| '{' formula_list '}' { $$=$2; stack_expr($$).id("smv_nondet_choice"); }
| INC_Token '(' term ')' { init($$, "inc"); mto($$, $3); }
Expand Down
89 changes: 89 additions & 0 deletions src/smvlang/smv_range.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*******************************************************************\

Module: SMV Typechecking

Author: Daniel Kroening, [email protected]

\*******************************************************************/

#ifndef CPROVER_SMV_RANGE_H
#define CPROVER_SMV_RANGE_H

#include <util/arith_tools.h>

class smv_ranget
{
public:
smv_ranget() : from(0), to(0)
{
}

smv_ranget(mp_integer _from, mp_integer _to)
: from(std::move(_from)), to(std::move(_to))
{
PRECONDITION(_from <= _to);
}

mp_integer from, to;

bool is_contained_in(const smv_ranget &other) const
{
if(other.from > from)
return false;
if(other.to < to)
return false;
return true;
}

void make_union(const smv_ranget &other)
{
mp_min(from, other.from);
mp_max(to, other.to);
}

void to_type(typet &dest) const
{
dest = typet(ID_range);
dest.set(ID_from, integer2string(from));
dest.set(ID_to, integer2string(to));
}

bool is_bool() const
{
return from == 0 && to == 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

While I understand that this is the same behaviour as before: why would from == 1 or to == 0 not be permitted?

Copy link
Member Author

Choose a reason for hiding this comment

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

See #903, and will add a precondition to the class.

}

bool is_singleton() const
{
return from == to;
}

smv_ranget &operator+(const smv_ranget &other)
{
from += other.from;
to += other.to;
return *this;
}

smv_ranget &operator-(const smv_ranget &other)
{
from -= other.from;
to -= other.to;
return *this;
}

smv_ranget &operator*(const smv_ranget &other)
{
mp_integer p1 = from * other.from;
mp_integer p2 = from * other.to;
mp_integer p3 = to * other.from;
mp_integer p4 = to * other.to;

from = std::min(p1, std::min(p2, std::min(p3, p4)));
to = std::max(p1, std::max(p2, std::max(p3, p4)));

return *this;
}
};

#endif // CPROVER_SMV_RANGE_H
Loading
Loading