-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This introduces a pass during which the given property is 'normalized', using heuristic rewrites, with the goal to reduce the burden of a large number of redundant case-splits in each backend.
- Loading branch information
Showing
14 changed files
with
131 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ Author: Daniel Kroening, [email protected] | |
#include <langapi/language.h> | ||
#include <langapi/language_util.h> | ||
#include <langapi/mode.h> | ||
#include <temporal-logic/normalize_property.h> | ||
#include <verilog/sva_expr.h> | ||
|
||
#include "ebmc_error.h" | ||
|
@@ -70,7 +71,9 @@ ebmc_propertiest ebmc_propertiest::from_transition_system( | |
else | ||
properties.properties.back().name = symbol.pretty_name; | ||
|
||
properties.properties.back().expr = symbol.value; | ||
properties.properties.back().original_expr = symbol.value; | ||
properties.properties.back().normalized_expr = | ||
normalize_property(symbol.value); | ||
properties.properties.back().location = symbol.location; | ||
properties.properties.back().expr_string = value_as_string; | ||
properties.properties.back().mode = symbol.mode; | ||
|
@@ -156,7 +159,8 @@ ebmc_propertiest ebmc_propertiest::from_command_line( | |
ebmc_propertiest properties; | ||
properties.properties.push_back(propertyt()); | ||
auto &p = properties.properties.back(); | ||
p.expr = expr; | ||
p.original_expr = expr; | ||
p.normalized_expr = normalize_property(expr); | ||
p.expr_string = expr_as_string; | ||
p.mode = transition_system.main_symbol->mode; | ||
p.location.make_nil(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
SRC = negate_property.cpp \ | ||
normalize_property.cpp \ | ||
temporal_logic.cpp \ | ||
#empty line | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/*******************************************************************\ | ||
Module: Property Normalization | ||
Author: Daniel Kroening, [email protected] | ||
\*******************************************************************/ | ||
|
||
#include "normalize_property.h" | ||
|
||
#include <util/std_expr.h> | ||
|
||
#include <verilog/sva_expr.h> | ||
|
||
#include "temporal_expr.h" | ||
|
||
exprt normalize_pre_not(not_exprt expr) | ||
{ | ||
const auto &op = expr.op(); | ||
|
||
if(op.id() == ID_and) | ||
{ | ||
auto operands = op.operands(); | ||
for(auto &op : operands) | ||
op = not_exprt{op}; | ||
return or_exprt{std::move(operands)}; | ||
} | ||
else if(op.id() == ID_or) | ||
{ | ||
auto operands = op.operands(); | ||
for(auto &op : operands) | ||
op = not_exprt{op}; | ||
return and_exprt{std::move(operands)}; | ||
} | ||
else if(op.id() == ID_not) | ||
{ | ||
return to_not_expr(op).op(); | ||
} | ||
|
||
return std::move(expr); | ||
} | ||
|
||
exprt normalize_pre_implies(implies_exprt expr) | ||
{ | ||
return or_exprt{not_exprt{expr.lhs()}, expr.rhs()}; | ||
} | ||
|
||
exprt normalize_property(exprt expr) | ||
{ | ||
// pre-traversal | ||
if(expr.id() == ID_not) | ||
expr = normalize_pre_not(to_not_expr(expr)); | ||
else if(expr.id() == ID_implies) | ||
expr = normalize_pre_implies(to_implies_expr(expr)); | ||
else if(expr.id() == ID_sva_cover) | ||
expr = G_exprt{not_exprt{to_sva_cover_expr(expr).op()}}; | ||
|
||
// normalize the operands | ||
for(auto &op : expr.operands()) | ||
op = normalize_property(op); | ||
|
||
// post-traversal | ||
|
||
return expr; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/*******************************************************************\ | ||
Module: Property Normalization | ||
Author: Daniel Kroening, [email protected] | ||
\*******************************************************************/ | ||
|
||
#ifndef CPROVER_TEMPORAL_LOGIC_NORMALIZE_PROPERTY_H | ||
#define CPROVER_TEMPORAL_LOGIC_NORMALIZE_PROPERTY_H | ||
|
||
#include <util/expr.h> | ||
|
||
/// This applies the following rewrites: | ||
/// cover(φ) --> G¬φ | ||
/// ¬(a ∨ b) --> ¬a ∧ ¬b | ||
/// ¬(a ∧ b) --> ¬a ∨ ¬b | ||
/// ¬¬φ --> φ | ||
exprt normalize_property(exprt); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters