@@ -104,15 +104,6 @@ impl slang_ui::Hook for App {
104
104
) . op ( Op :: Eq , b)
105
105
}
106
106
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
- */
116
107
let mut post_conditions = Expr :: bool ( true ) ;
117
108
for post_condition in f. ensures ( ) {
118
109
post_conditions = post_conditions. and (
@@ -201,7 +192,6 @@ fn does_function_body_comply_with_postconditions_in_isolated_scope(
201
192
span : b. span . clone ( )
202
193
} )
203
194
} ;
204
- //specifications.push(ensures_body);
205
195
let mut requires: Vec < Specification > = Vec :: new ( ) ;
206
196
for specification in & f. specifications {
207
197
if let Specification :: Requires { .. } = specification {
@@ -230,36 +220,11 @@ fn does_function_body_comply_with_postconditions_in_isolated_scope(
230
220
span : b. span . clone ( )
231
221
} )
232
222
} ;
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
- */
241
223
242
- //println!("Axiom only post_conditions: {:#?}", axiom_only_post_conditions.to_string());
243
- //println!("Method post conditions: {:#?}", method_ensures_post_conditions);
244
224
return solver. scope ( |solver| {
245
225
solver. assert ( expr_to_smt ( & axiom_only_post_conditions) ?. as_bool ( ) ?) ?;
246
226
verify_method ( true , & method_ensures_post_conditions, cx, solver)
247
227
} ) ;
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
- */
263
228
}
264
229
Ok ( ( ) )
265
230
}
@@ -273,7 +238,6 @@ fn expr_to_smt(expr: &Expr) -> Result<Dynamic, Error> {
273
238
}
274
239
275
240
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);
277
241
// Get method's preconditions;
278
242
let pres = m. requires ( ) ;
279
243
// Merge them into a single condition
@@ -292,7 +256,6 @@ fn verify_method(is_function: bool, m: &Method, cx: &mut slang_ui::Context, solv
292
256
// However, we check for satisfiability of !(precondition -> wp_predicate)
293
257
// which is equivalent to !(!precondition or wp_predicate) == precondition and !wp_predicate
294
258
// Therefore we assert the precondition and later on assert the negation of each of the wp_predicate's
295
- //println!("Spre: {:#?}", spre);
296
259
solver. assert ( spre. as_bool ( ) ?) ?;
297
260
298
261
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
374
337
) ?;
375
338
376
339
ivl = ivl. seq ( & ivl_encoding) ;
377
- //println!("IVL:\n{:#?}", ivl);
378
340
379
341
let dsa = ivl_to_dsa ( & ivl, & mut HashMap :: new ( ) ) ?;
380
342
381
-
382
- //println!("Method {} IVL {:#?}", m.name.to_string(), ivl.to_string());
383
-
384
343
// Calculate obligation and error message (if obligation is not
385
344
// verified)
386
345
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
403
362
// If the obligations result not valid, report the error (on
404
363
// the span in which the error happens)
405
364
smtlib:: SatResult :: Sat => {
406
- //println!("{}", format!("expr: {expr} span_start: {} span_end: {}", span.start(), span.end()));
407
365
cx. error ( span, format ! ( "{}" , msg) ) ;
408
366
res = Err ( Error :: UnexpectedSatResult { expected : SatResult :: Unsat , actual : SatResult :: Sat } ) ;
409
367
}
@@ -446,11 +404,9 @@ fn does_method_modify_unspecified_global_variables(
446
404
None
447
405
}
448
406
CmdKind :: Assignment { name, .. } => {
449
- //println!("Searching for {} in symbol table {:#?}", name, symbol_table);
450
407
if symbol_table. contains ( & name. to_string ( ) ) {
451
408
return None
452
409
}
453
- //println!("Searching for {} in global variables {:#?}", name, specified_global_variables);
454
410
if specified_global_variables. contains ( & name. to_string ( ) ) {
455
411
return None
456
412
}
@@ -508,7 +464,6 @@ fn ivl_to_dsa(ivl: &IVLCmd, varmap: &mut HashMap<Ident, (Ident, Type)>) -> Resul
508
464
// get new ident for name and update it in the map
509
465
let new_ident = get_fresh_var_name ( & name. ident ) ;
510
466
varmap. insert ( name. ident . clone ( ) , ( new_ident. clone ( ) , expr. ty . clone ( ) ) ) ;
511
- // assume new_ident == dsa
512
467
Ok ( assume_equality (
513
468
& Expr :: new_typed ( ExprKind :: Ident ( new_ident) , expr. ty . clone ( ) ) ,
514
469
& dsa
@@ -638,8 +593,6 @@ fn extract_identifiers_from_expression(expr: &Expr, ignored_quantified_identifie
638
593
}
639
594
}
640
595
641
- // Encoding of (assert-only) statements into IVL (for programs comprised of only
642
- // a single assertion)
643
596
fn cmd_to_ivlcmd ( cmd : & Cmd , method_context : & MethodContext , loop_context : & LoopContext ) -> Result < IVLCmd , Error > {
644
597
let & Cmd { kind, span, .. } = & cmd;
645
598
Ok ( match kind {
@@ -819,7 +772,6 @@ fn return_to_ivl(expr: Option<&Expr>, span: &Span, method_context: &MethodContex
819
772
for post_condition in method_context. post_conditions . clone ( ) {
820
773
let mut replaced_old = replace_old_in_expression ( & post_condition, & method_context. global_variables_old_values ) ;
821
774
replaced_old. span = post_condition. span . clone ( ) ;
822
- //println!("replace_old {}", replaced_old);
823
775
// assert method_post_conditions
824
776
result = result. seq ( & IVLCmd :: assert (
825
777
& replaced_old,
@@ -847,7 +799,6 @@ fn return_to_ivl(expr: Option<&Expr>, span: &Span, method_context: &MethodContex
847
799
for post_condition in method_context. post_conditions . clone ( ) {
848
800
let mut replaced_old = replace_old_in_expression ( & post_condition, & method_context. global_variables_old_values ) ;
849
801
replaced_old. span = span. clone ( ) ;
850
- //println!("replace_old {}", replaced_old);
851
802
// assert method_post_conditions
852
803
result = result. seq ( & IVLCmd :: assert (
853
804
& replaced_old,
@@ -947,7 +898,6 @@ fn loop_to_ivl(invariants: &Vec<Expr>, variant: &Option<Expr>, cases: &Cases, me
947
898
case_condition_prefix = case_condition_prefix. seq ( & IVLCmd :: assume ( & case. condition . clone ( ) . prefix ( PrefixOp :: Not ) ) ) ;
948
899
let break_paths = find_break_paths ( & case. cmd , assume_case, method_context, loop_context) ?;
949
900
for break_path in break_paths {
950
- //eprintln!("break_path {:#?}", break_path);
951
901
body_translation = body_translation. nondet ( & break_path)
952
902
}
953
903
@@ -1266,7 +1216,6 @@ fn wp_set_seq(cmd1: &Box<IVLCmd>, cmd2: &Box<IVLCmd>, post_condition: Vec<Weakes
1266
1216
return Ok ( wp_set1) ;
1267
1217
}
1268
1218
1269
- // f (e, i, v) -> e[i <- v]
1270
1219
fn replace_in_expression ( original_expression : & Expr , identifier : & Name , replace_with_identifier : & Expr ) -> Expr {
1271
1220
let mut result = match & original_expression. kind {
1272
1221
ExprKind :: Ident ( name) if name. 0 == identifier. ident . 0 => replace_with_identifier. clone ( ) ,
0 commit comments