Skip to content

Commit 2258716

Browse files
committed
Remove out commented code
1 parent 1bea9ef commit 2258716

File tree

1 file changed

+0
-51
lines changed

1 file changed

+0
-51
lines changed

src/lib.rs

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,6 @@ impl slang_ui::Hook for App {
104104
).op(Op::Eq, b)
105105
}
106106

107-
108-
109-
// add as axiom
110-
/*
111-
function foo (x:T) : S
112-
axiom {
113-
forall x:T :: F -> (foo (x) == (e) and G[result := foo(x)])
114-
}
115-
*/
116107
let mut post_conditions = Expr::bool(true);
117108
for post_condition in f.ensures() {
118109
post_conditions = post_conditions.and(
@@ -201,7 +192,6 @@ fn does_function_body_comply_with_postconditions_in_isolated_scope(
201192
span: b.span.clone()
202193
})
203194
};
204-
//specifications.push(ensures_body);
205195
let mut requires: Vec<Specification> = Vec::new();
206196
for specification in &f.specifications {
207197
if let Specification::Requires { .. } = specification {
@@ -230,36 +220,11 @@ fn does_function_body_comply_with_postconditions_in_isolated_scope(
230220
span: b.span.clone()
231221
})
232222
};
233-
//println!("Axiom only body: {:#?}", axiom_only_body.to_string());
234-
//println!("Method only body: {:#?}", method_ensures_body);
235-
/*
236-
let result1 = solver.scope(|solver| {
237-
solver.assert(expr_to_smt(&axiom_only_body)?.as_bool()?)?;
238-
verify_method(&method_ensures_body, cx, solver)
239-
});
240-
*/
241223

242-
//println!("Axiom only post_conditions: {:#?}", axiom_only_post_conditions.to_string());
243-
//println!("Method post conditions: {:#?}", method_ensures_post_conditions);
244224
return solver.scope(|solver| {
245225
solver.assert(expr_to_smt(&axiom_only_post_conditions)?.as_bool()?)?;
246226
verify_method(true, &method_ensures_post_conditions, cx, solver)
247227
});
248-
/*
249-
match (result1, result2) {
250-
(Ok(_), Ok(_)) => (),
251-
(Err(e), Ok(_)) => {
252-
//println!("Ensure body failed {e}");
253-
return Err(e) },
254-
(Ok(_), Err(e)) => {
255-
//println!("Ensure post conditions failed {e}");
256-
return Err(e) }
257-
(Err(_e1), Err(_e2)) => {
258-
//println!("Both failed {e1} {e2}");
259-
}
260-
}
261-
262-
*/
263228
}
264229
Ok(())
265230
}
@@ -273,7 +238,6 @@ fn expr_to_smt(expr: &Expr) -> Result<Dynamic, Error> {
273238
}
274239

275240
fn verify_method(is_function: bool, m: &Method, cx: &mut slang_ui::Context, solver: &mut Solver<Z3Binary>) -> Result<(), Error> {
276-
//println!("Checking method {}", m.name);
277241
// Get method's preconditions;
278242
let pres = m.requires();
279243
// Merge them into a single condition
@@ -292,7 +256,6 @@ fn verify_method(is_function: bool, m: &Method, cx: &mut slang_ui::Context, solv
292256
// However, we check for satisfiability of !(precondition -> wp_predicate)
293257
// which is equivalent to !(!precondition or wp_predicate) == precondition and !wp_predicate
294258
// Therefore we assert the precondition and later on assert the negation of each of the wp_predicate's
295-
//println!("Spre: {:#?}", spre);
296259
solver.assert(spre.as_bool()?)?;
297260

298261
let post_conditions: Vec<Expr> = m.ensures().map(|e| e.clone()).collect();
@@ -374,13 +337,9 @@ fn verify_method(is_function: bool, m: &Method, cx: &mut slang_ui::Context, solv
374337
)?;
375338

376339
ivl = ivl.seq(&ivl_encoding);
377-
//println!("IVL:\n{:#?}", ivl);
378340

379341
let dsa = ivl_to_dsa(&ivl, &mut HashMap::new())?;
380342

381-
382-
//println!("Method {} IVL {:#?}", m.name.to_string(), ivl.to_string());
383-
384343
// Calculate obligation and error message (if obligation is not
385344
// verified)
386345
let wp_list = wp_set(&dsa, vec![])?;
@@ -403,7 +362,6 @@ fn verify_method(is_function: bool, m: &Method, cx: &mut slang_ui::Context, solv
403362
// If the obligations result not valid, report the error (on
404363
// the span in which the error happens)
405364
smtlib::SatResult::Sat => {
406-
//println!("{}", format!("expr: {expr} span_start: {} span_end: {}", span.start(), span.end()));
407365
cx.error(span, format!("{}", msg));
408366
res = Err(Error::UnexpectedSatResult{expected: SatResult::Unsat, actual: SatResult::Sat});
409367
}
@@ -446,11 +404,9 @@ fn does_method_modify_unspecified_global_variables(
446404
None
447405
}
448406
CmdKind::Assignment { name, .. } => {
449-
//println!("Searching for {} in symbol table {:#?}", name, symbol_table);
450407
if symbol_table.contains(&name.to_string()) {
451408
return None
452409
}
453-
//println!("Searching for {} in global variables {:#?}", name, specified_global_variables);
454410
if specified_global_variables.contains(&name.to_string()) {
455411
return None
456412
}
@@ -508,7 +464,6 @@ fn ivl_to_dsa(ivl: &IVLCmd, varmap: &mut HashMap<Ident, (Ident, Type)>) -> Resul
508464
// get new ident for name and update it in the map
509465
let new_ident = get_fresh_var_name(&name.ident);
510466
varmap.insert(name.ident.clone(), (new_ident.clone(), expr.ty.clone()));
511-
// assume new_ident == dsa
512467
Ok(assume_equality(
513468
&Expr::new_typed(ExprKind::Ident(new_ident), expr.ty.clone()),
514469
&dsa
@@ -638,8 +593,6 @@ fn extract_identifiers_from_expression(expr: &Expr, ignored_quantified_identifie
638593
}
639594
}
640595

641-
// Encoding of (assert-only) statements into IVL (for programs comprised of only
642-
// a single assertion)
643596
fn cmd_to_ivlcmd(cmd: &Cmd, method_context: &MethodContext, loop_context: &LoopContext) -> Result<IVLCmd, Error> {
644597
let &Cmd { kind, span, .. } = &cmd;
645598
Ok(match kind {
@@ -819,7 +772,6 @@ fn return_to_ivl(expr: Option<&Expr>, span: &Span, method_context: &MethodContex
819772
for post_condition in method_context.post_conditions.clone() {
820773
let mut replaced_old = replace_old_in_expression(&post_condition, &method_context.global_variables_old_values);
821774
replaced_old.span = post_condition.span.clone();
822-
//println!("replace_old {}", replaced_old);
823775
// assert method_post_conditions
824776
result = result.seq(&IVLCmd::assert(
825777
&replaced_old,
@@ -847,7 +799,6 @@ fn return_to_ivl(expr: Option<&Expr>, span: &Span, method_context: &MethodContex
847799
for post_condition in method_context.post_conditions.clone() {
848800
let mut replaced_old = replace_old_in_expression(&post_condition, &method_context.global_variables_old_values);
849801
replaced_old.span = span.clone();
850-
//println!("replace_old {}", replaced_old);
851802
// assert method_post_conditions
852803
result = result.seq(&IVLCmd::assert(
853804
&replaced_old,
@@ -947,7 +898,6 @@ fn loop_to_ivl(invariants: &Vec<Expr>, variant: &Option<Expr>, cases: &Cases, me
947898
case_condition_prefix = case_condition_prefix.seq(&IVLCmd::assume(&case.condition.clone().prefix(PrefixOp::Not)));
948899
let break_paths = find_break_paths(&case.cmd, assume_case, method_context, loop_context)?;
949900
for break_path in break_paths {
950-
//eprintln!("break_path {:#?}", break_path);
951901
body_translation = body_translation.nondet(&break_path)
952902
}
953903

@@ -1266,7 +1216,6 @@ fn wp_set_seq(cmd1: &Box<IVLCmd>, cmd2: &Box<IVLCmd>, post_condition: Vec<Weakes
12661216
return Ok(wp_set1);
12671217
}
12681218

1269-
// f (e, i, v) -> e[i <- v]
12701219
fn replace_in_expression(original_expression: &Expr, identifier: &Name, replace_with_identifier: &Expr) -> Expr {
12711220
let mut result = match &original_expression.kind {
12721221
ExprKind::Ident(name) if name.0 == identifier.ident.0 => replace_with_identifier.clone(),

0 commit comments

Comments
 (0)