Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Let arbitrary boolean values used in MaySet encoding depend on reference #191

Merged
merged 1 commit into from
May 9, 2024
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
6 changes: 3 additions & 3 deletions src/nagini_translation/translators/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,15 +921,15 @@ def get_fresh_int_lit(self, ctx: Context) -> Expr:
return self.viper.IntLit(ctx.get_fresh_int(), self.no_position(ctx),
self.no_info(ctx))

def get_unknown_bool(self, ctx: Context) -> Expr:
def get_unknown_bool(self, arg: Expr, ctx: Context) -> Expr:
"""
Returns an arbitrary but fixed boolean value.
Returns an arbitrary but fixed boolean value that depends on the value of arg.
"""
pos = self.no_position(ctx)
info = self.no_info(ctx)
fresh_int = self.get_fresh_int_lit(ctx)
param = self.viper.LocalVarDecl('i', self.viper.Int, pos, info)
return self.viper.FuncApp(ARBITRARY_BOOL_FUNC, [fresh_int], pos, info,
return self.viper.FuncApp(ARBITRARY_BOOL_FUNC, [fresh_int, self.to_ref(arg, ctx)], pos, info,
self.viper.Bool, [param])

def _conjoin(self, eqs: List[Expr], pos: Position, info: Info) -> Expr:
Expand Down
2 changes: 1 addition & 1 deletion src/nagini_translation/translators/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def translate_may_set(self, node: ast.Call, ctx: Context) -> StmtsAndExpr:
pos, info)
result_ex = self.viper.CondExp(have_normal_perm, normal_acc, may_set_pred, pos,
info)
unknown = self.get_unknown_bool(ctx)
unknown = self.get_unknown_bool(rec, ctx)
result_in = self.viper.CondExp(unknown, normal_acc, may_set_pred, pos, info)
return [], self.viper.InhaleExhaleExp(result_in, result_ex, pos, info)

Expand Down
3 changes: 2 additions & 1 deletion src/nagini_translation/translators/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,8 @@ def create_arbitrary_bool_func(self, ctx: Context) -> 'silver.ast.Function':
pos = self.no_position(ctx)
info = self.no_info(ctx)
i_param_decl = self.viper.LocalVarDecl('i', self.viper.Int, pos, info)
return self.viper.Function(ARBITRARY_BOOL_FUNC, [i_param_decl],
r_param_decl = self.viper.LocalVarDecl('r', self.viper.Ref, pos, info)
return self.viper.Function(ARBITRARY_BOOL_FUNC, [i_param_decl, r_param_decl],
self.viper.Bool, [], [], None, pos, info)

def create_may_set_predicate(self, ctx: Context) -> 'silver.ast.Predicate':
Expand Down
Loading