From bcde99fbe99174a094f38fdda70ad69d65a423f4 Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Wed, 30 Apr 2014 17:19:08 +0200 Subject: Fist commit (WIP) --- .gitignore | 3 + Makefile | 13 + Makefile.bad | 155 ++++ TODO | 6 + _tags | 1 + abstract/constant_domain.ml | 18 + abstract/domain.ml | 7 + analyze | 1 + examples/gcd.c | 12 + examples/gcd_nd.c | 15 + examples/loop.c | 3 + examples/loop2.c | 2 + examples/loop3.c | 3 + examples/loop4.c | 2 + frontend/abstract_syntax_printer.ml | 242 +++++ frontend/abstract_syntax_printer.mli | 31 + frontend/abstract_syntax_tree.ml | 212 +++++ frontend/file_parser.ml | 32 + frontend/file_parser.mli | 10 + frontend/lexer.mll | 114 +++ frontend/parser.mly | 247 +++++ libs/mapext.ml | 741 +++++++++++++++ libs/mapext.mli | 473 ++++++++++ main.ml | 27 + tests/README.txt | 32 + tests/results/0000_noinit_var.constants.txt | 1 + tests/results/0000_noinit_var.intervals.txt | 1 + tests/results/0000_noinit_var.polyhedra.txt | 1 + tests/results/0001_noinit_2var.constants.txt | 1 + tests/results/0001_noinit_2var.intervals.txt | 1 + tests/results/0001_noinit_2var.polyhedra.txt | 1 + tests/results/0002_init_var.constants.txt | 1 + tests/results/0002_init_var.intervals.txt | 1 + tests/results/0002_init_var.polyhedra.txt | 1 + tests/results/0003_init_2var.constants.txt | 1 + tests/results/0003_init_2var.intervals.txt | 1 + tests/results/0003_init_2var.polyhedra.txt | 1 + tests/results/0004_init_2var2.constants.txt | 1 + tests/results/0004_init_2var2.intervals.txt | 1 + tests/results/0004_init_2var2.polyhedra.txt | 1 + tests/results/0100_print_var.constants.txt | 2 + tests/results/0100_print_var.intervals.txt | 2 + tests/results/0100_print_var.polyhedra.txt | 2 + tests/results/0101_print_2var.constants.txt | 2 + tests/results/0101_print_2var.intervals.txt | 2 + tests/results/0101_print_2var.polyhedra.txt | 2 + tests/results/0102_print_3var.constants.txt | 2 + tests/results/0102_print_3var.intervals.txt | 2 + tests/results/0102_print_3var.polyhedra.txt | 2 + tests/results/0103_local.constants.txt | 2 + tests/results/0103_local.intervals.txt | 2 + tests/results/0103_local.polyhedra.txt | 2 + tests/results/0200_assign_cst.constants.txt | 4 + tests/results/0200_assign_cst.intervals.txt | 4 + tests/results/0200_assign_cst.polyhedra.txt | 4 + tests/results/0201_assign_cst2.constants.txt | 4 + tests/results/0201_assign_cst2.intervals.txt | 4 + tests/results/0201_assign_cst2.polyhedra.txt | 4 + tests/results/0202_assign_expr.constants.txt | 1 + tests/results/0202_assign_expr.intervals.txt | 1 + tests/results/0202_assign_expr.polyhedra.txt | 1 + tests/results/0203_assign_expr2.constants.txt | 2 + tests/results/0203_assign_expr2.intervals.txt | 2 + tests/results/0203_assign_expr2.polyhedra.txt | 2 + tests/results/0204_assign_rand.constants.txt | 2 + tests/results/0204_assign_rand.intervals.txt | 2 + tests/results/0204_assign_rand.polyhedra.txt | 2 + tests/results/0205_assign_rand2.constants.txt | 2 + tests/results/0205_assign_rand2.intervals.txt | 2 + tests/results/0205_assign_rand2.polyhedra.txt | 2 + tests/results/0206_assign_add.constants.txt | 1 + tests/results/0206_assign_add.intervals.txt | 1 + tests/results/0206_assign_add.polyhedra.txt | 1 + tests/results/0207_assign_add2.constants.txt | 1 + tests/results/0207_assign_add2.intervals.txt | 1 + tests/results/0207_assign_add2.polyhedra.txt | 1 + tests/results/0208_assign_add3.constants.txt | 1 + tests/results/0208_assign_add3.intervals.txt | 1 + tests/results/0208_assign_add3.polyhedra.txt | 1 + tests/results/0209_assign_neg.constants.txt | 1 + tests/results/0209_assign_neg.intervals.txt | 1 + tests/results/0209_assign_neg.polyhedra.txt | 1 + tests/results/0210_assign_neg2.constants.txt | 1 + tests/results/0210_assign_neg2.intervals.txt | 1 + tests/results/0210_assign_neg2.polyhedra.txt | 1 + tests/results/0211_assign_sub.constants.txt | 1 + tests/results/0211_assign_sub.intervals.txt | 1 + tests/results/0211_assign_sub.polyhedra.txt | 1 + tests/results/0212_assign_sub2.constants.txt | 1 + tests/results/0212_assign_sub2.intervals.txt | 1 + tests/results/0212_assign_sub2.polyhedra.txt | 1 + tests/results/0213_assign_mul.constants.txt | 1 + tests/results/0213_assign_mul.intervals.txt | 1 + tests/results/0213_assign_mul.polyhedra.txt | 1 + tests/results/0214_assign_mul2.constants.txt | 1 + tests/results/0214_assign_mul2.intervals.txt | 1 + tests/results/0214_assign_mul2.polyhedra.txt | 1 + tests/results/0215_assign_mul3.constants.txt | 1 + tests/results/0215_assign_mul3.intervals.txt | 1 + tests/results/0215_assign_mul3.polyhedra.txt | 1 + tests/results/0216_assign_mul4.constants.txt | 1 + tests/results/0216_assign_mul4.intervals.txt | 1 + tests/results/0216_assign_mul4.polyhedra.txt | 1 + tests/results/0217_assign_copy.constants.txt | 2 + tests/results/0217_assign_copy.intervals.txt | 2 + tests/results/0217_assign_copy.polyhedra.txt | 2 + tests/results/0218_assign_rel.constants.txt | 2 + tests/results/0218_assign_rel.intervals.txt | 2 + tests/results/0218_assign_rel.polyhedra.txt | 2 + tests/results/0219_assign_rel2.constants.txt | 1 + tests/results/0219_assign_rel2.intervals.txt | 1 + tests/results/0219_assign_rel2.polyhedra.txt | 1 + tests/results/0300_if_true.constants.txt | 1 + tests/results/0300_if_true.intervals.txt | 1 + tests/results/0300_if_true.polyhedra.txt | 1 + tests/results/0301_if_false.constants.txt | 1 + tests/results/0301_if_false.intervals.txt | 1 + tests/results/0301_if_false.polyhedra.txt | 1 + tests/results/0302_if_both.constants.txt | 1 + tests/results/0302_if_both.intervals.txt | 1 + tests/results/0302_if_both.polyhedra.txt | 1 + tests/results/0303_if_else_true.constants.txt | 1 + tests/results/0303_if_else_true.intervals.txt | 1 + tests/results/0303_if_else_true.polyhedra.txt | 1 + tests/results/0304_if_else_false.constants.txt | 1 + tests/results/0304_if_else_false.intervals.txt | 1 + tests/results/0304_if_else_false.polyhedra.txt | 1 + tests/results/0305_if_else_both.constants.txt | 1 + tests/results/0305_if_else_both.intervals.txt | 1 + tests/results/0305_if_else_both.polyhedra.txt | 1 + tests/results/0306_if_rel.constants.txt | 1 + tests/results/0306_if_rel.intervals.txt | 1 + tests/results/0306_if_rel.polyhedra.txt | 1 + tests/results/0307_if_var.constants.txt | 3 + tests/results/0307_if_var.intervals.txt | 3 + tests/results/0307_if_var.polyhedra.txt | 3 + tests/results/0308_if_var2.constants.txt | 1 + tests/results/0308_if_var2.intervals.txt | 1 + tests/results/0308_if_var2.polyhedra.txt | 1 + tests/results/0309_if_var_rel.constants.txt | 1 + tests/results/0309_if_var_rel.intervals.txt | 1 + tests/results/0309_if_var_rel.polyhedra.txt | 1 + tests/results/0310_cmp_le.constants.txt | 2 + tests/results/0310_cmp_le.intervals.txt | 2 + tests/results/0310_cmp_le.polyhedra.txt | 3 + tests/results/0311_cmp_le2.constants.txt | 2 + tests/results/0311_cmp_le2.intervals.txt | 2 + tests/results/0311_cmp_le2.polyhedra.txt | 2 + tests/results/0312_cmp_le3.constants.txt | 2 + tests/results/0312_cmp_le3.intervals.txt | 2 + tests/results/0312_cmp_le3.polyhedra.txt | 2 + tests/results/0313_cmp_lt.constants.txt | 2 + tests/results/0313_cmp_lt.intervals.txt | 2 + tests/results/0313_cmp_lt.polyhedra.txt | 2 + tests/results/0314_cmp_ge.constants.txt | 2 + tests/results/0314_cmp_ge.intervals.txt | 2 + tests/results/0314_cmp_ge.polyhedra.txt | 2 + tests/results/0315_cmp_gt.constants.txt | 2 + tests/results/0315_cmp_gt.intervals.txt | 2 + tests/results/0315_cmp_gt.polyhedra.txt | 2 + tests/results/0316_cmp_eq.constants.txt | 2 + tests/results/0316_cmp_eq.intervals.txt | 2 + tests/results/0316_cmp_eq.polyhedra.txt | 2 + tests/results/0317_cmp_eq2.constants.txt | 2 + tests/results/0317_cmp_eq2.intervals.txt | 2 + tests/results/0317_cmp_eq2.polyhedra.txt | 2 + tests/results/0318_cmp_ne.constants.txt | 2 + tests/results/0318_cmp_ne.intervals.txt | 2 + tests/results/0318_cmp_ne.polyhedra.txt | 3 + tests/results/0319_cmp_ne.constants.txt | 2 + tests/results/0319_cmp_ne.intervals.txt | 2 + tests/results/0319_cmp_ne.polyhedra.txt | 2 + tests/results/0320_cmp_eq_ne.constants.txt | 3 + tests/results/0320_cmp_eq_ne.intervals.txt | 3 + tests/results/0320_cmp_eq_ne.polyhedra.txt | 3 + tests/results/0321_cmp_rel.constants.txt | 2 + tests/results/0321_cmp_rel.intervals.txt | 2 + tests/results/0321_cmp_rel.polyhedra.txt | 2 + tests/results/0322_if_and.constants.txt | 3 + tests/results/0322_if_and.intervals.txt | 3 + tests/results/0322_if_and.polyhedra.txt | 4 + tests/results/0323_if_or.constants.txt | 3 + tests/results/0323_if_or.intervals.txt | 3 + tests/results/0323_if_or.polyhedra.txt | 4 + tests/results/0324_if_not.constants.txt | 3 + tests/results/0324_if_not.intervals.txt | 3 + tests/results/0324_if_not.polyhedra.txt | 4 + tests/results/0325_if_bool.constants.txt | 3 + tests/results/0325_if_bool.intervals.txt | 3 + tests/results/0325_if_bool.polyhedra.txt | 5 + tests/results/0400_assert_true.constants.txt | 1 + tests/results/0400_assert_true.intervals.txt | 1 + tests/results/0400_assert_true.polyhedra.txt | 1 + tests/results/0401_assert_false.constants.txt | 2 + tests/results/0401_assert_false.intervals.txt | 2 + tests/results/0401_assert_false.polyhedra.txt | 2 + tests/results/0402_assert_both.constants.txt | 3 + tests/results/0402_assert_both.intervals.txt | 3 + tests/results/0402_assert_both.polyhedra.txt | 3 + tests/results/0403_assert_both2.constants.txt | 3 + tests/results/0403_assert_both2.intervals.txt | 2 + tests/results/0403_assert_both2.polyhedra.txt | 2 + tests/results/0404_assert_rel.constants.txt | 2 + tests/results/0404_assert_rel.intervals.txt | 2 + tests/results/0404_assert_rel.polyhedra.txt | 1 + tests/results/0500_loop_count.constants.txt | 5 + tests/results/0500_loop_count.intervals.txt | 5 + tests/results/0500_loop_count.polyhedra.txt | 5 + tests/results/0501_loop_infinite.constants.txt | 5 + tests/results/0501_loop_infinite.intervals.txt | 5 + tests/results/0501_loop_infinite.polyhedra.txt | 5 + tests/results/0502_loop_infinite2.constants.txt | 5 + tests/results/0502_loop_infinite2.intervals.txt | 5 + tests/results/0502_loop_infinite2.polyhedra.txt | 5 + tests/results/0503_loop_nondet.constants.txt | 5 + tests/results/0503_loop_nondet.intervals.txt | 5 + tests/results/0503_loop_nondet.polyhedra.txt | 5 + tests/results/0504_loop_rel.constants.txt | 6 + tests/results/0504_loop_rel.intervals.txt | 6 + tests/results/0504_loop_rel.polyhedra.txt | 5 + tests/results/0505_loop_rel2.constants.txt | 6 + tests/results/0505_loop_rel2.intervals.txt | 6 + tests/results/0505_loop_rel2.polyhedra.txt | 5 + tests/results/0506_loop_limit.constants.txt | 2 + tests/results/0506_loop_limit.intervals.txt | 2 + tests/results/0506_loop_limit.polyhedra.txt | 2 + tests/results/0507_loop_limit2.constants.txt | 2 + tests/results/0507_loop_limit2.intervals.txt | 2 + tests/results/0507_loop_limit2.polyhedra.txt | 2 + tests/results/0508_loop_init.constants.txt | 2 + tests/results/0508_loop_init.intervals.txt | 1 + tests/results/0508_loop_init.polyhedra.txt | 1 + tests/results/0509_loop_nested.constants.txt | 1 + tests/results/0509_loop_nested.intervals.txt | 1 + tests/results/0509_loop_nested.polyhedra.txt | 1 + tests/results/0510_loop_nested2.constants.txt | 1 + tests/results/0510_loop_nested2.intervals.txt | 1 + tests/results/0510_loop_nested2.polyhedra.txt | 1 + tests/results/0600_bubble_sort.constants.txt | 33 + tests/results/0600_bubble_sort.intervals.txt | 25 + tests/results/0600_bubble_sort.polyhedra.txt | 1 + tests/results/0601_heap_sort.constants.txt | 104 +++ tests/results/0601_heap_sort.intervals.txt | 95 ++ tests/results/0601_heap_sort.polyhedra.txt | 1 + tests/results/0602_rate_limiter.constants.txt | 2 + tests/results/0602_rate_limiter.intervals.txt | 2 + tests/results/0602_rate_limiter.polyhedra.txt | 2 + tests/results/0603_rate_limiter2.constants.txt | 5 + tests/results/0603_rate_limiter2.intervals.txt | 4 + tests/results/0603_rate_limiter2.polyhedra.txt | 1 + tests/results/all.constants.txt | 1135 +++++++++++++++++++++++ tests/results/all.intervals.txt | 1115 ++++++++++++++++++++++ tests/results/all.polyhedra.txt | 998 ++++++++++++++++++++ tests/sources/0000_noinit_var.c | 1 + tests/sources/0001_noinit_2var.c | 2 + tests/sources/0002_init_var.c | 1 + tests/sources/0003_init_2var.c | 2 + tests/sources/0004_init_2var2.c | 1 + tests/sources/0100_print_var.c | 2 + tests/sources/0101_print_2var.c | 3 + tests/sources/0102_print_3var.c | 4 + tests/sources/0103_local.c | 5 + tests/sources/0200_assign_cst.c | 6 + tests/sources/0201_assign_cst2.c | 7 + tests/sources/0202_assign_expr.c | 2 + tests/sources/0203_assign_expr2.c | 5 + tests/sources/0204_assign_rand.c | 3 + tests/sources/0205_assign_rand2.c | 3 + tests/sources/0206_assign_add.c | 2 + tests/sources/0207_assign_add2.c | 2 + tests/sources/0208_assign_add3.c | 2 + tests/sources/0209_assign_neg.c | 2 + tests/sources/0210_assign_neg2.c | 3 + tests/sources/0211_assign_sub.c | 2 + tests/sources/0212_assign_sub2.c | 2 + tests/sources/0213_assign_mul.c | 2 + tests/sources/0214_assign_mul2.c | 2 + tests/sources/0215_assign_mul3.c | 2 + tests/sources/0216_assign_mul4.c | 2 + tests/sources/0217_assign_copy.c | 5 + tests/sources/0218_assign_rel.c | 5 + tests/sources/0219_assign_rel2.c | 3 + tests/sources/0300_if_true.c | 2 + tests/sources/0301_if_false.c | 2 + tests/sources/0302_if_both.c | 2 + tests/sources/0303_if_else_true.c | 2 + tests/sources/0304_if_else_false.c | 2 + tests/sources/0305_if_else_both.c | 2 + tests/sources/0306_if_rel.c | 3 + tests/sources/0307_if_var.c | 3 + tests/sources/0308_if_var2.c | 2 + tests/sources/0309_if_var_rel.c | 3 + tests/sources/0310_cmp_le.c | 3 + tests/sources/0311_cmp_le2.c | 3 + tests/sources/0312_cmp_le3.c | 3 + tests/sources/0313_cmp_lt.c | 3 + tests/sources/0314_cmp_ge.c | 3 + tests/sources/0315_cmp_gt.c | 3 + tests/sources/0316_cmp_eq.c | 3 + tests/sources/0317_cmp_eq2.c | 3 + tests/sources/0318_cmp_ne.c | 3 + tests/sources/0319_cmp_ne.c | 3 + tests/sources/0320_cmp_eq_ne.c | 5 + tests/sources/0321_cmp_rel.c | 3 + tests/sources/0322_if_and.c | 4 + tests/sources/0323_if_or.c | 4 + tests/sources/0324_if_not.c | 4 + tests/sources/0325_if_bool.c | 4 + tests/sources/0400_assert_true.c | 2 + tests/sources/0401_assert_false.c | 2 + tests/sources/0402_assert_both.c | 3 + tests/sources/0403_assert_both2.c | 3 + tests/sources/0404_assert_rel.c | 4 + tests/sources/0500_loop_count.c | 5 + tests/sources/0501_loop_infinite.c | 4 + tests/sources/0502_loop_infinite2.c | 5 + tests/sources/0503_loop_nondet.c | 5 + tests/sources/0504_loop_rel.c | 7 + tests/sources/0505_loop_rel2.c | 7 + tests/sources/0506_loop_limit.c | 5 + tests/sources/0507_loop_limit2.c | 6 + tests/sources/0508_loop_init.c | 14 + tests/sources/0509_loop_nested.c | 9 + tests/sources/0510_loop_nested2.c | 10 + tests/sources/0600_bubble_sort.c | 32 + tests/sources/0601_heap_sort.c | 66 ++ tests/sources/0602_rate_limiter.c | 26 + tests/sources/0603_rate_limiter2.c | 21 + 328 files changed, 6753 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 Makefile.bad create mode 100644 TODO create mode 100644 _tags create mode 100644 abstract/constant_domain.ml create mode 100644 abstract/domain.ml create mode 120000 analyze create mode 100644 examples/gcd.c create mode 100644 examples/gcd_nd.c create mode 100644 examples/loop.c create mode 100644 examples/loop2.c create mode 100644 examples/loop3.c create mode 100644 examples/loop4.c create mode 100644 frontend/abstract_syntax_printer.ml create mode 100644 frontend/abstract_syntax_printer.mli create mode 100644 frontend/abstract_syntax_tree.ml create mode 100644 frontend/file_parser.ml create mode 100644 frontend/file_parser.mli create mode 100644 frontend/lexer.mll create mode 100644 frontend/parser.mly create mode 100644 libs/mapext.ml create mode 100644 libs/mapext.mli create mode 100644 main.ml create mode 100644 tests/README.txt create mode 100644 tests/results/0000_noinit_var.constants.txt create mode 100644 tests/results/0000_noinit_var.intervals.txt create mode 100644 tests/results/0000_noinit_var.polyhedra.txt create mode 100644 tests/results/0001_noinit_2var.constants.txt create mode 100644 tests/results/0001_noinit_2var.intervals.txt create mode 100644 tests/results/0001_noinit_2var.polyhedra.txt create mode 100644 tests/results/0002_init_var.constants.txt create mode 100644 tests/results/0002_init_var.intervals.txt create mode 100644 tests/results/0002_init_var.polyhedra.txt create mode 100644 tests/results/0003_init_2var.constants.txt create mode 100644 tests/results/0003_init_2var.intervals.txt create mode 100644 tests/results/0003_init_2var.polyhedra.txt create mode 100644 tests/results/0004_init_2var2.constants.txt create mode 100644 tests/results/0004_init_2var2.intervals.txt create mode 100644 tests/results/0004_init_2var2.polyhedra.txt create mode 100644 tests/results/0100_print_var.constants.txt create mode 100644 tests/results/0100_print_var.intervals.txt create mode 100644 tests/results/0100_print_var.polyhedra.txt create mode 100644 tests/results/0101_print_2var.constants.txt create mode 100644 tests/results/0101_print_2var.intervals.txt create mode 100644 tests/results/0101_print_2var.polyhedra.txt create mode 100644 tests/results/0102_print_3var.constants.txt create mode 100644 tests/results/0102_print_3var.intervals.txt create mode 100644 tests/results/0102_print_3var.polyhedra.txt create mode 100644 tests/results/0103_local.constants.txt create mode 100644 tests/results/0103_local.intervals.txt create mode 100644 tests/results/0103_local.polyhedra.txt create mode 100644 tests/results/0200_assign_cst.constants.txt create mode 100644 tests/results/0200_assign_cst.intervals.txt create mode 100644 tests/results/0200_assign_cst.polyhedra.txt create mode 100644 tests/results/0201_assign_cst2.constants.txt create mode 100644 tests/results/0201_assign_cst2.intervals.txt create mode 100644 tests/results/0201_assign_cst2.polyhedra.txt create mode 100644 tests/results/0202_assign_expr.constants.txt create mode 100644 tests/results/0202_assign_expr.intervals.txt create mode 100644 tests/results/0202_assign_expr.polyhedra.txt create mode 100644 tests/results/0203_assign_expr2.constants.txt create mode 100644 tests/results/0203_assign_expr2.intervals.txt create mode 100644 tests/results/0203_assign_expr2.polyhedra.txt create mode 100644 tests/results/0204_assign_rand.constants.txt create mode 100644 tests/results/0204_assign_rand.intervals.txt create mode 100644 tests/results/0204_assign_rand.polyhedra.txt create mode 100644 tests/results/0205_assign_rand2.constants.txt create mode 100644 tests/results/0205_assign_rand2.intervals.txt create mode 100644 tests/results/0205_assign_rand2.polyhedra.txt create mode 100644 tests/results/0206_assign_add.constants.txt create mode 100644 tests/results/0206_assign_add.intervals.txt create mode 100644 tests/results/0206_assign_add.polyhedra.txt create mode 100644 tests/results/0207_assign_add2.constants.txt create mode 100644 tests/results/0207_assign_add2.intervals.txt create mode 100644 tests/results/0207_assign_add2.polyhedra.txt create mode 100644 tests/results/0208_assign_add3.constants.txt create mode 100644 tests/results/0208_assign_add3.intervals.txt create mode 100644 tests/results/0208_assign_add3.polyhedra.txt create mode 100644 tests/results/0209_assign_neg.constants.txt create mode 100644 tests/results/0209_assign_neg.intervals.txt create mode 100644 tests/results/0209_assign_neg.polyhedra.txt create mode 100644 tests/results/0210_assign_neg2.constants.txt create mode 100644 tests/results/0210_assign_neg2.intervals.txt create mode 100644 tests/results/0210_assign_neg2.polyhedra.txt create mode 100644 tests/results/0211_assign_sub.constants.txt create mode 100644 tests/results/0211_assign_sub.intervals.txt create mode 100644 tests/results/0211_assign_sub.polyhedra.txt create mode 100644 tests/results/0212_assign_sub2.constants.txt create mode 100644 tests/results/0212_assign_sub2.intervals.txt create mode 100644 tests/results/0212_assign_sub2.polyhedra.txt create mode 100644 tests/results/0213_assign_mul.constants.txt create mode 100644 tests/results/0213_assign_mul.intervals.txt create mode 100644 tests/results/0213_assign_mul.polyhedra.txt create mode 100644 tests/results/0214_assign_mul2.constants.txt create mode 100644 tests/results/0214_assign_mul2.intervals.txt create mode 100644 tests/results/0214_assign_mul2.polyhedra.txt create mode 100644 tests/results/0215_assign_mul3.constants.txt create mode 100644 tests/results/0215_assign_mul3.intervals.txt create mode 100644 tests/results/0215_assign_mul3.polyhedra.txt create mode 100644 tests/results/0216_assign_mul4.constants.txt create mode 100644 tests/results/0216_assign_mul4.intervals.txt create mode 100644 tests/results/0216_assign_mul4.polyhedra.txt create mode 100644 tests/results/0217_assign_copy.constants.txt create mode 100644 tests/results/0217_assign_copy.intervals.txt create mode 100644 tests/results/0217_assign_copy.polyhedra.txt create mode 100644 tests/results/0218_assign_rel.constants.txt create mode 100644 tests/results/0218_assign_rel.intervals.txt create mode 100644 tests/results/0218_assign_rel.polyhedra.txt create mode 100644 tests/results/0219_assign_rel2.constants.txt create mode 100644 tests/results/0219_assign_rel2.intervals.txt create mode 100644 tests/results/0219_assign_rel2.polyhedra.txt create mode 100644 tests/results/0300_if_true.constants.txt create mode 100644 tests/results/0300_if_true.intervals.txt create mode 100644 tests/results/0300_if_true.polyhedra.txt create mode 100644 tests/results/0301_if_false.constants.txt create mode 100644 tests/results/0301_if_false.intervals.txt create mode 100644 tests/results/0301_if_false.polyhedra.txt create mode 100644 tests/results/0302_if_both.constants.txt create mode 100644 tests/results/0302_if_both.intervals.txt create mode 100644 tests/results/0302_if_both.polyhedra.txt create mode 100644 tests/results/0303_if_else_true.constants.txt create mode 100644 tests/results/0303_if_else_true.intervals.txt create mode 100644 tests/results/0303_if_else_true.polyhedra.txt create mode 100644 tests/results/0304_if_else_false.constants.txt create mode 100644 tests/results/0304_if_else_false.intervals.txt create mode 100644 tests/results/0304_if_else_false.polyhedra.txt create mode 100644 tests/results/0305_if_else_both.constants.txt create mode 100644 tests/results/0305_if_else_both.intervals.txt create mode 100644 tests/results/0305_if_else_both.polyhedra.txt create mode 100644 tests/results/0306_if_rel.constants.txt create mode 100644 tests/results/0306_if_rel.intervals.txt create mode 100644 tests/results/0306_if_rel.polyhedra.txt create mode 100644 tests/results/0307_if_var.constants.txt create mode 100644 tests/results/0307_if_var.intervals.txt create mode 100644 tests/results/0307_if_var.polyhedra.txt create mode 100644 tests/results/0308_if_var2.constants.txt create mode 100644 tests/results/0308_if_var2.intervals.txt create mode 100644 tests/results/0308_if_var2.polyhedra.txt create mode 100644 tests/results/0309_if_var_rel.constants.txt create mode 100644 tests/results/0309_if_var_rel.intervals.txt create mode 100644 tests/results/0309_if_var_rel.polyhedra.txt create mode 100644 tests/results/0310_cmp_le.constants.txt create mode 100644 tests/results/0310_cmp_le.intervals.txt create mode 100644 tests/results/0310_cmp_le.polyhedra.txt create mode 100644 tests/results/0311_cmp_le2.constants.txt create mode 100644 tests/results/0311_cmp_le2.intervals.txt create mode 100644 tests/results/0311_cmp_le2.polyhedra.txt create mode 100644 tests/results/0312_cmp_le3.constants.txt create mode 100644 tests/results/0312_cmp_le3.intervals.txt create mode 100644 tests/results/0312_cmp_le3.polyhedra.txt create mode 100644 tests/results/0313_cmp_lt.constants.txt create mode 100644 tests/results/0313_cmp_lt.intervals.txt create mode 100644 tests/results/0313_cmp_lt.polyhedra.txt create mode 100644 tests/results/0314_cmp_ge.constants.txt create mode 100644 tests/results/0314_cmp_ge.intervals.txt create mode 100644 tests/results/0314_cmp_ge.polyhedra.txt create mode 100644 tests/results/0315_cmp_gt.constants.txt create mode 100644 tests/results/0315_cmp_gt.intervals.txt create mode 100644 tests/results/0315_cmp_gt.polyhedra.txt create mode 100644 tests/results/0316_cmp_eq.constants.txt create mode 100644 tests/results/0316_cmp_eq.intervals.txt create mode 100644 tests/results/0316_cmp_eq.polyhedra.txt create mode 100644 tests/results/0317_cmp_eq2.constants.txt create mode 100644 tests/results/0317_cmp_eq2.intervals.txt create mode 100644 tests/results/0317_cmp_eq2.polyhedra.txt create mode 100644 tests/results/0318_cmp_ne.constants.txt create mode 100644 tests/results/0318_cmp_ne.intervals.txt create mode 100644 tests/results/0318_cmp_ne.polyhedra.txt create mode 100644 tests/results/0319_cmp_ne.constants.txt create mode 100644 tests/results/0319_cmp_ne.intervals.txt create mode 100644 tests/results/0319_cmp_ne.polyhedra.txt create mode 100644 tests/results/0320_cmp_eq_ne.constants.txt create mode 100644 tests/results/0320_cmp_eq_ne.intervals.txt create mode 100644 tests/results/0320_cmp_eq_ne.polyhedra.txt create mode 100644 tests/results/0321_cmp_rel.constants.txt create mode 100644 tests/results/0321_cmp_rel.intervals.txt create mode 100644 tests/results/0321_cmp_rel.polyhedra.txt create mode 100644 tests/results/0322_if_and.constants.txt create mode 100644 tests/results/0322_if_and.intervals.txt create mode 100644 tests/results/0322_if_and.polyhedra.txt create mode 100644 tests/results/0323_if_or.constants.txt create mode 100644 tests/results/0323_if_or.intervals.txt create mode 100644 tests/results/0323_if_or.polyhedra.txt create mode 100644 tests/results/0324_if_not.constants.txt create mode 100644 tests/results/0324_if_not.intervals.txt create mode 100644 tests/results/0324_if_not.polyhedra.txt create mode 100644 tests/results/0325_if_bool.constants.txt create mode 100644 tests/results/0325_if_bool.intervals.txt create mode 100644 tests/results/0325_if_bool.polyhedra.txt create mode 100644 tests/results/0400_assert_true.constants.txt create mode 100644 tests/results/0400_assert_true.intervals.txt create mode 100644 tests/results/0400_assert_true.polyhedra.txt create mode 100644 tests/results/0401_assert_false.constants.txt create mode 100644 tests/results/0401_assert_false.intervals.txt create mode 100644 tests/results/0401_assert_false.polyhedra.txt create mode 100644 tests/results/0402_assert_both.constants.txt create mode 100644 tests/results/0402_assert_both.intervals.txt create mode 100644 tests/results/0402_assert_both.polyhedra.txt create mode 100644 tests/results/0403_assert_both2.constants.txt create mode 100644 tests/results/0403_assert_both2.intervals.txt create mode 100644 tests/results/0403_assert_both2.polyhedra.txt create mode 100644 tests/results/0404_assert_rel.constants.txt create mode 100644 tests/results/0404_assert_rel.intervals.txt create mode 100644 tests/results/0404_assert_rel.polyhedra.txt create mode 100644 tests/results/0500_loop_count.constants.txt create mode 100644 tests/results/0500_loop_count.intervals.txt create mode 100644 tests/results/0500_loop_count.polyhedra.txt create mode 100644 tests/results/0501_loop_infinite.constants.txt create mode 100644 tests/results/0501_loop_infinite.intervals.txt create mode 100644 tests/results/0501_loop_infinite.polyhedra.txt create mode 100644 tests/results/0502_loop_infinite2.constants.txt create mode 100644 tests/results/0502_loop_infinite2.intervals.txt create mode 100644 tests/results/0502_loop_infinite2.polyhedra.txt create mode 100644 tests/results/0503_loop_nondet.constants.txt create mode 100644 tests/results/0503_loop_nondet.intervals.txt create mode 100644 tests/results/0503_loop_nondet.polyhedra.txt create mode 100644 tests/results/0504_loop_rel.constants.txt create mode 100644 tests/results/0504_loop_rel.intervals.txt create mode 100644 tests/results/0504_loop_rel.polyhedra.txt create mode 100644 tests/results/0505_loop_rel2.constants.txt create mode 100644 tests/results/0505_loop_rel2.intervals.txt create mode 100644 tests/results/0505_loop_rel2.polyhedra.txt create mode 100644 tests/results/0506_loop_limit.constants.txt create mode 100644 tests/results/0506_loop_limit.intervals.txt create mode 100644 tests/results/0506_loop_limit.polyhedra.txt create mode 100644 tests/results/0507_loop_limit2.constants.txt create mode 100644 tests/results/0507_loop_limit2.intervals.txt create mode 100644 tests/results/0507_loop_limit2.polyhedra.txt create mode 100644 tests/results/0508_loop_init.constants.txt create mode 100644 tests/results/0508_loop_init.intervals.txt create mode 100644 tests/results/0508_loop_init.polyhedra.txt create mode 100644 tests/results/0509_loop_nested.constants.txt create mode 100644 tests/results/0509_loop_nested.intervals.txt create mode 100644 tests/results/0509_loop_nested.polyhedra.txt create mode 100644 tests/results/0510_loop_nested2.constants.txt create mode 100644 tests/results/0510_loop_nested2.intervals.txt create mode 100644 tests/results/0510_loop_nested2.polyhedra.txt create mode 100644 tests/results/0600_bubble_sort.constants.txt create mode 100644 tests/results/0600_bubble_sort.intervals.txt create mode 100644 tests/results/0600_bubble_sort.polyhedra.txt create mode 100644 tests/results/0601_heap_sort.constants.txt create mode 100644 tests/results/0601_heap_sort.intervals.txt create mode 100644 tests/results/0601_heap_sort.polyhedra.txt create mode 100644 tests/results/0602_rate_limiter.constants.txt create mode 100644 tests/results/0602_rate_limiter.intervals.txt create mode 100644 tests/results/0602_rate_limiter.polyhedra.txt create mode 100644 tests/results/0603_rate_limiter2.constants.txt create mode 100644 tests/results/0603_rate_limiter2.intervals.txt create mode 100644 tests/results/0603_rate_limiter2.polyhedra.txt create mode 100644 tests/results/all.constants.txt create mode 100644 tests/results/all.intervals.txt create mode 100644 tests/results/all.polyhedra.txt create mode 100644 tests/sources/0000_noinit_var.c create mode 100644 tests/sources/0001_noinit_2var.c create mode 100644 tests/sources/0002_init_var.c create mode 100644 tests/sources/0003_init_2var.c create mode 100644 tests/sources/0004_init_2var2.c create mode 100644 tests/sources/0100_print_var.c create mode 100644 tests/sources/0101_print_2var.c create mode 100644 tests/sources/0102_print_3var.c create mode 100644 tests/sources/0103_local.c create mode 100644 tests/sources/0200_assign_cst.c create mode 100644 tests/sources/0201_assign_cst2.c create mode 100644 tests/sources/0202_assign_expr.c create mode 100644 tests/sources/0203_assign_expr2.c create mode 100644 tests/sources/0204_assign_rand.c create mode 100644 tests/sources/0205_assign_rand2.c create mode 100644 tests/sources/0206_assign_add.c create mode 100644 tests/sources/0207_assign_add2.c create mode 100644 tests/sources/0208_assign_add3.c create mode 100644 tests/sources/0209_assign_neg.c create mode 100644 tests/sources/0210_assign_neg2.c create mode 100644 tests/sources/0211_assign_sub.c create mode 100644 tests/sources/0212_assign_sub2.c create mode 100644 tests/sources/0213_assign_mul.c create mode 100644 tests/sources/0214_assign_mul2.c create mode 100644 tests/sources/0215_assign_mul3.c create mode 100644 tests/sources/0216_assign_mul4.c create mode 100644 tests/sources/0217_assign_copy.c create mode 100644 tests/sources/0218_assign_rel.c create mode 100644 tests/sources/0219_assign_rel2.c create mode 100644 tests/sources/0300_if_true.c create mode 100644 tests/sources/0301_if_false.c create mode 100644 tests/sources/0302_if_both.c create mode 100644 tests/sources/0303_if_else_true.c create mode 100644 tests/sources/0304_if_else_false.c create mode 100644 tests/sources/0305_if_else_both.c create mode 100644 tests/sources/0306_if_rel.c create mode 100644 tests/sources/0307_if_var.c create mode 100644 tests/sources/0308_if_var2.c create mode 100644 tests/sources/0309_if_var_rel.c create mode 100644 tests/sources/0310_cmp_le.c create mode 100644 tests/sources/0311_cmp_le2.c create mode 100644 tests/sources/0312_cmp_le3.c create mode 100644 tests/sources/0313_cmp_lt.c create mode 100644 tests/sources/0314_cmp_ge.c create mode 100644 tests/sources/0315_cmp_gt.c create mode 100644 tests/sources/0316_cmp_eq.c create mode 100644 tests/sources/0317_cmp_eq2.c create mode 100644 tests/sources/0318_cmp_ne.c create mode 100644 tests/sources/0319_cmp_ne.c create mode 100644 tests/sources/0320_cmp_eq_ne.c create mode 100644 tests/sources/0321_cmp_rel.c create mode 100644 tests/sources/0322_if_and.c create mode 100644 tests/sources/0323_if_or.c create mode 100644 tests/sources/0324_if_not.c create mode 100644 tests/sources/0325_if_bool.c create mode 100644 tests/sources/0400_assert_true.c create mode 100644 tests/sources/0401_assert_false.c create mode 100644 tests/sources/0402_assert_both.c create mode 100644 tests/sources/0403_assert_both2.c create mode 100644 tests/sources/0404_assert_rel.c create mode 100644 tests/sources/0500_loop_count.c create mode 100644 tests/sources/0501_loop_infinite.c create mode 100644 tests/sources/0502_loop_infinite2.c create mode 100644 tests/sources/0503_loop_nondet.c create mode 100644 tests/sources/0504_loop_rel.c create mode 100644 tests/sources/0505_loop_rel2.c create mode 100644 tests/sources/0506_loop_limit.c create mode 100644 tests/sources/0507_loop_limit2.c create mode 100644 tests/sources/0508_loop_init.c create mode 100644 tests/sources/0509_loop_nested.c create mode 100644 tests/sources/0510_loop_nested2.c create mode 100644 tests/sources/0600_bubble_sort.c create mode 100644 tests/sources/0601_heap_sort.c create mode 100644 tests/sources/0602_rate_limiter.c create mode 100644 tests/sources/0603_rate_limiter2.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..17ef805 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.swp +_build +analyzer diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..640da3b --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +.PHONY: clean + +BIN=analyze +SRCDIRS=libs,frontend + +all: $(BIN) + +$(BIN): main.ml + ocamlbuild -Is $(SRCDIRS) main.native + mv main.native $(BIN) + +clean: + rm -rf _build diff --git a/Makefile.bad b/Makefile.bad new file mode 100644 index 0000000..691e0fa --- /dev/null +++ b/Makefile.bad @@ -0,0 +1,155 @@ +# Cours "Sémantique et Application à la Vérification de programmes" +# +# Antoine Miné 2014 +# Ecole normale supérieure, Paris, France / CNRS / INRIA + +# Makefile + + +# points to compilers +# +# (we rely heavily on ocamlfind) +# (no change needed, the default ones in /usr/bin should be good) +# +OCAMLFIND = ocamlfind +OCAMLLEX = ocamllex +MENHIR = menhir + + +# options for compilers +# +# (change this if you want to enable/disable debugging) +# +OCAMLCFLAGS = -g +OCAMLOPTFLAGS = -g +OCAMLLEXFLAGS = +MENHIRFLAGS = --explain + + +# library paths +# +# (change this if you add new subdirectories or libraries) +# +OCAMLINC = -I frontend -I libs -I corrections -I +zarith + +# libraries +# +# (change this to add new libraries) +# +LIBS = -package zarith +CMXA = +CMA = + +# name of the compiled executable +# +# (change to a better name matching your project) +# +TARGET = main + + +# compile either to byte code or native code +# +# uncomment only one of the two lines! +# +all: $(TARGET).byte +#all: $(TARGET).opt + + +# list of automatically generated files (by ocamllex and menhir) +# +# (this will probably not change during the project) +# +AUTOGEN = \ + frontend/lexer.ml \ + frontend/parser.ml \ + frontend/parser.mli + + +# list of ML source files to compile (including automatically generated) +# +# add your files here, in the right order! +# +MLFILES = \ + libs/mapext.ml \ + frontend/abstract_syntax_tree.ml \ + frontend/abstract_syntax_printer.ml \ + frontend/parser.ml \ + frontend/lexer.ml \ + frontend/file_parser.ml \ + main.ml + + +# list of MLI source files +# +# add your files here +# (this is only used for ocamldep) +# +MLIFILES = \ + libs/mapext.mli \ + frontend/parser.mli \ + frontend/abstract_syntax_printer.mli \ + frontend/file_parser.mli + + +# below are general compilation rules +# +# you probably don't need to change anything below this point + + +# list of object files, derived from ML sources +# +CMOFILES = $(MLFILES:%.ml=%.cmo) +CMXFILES = $(MLFILES:%.ml=%.cmx) + +$(TARGET).byte: $(CMOFILES) + $(OCAMLFIND) ocamlc -o $@ $(OCAMLCFLAGS) $(OCAMLINC) $(LIBS) $(CMA) -linkpkg $+ + +# native link +$(TARGET).opt: $(CMXFILES) + $(OCAMLFIND) ocamlopt -o $@ $(OCAMLOPTFLAGS) $(OCAMLINC) $(LIBS) $(CMXA) -linkpkg $+ + + +# compilation rules + +%.cmo: %.ml %.cmi + $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLINC) $(LIBS) -c $*.ml + +%.cmx: %.ml %.cmi + $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLINC) $(LIBS) -c $*.ml + +%.cmi: %.mli + $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLINC) $(LIBS) -c $*.mli + +%.cmo: %.ml + $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLINC) $(LIBS) -c $*.ml + +%.cmx: %.ml + $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLINC) $(LIBS) -c $*.ml + +%.ml: %.mll + $(OCAMLLEX) $(OCAMLLEXFLAGS) $*.mll + +%.ml %.mli: %.mly + $(MENHIR) $(MENHIRFLAGS) $*.mly + + +# remove temporaries and binaries +# +clean: + rm -f depend $(AUTOGEN) $(TARGET).byte $(TARGET).opt + rm -f `find . -name "*.o"` + rm -f `find . -name "*.a"` + rm -f `find . -name "*.cm*"` + rm -f `find . -name "*~"` + rm -f `find . -name "\#*"` + rm -f `find . -name "*.conflicts"` + +.phony: clean + + +# automatic dependencies +# +depend: $(MLFILES) $(MLIFILES) + -$(OCAMLFIND) ocamldep -native $(OCAMLINC) $+ > depend + +include depend diff --git a/TODO b/TODO new file mode 100644 index 0000000..7b30877 --- /dev/null +++ b/TODO @@ -0,0 +1,6 @@ +1. Définir un type pour décrire les valeurs abstraites + ie. définir le domaine abstrait + - Constantes + bot + top : bool et int + - Intervalles + bot + top : int + +2. Interprète abstrait diff --git a/_tags b/_tags new file mode 100644 index 0000000..25bfa60 --- /dev/null +++ b/_tags @@ -0,0 +1 @@ +true: use_menhir diff --git a/abstract/constant_domain.ml b/abstract/constant_domain.ml new file mode 100644 index 0000000..8444779 --- /dev/null +++ b/abstract/constant_domain.ml @@ -0,0 +1,18 @@ + + +module Make : Domain.s = + struct + + + type tv = + | Bot + | BTrue + | BFalse + | BTop + | I of Z.t + | ITop + | Top + + type ts = tv VarMap.t + + end diff --git a/abstract/domain.ml b/abstract/domain.ml new file mode 100644 index 0000000..d022e34 --- /dev/null +++ b/abstract/domain.ml @@ -0,0 +1,7 @@ + +module type S = + sig + type tv + type ts + + end diff --git a/analyze b/analyze new file mode 120000 index 0000000..660214f --- /dev/null +++ b/analyze @@ -0,0 +1 @@ +/home/katchup/Core/ENS/Info/psv-SemVerif-Projet/_build/main.native \ No newline at end of file diff --git a/examples/gcd.c b/examples/gcd.c new file mode 100644 index 0000000..1f66332 --- /dev/null +++ b/examples/gcd.c @@ -0,0 +1,12 @@ +a = -26134272; +b = 26396928; + +if (a < 0) a = -a; +if (b < 0) b = -b; +while (b > 0) { // try changing this to b >= 0 + tmp = b; + b = a % b; + a = tmp; + } +print (a); // this should print 131328 + diff --git a/examples/gcd_nd.c b/examples/gcd_nd.c new file mode 100644 index 0000000..260af41 --- /dev/null +++ b/examples/gcd_nd.c @@ -0,0 +1,15 @@ +a = rand(5,15); +b = rand(3,8); + +if (a < 0) a = -a; +if (b < 0) b = -b; +while (b > 0) { // try changing this to b >= 0 + tmp = b; + b = a % b; + a = tmp; + } +assert (b==0); // should be true +//assert (a>6); // try uncommenting this line +tmp = 0; +print (a); + diff --git a/examples/loop.c b/examples/loop.c new file mode 100644 index 0000000..7e22dfa --- /dev/null +++ b/examples/loop.c @@ -0,0 +1,3 @@ +x = 0; +while (x >= 0) { } + diff --git a/examples/loop2.c b/examples/loop2.c new file mode 100644 index 0000000..64f05c9 --- /dev/null +++ b/examples/loop2.c @@ -0,0 +1,2 @@ +x = 0; +while (x <= 0) x = x-1; diff --git a/examples/loop3.c b/examples/loop3.c new file mode 100644 index 0000000..f22958c --- /dev/null +++ b/examples/loop3.c @@ -0,0 +1,3 @@ +x = 5; +while (x < 10) { x=x-1; y=1/x; } + diff --git a/examples/loop4.c b/examples/loop4.c new file mode 100644 index 0000000..6cbe12c --- /dev/null +++ b/examples/loop4.c @@ -0,0 +1,2 @@ +x = rand(-10,10); +while (x <= 0) x = x-1; diff --git a/frontend/abstract_syntax_printer.ml b/frontend/abstract_syntax_printer.ml new file mode 100644 index 0000000..1ecdc00 --- /dev/null +++ b/frontend/abstract_syntax_printer.ml @@ -0,0 +1,242 @@ +(* + Cours "Sémantique et Application à la Vérification de programmes" + + Antoine Miné 2014 + Ecole normale supérieure, Paris, France / CNRS / INRIA +*) + +(* + Pretty-printer for abstract syntax trees. +*) + +open Abstract_syntax_tree +open Lexing + + +(* locations *) +(* ********* *) + +let string_of_position p = + Printf.sprintf "%s:%i:%i" p.pos_fname p.pos_lnum (p.pos_cnum - p.pos_bol) + +let string_of_extent (p,q) = + if p.pos_fname = q.pos_fname then + if p.pos_lnum = q.pos_lnum then + if p.pos_cnum = q.pos_cnum then + Printf.sprintf "%s:%i.%i" p.pos_fname p.pos_lnum (p.pos_cnum - p.pos_bol) + else + Printf.sprintf "%s:%i.%i-%i" p.pos_fname p.pos_lnum (p.pos_cnum - p.pos_bol) (q.pos_cnum - q.pos_bol) + else + Printf.sprintf "%s:%i.%i-%i.%i" p.pos_fname p.pos_lnum (p.pos_cnum - p.pos_bol) q.pos_lnum (q.pos_cnum - q.pos_bol) + else + Printf.sprintf "%s:%i.%i-%s:%i.%i" p.pos_fname p.pos_lnum (p.pos_cnum - p.pos_bol) q.pos_fname q.pos_lnum (q.pos_cnum - q.pos_bol) + + + +(* operators *) +(* ********* *) + +let string_of_unary_op = function + | AST_UNARY_PLUS -> "+" + | AST_UNARY_MINUS -> "-" + | AST_NOT -> "!" + +let string_of_binary_op = function + | AST_MULTIPLY -> "*" + | AST_DIVIDE -> "/" + | AST_MODULO -> "%" + | AST_PLUS -> "+" + | AST_MINUS -> "-" + | AST_EQUAL -> "==" + | AST_NOT_EQUAL -> "!=" + | AST_LESS -> "<" + | AST_LESS_EQUAL -> "<=" + | AST_GREATER -> ">" + | AST_GREATER_EQUAL -> ">=" + | AST_AND -> "&&" + | AST_OR -> "||" + + + +(* higher values mean higher precedence *) +let binary_precedence = function + | AST_MULTIPLY | AST_DIVIDE | AST_MODULO -> 6 + | AST_PLUS | AST_MINUS -> 5 + | AST_EQUAL | AST_NOT_EQUAL -> 4 + | AST_LESS | AST_LESS_EQUAL | AST_GREATER | AST_GREATER_EQUAL -> 3 + | AST_AND -> 2 + | AST_OR -> 1 + +(* precedence of the operator at the root of the expression; + this is used to avoid printing unnecessary parentheses + *) +let expr_precedence = function + | AST_unary (op, _) -> 99 + | AST_binary(op, _, _) -> binary_precedence op + | _ -> 100 + + +(* utility to print lists *) +let print_list f sep fmt l = + let rec aux = function + | [] -> () + | [a] -> f fmt a + | a::b -> f fmt a; Format.pp_print_string fmt sep; aux b + in + aux l + + +(* types *) +(* ***** *) + +let string_of_typ = function + | AST_TYP_INT -> "int" + | AST_TYP_BOOL -> "bool" + | AST_TYP_AUTO -> "auto" + + +(* expressions *) +(* *********** *) + +let print_id fmt v = + Format.pp_print_string fmt v + +let rec print_expr fmt e = + match e with + + | AST_unary (op,(e1,_)) -> + Format.pp_print_string fmt (string_of_unary_op op); + if expr_precedence e1 <= expr_precedence e + then Format.fprintf fmt " (%a)" print_expr e1 + else Format.fprintf fmt " %a" print_expr e1 + + | AST_binary (op,(e1,_),(e2,_)) -> + if expr_precedence e1 < expr_precedence e + then Format.fprintf fmt "(%a) " print_expr e1 + else Format.fprintf fmt "%a " print_expr e1; + Format.pp_print_string fmt (string_of_binary_op op); + if expr_precedence e2 <= expr_precedence e + then Format.fprintf fmt " (%a)" print_expr e2 + else Format.fprintf fmt " %a" print_expr e2 + + | AST_int_const (i,_) -> Format.pp_print_string fmt i + + | AST_int_rand ((i1,_),(i2,_)) -> Format.fprintf fmt "rand(%s, %s)" i1 i2 + + | AST_bool_const b -> Format.pp_print_bool fmt b + + | AST_identifier (v,_) -> print_id fmt v + + | AST_expr_call ((i,_),l) -> + Format.fprintf fmt "%a(%a)" + print_id i (print_list print_expr ",") (List.map fst l) + +let print_lvalue fmt v = + Format.pp_print_string fmt v + + + +(* statements *) +(* ********** *) + +let indent ind = ind^" " + +(* ind is a string of spaces (indentation) to put at the begining of each line + *) +let rec print_stat ind fmt = function + + | AST_block b -> + print_block ind fmt b + + | AST_assign ((v,_),(e,_)) -> + Format.fprintf fmt "%s%a = %a;@\n" + ind print_lvalue v print_expr e + + | AST_if ((e,_), (b1,_), None) -> + Format.fprintf fmt "%sif (%a)@\n%a" + ind print_expr e (print_stat (indent ind)) b1 + + | AST_if ((e,_), (b1,_), Some (b2,_)) -> + Format.fprintf fmt "%sif (%a)@\n%a%selse@\n%a" + ind print_expr e (print_stat (indent ind)) b1 + ind (print_stat (indent ind)) b2 + + | AST_while ((e,_),(b,_)) -> + Format.fprintf fmt "%swhile (%a)@\n%a" + ind print_expr e (print_stat (indent ind)) b + + | AST_assert ((e,_)) -> + Format.fprintf fmt "%sassert (%a);@\n" + ind print_expr e + + | AST_print l -> + Format.fprintf fmt "%sprint (%a);@\n" + ind (print_list print_id ",") (List.map fst l) + + | AST_local d -> + Format.fprintf fmt "%s%a" ind print_var_decl d + + | AST_stat_call ((i,_),l) -> + Format.fprintf fmt "%s%a(%a);@\n" + ind print_id i (print_list print_expr ",") (List.map fst l) + + | AST_return None -> + Format.fprintf fmt "%sreturn;@\n" ind + + | AST_return (Some (e,_)) -> + Format.fprintf fmt "%sreturn %a;@\n" + ind print_expr e + + | AST_BREAK -> + Format.fprintf fmt "%sbreak;@\n" ind + + | AST_HALT -> + Format.fprintf fmt "%shalt;@\n" ind + + | AST_label (l,_) -> + Format.fprintf fmt "%s%a:@\n" ind print_id l + + | AST_goto (l,_) -> + Format.fprintf fmt "%sgoto %a;@\n" ind print_id l + +and print_block ind fmt b = + Format.fprintf fmt "%s{@\n" ind; + List.iter (fun (bb,_) -> print_stat (indent ind) fmt bb) b; + Format.fprintf fmt "%s}@\n" ind + + + +(* declarations *) +(* ************ *) + +and print_var_decl fmt ((t,_),l) = + Format.fprintf fmt "%s %a;@\n" + (string_of_typ t) (print_list print_var_init ", ") l + +and print_var_init fmt ((i,_),eo) = + print_id fmt i; + match eo with + | None -> () + | Some (e,_) -> Format.fprintf fmt " = %a" print_expr e + +let print_arg_decl fmt ((t,_),(i,_)) = + Format.fprintf fmt "%s %a" + (string_of_typ t) print_id i + +let print_fun_decl fmt f = + Format.fprintf fmt "%s %a(%a)@\n%a" + (match fst (f.fun_typ) with None -> "void" | Some t -> string_of_typ t) + print_id (fst f.fun_name) + (print_list print_arg_decl ", ") f.fun_args + (print_block "") f.fun_body + +let print_toplevel fmt = function + | AST_stat (s,_) -> print_stat "" fmt s + | AST_fun_decl (f,_) -> print_fun_decl fmt f + + +(* programs *) +(* ******** *) + +let print_prog fmt (p,_) = + List.iter (print_toplevel fmt) p diff --git a/frontend/abstract_syntax_printer.mli b/frontend/abstract_syntax_printer.mli new file mode 100644 index 0000000..cbdc872 --- /dev/null +++ b/frontend/abstract_syntax_printer.mli @@ -0,0 +1,31 @@ +(* + Cours "Sémantique et Application à la Vérification de programmes" + + Antoine Miné 2014 + Ecole normale supérieure, Paris, France / CNRS / INRIA +*) + +(* + Pretty-printer for abstract syntax trees. +*) + +open Format +open Abstract_syntax_tree + +(* locations *) +val string_of_position: position -> string +val string_of_extent: extent -> string + + +(* printers *) + +val string_of_typ: typ -> string + +val print_id: formatter -> id -> unit +val print_lvalue: formatter -> lvalue -> unit +val print_expr: formatter -> expr -> unit +val print_stat: string -> formatter -> stat -> unit +val print_block: string -> formatter -> stat ext list -> unit +val print_var_decl: formatter -> var_decl -> unit +val print_fun_decl: formatter -> fun_decl -> unit +val print_prog: formatter -> prog -> unit diff --git a/frontend/abstract_syntax_tree.ml b/frontend/abstract_syntax_tree.ml new file mode 100644 index 0000000..d3022bb --- /dev/null +++ b/frontend/abstract_syntax_tree.ml @@ -0,0 +1,212 @@ +(* + Cours "Sémantique et Application à la Vérification de programmes" + + Antoine Miné 2014 + Ecole normale supérieure, Paris, France / CNRS / INRIA +*) + +(* + Definition of the abstract syntax trees output by the parser. +*) + + +open Lexing + + +(* position in the source file, we use ocamllex's default type *) + +type position = Lexing.position +let position_unknown = Lexing.dummy_pos + + +(* extents are pairs of positions *) + +type extent = position * position (* start/end *) +let extent_unknown = (position_unknown, position_unknown) + + +(* Many parts of the syntax are tagged with an extent indicating which + part of the parser-file corresponds to the sub-tree. + This is very useful for interesting error reporting! + *) +type 'a ext = 'a * extent + +(* variable identifiers, just strings for now *) +(* local variables and scoping would require using UNIQUE IDENTIFIERS + to handle the case where several variables have the same name + *) +type id = string + +(* types in our language *) +type typ = + (* mathematical integers, in Z *) + | AST_TYP_INT + + (* booleans: true or false *) + | AST_TYP_BOOL + + (* variables declared with the auto type should have their type + inferred automatically + *) + | AST_TYP_AUTO + + +(* unary expression operators *) +type unary_op = + + (* arithmetic operators *) + | AST_UNARY_PLUS (* +e *) + | AST_UNARY_MINUS (* -e *) + + (* logical operators *) + | AST_NOT (* !e logical negation *) + + +(* binary expression operators *) +type binary_op = + + (* arithmetic operators, work only for int *) + | AST_PLUS (* e + e *) + | AST_MINUS (* e - e *) + | AST_MULTIPLY (* e * e *) + | AST_DIVIDE (* e / e *) + | AST_MODULO (* e % e *) + + (* polymorphic comparison, should work for int and bool *) + | AST_EQUAL (* e == e *) + | AST_NOT_EQUAL (* e != e *) + + (* arithmetic comparisons, work only for int *) + | AST_LESS (* e < e *) + | AST_LESS_EQUAL (* e <= e *) + | AST_GREATER (* e > e *) + | AST_GREATER_EQUAL (* e >= e *) + + (* boolean operators, work only for bool *) + | AST_AND (* e && e *) + | AST_OR (* e || e *) + + +(* expressions *) +type expr = + (* unary operation *) + | AST_unary of unary_op * (expr ext) + + (* binary operation *) + | AST_binary of binary_op * (expr ext) * (expr ext) + + (* variable use *) + | AST_identifier of id ext + + (* constants (integers are still in their string representation) *) + | AST_int_const of string ext + | AST_bool_const of bool + + (* non-deterministic choice between two integeres *) + | AST_int_rand of (string ext) (* lower bound *) * + (string ext) (* upper bound *) + + (* EXTENSIONS *) + (* support for them is OPTIONAL *) + + (* calls a function with arguments and return value *) + | AST_expr_call of (id ext) (* function name *) * + (expr ext list) (* arguments *) + + +(* left part of assignments *) +type lvalue = id + +(* statements *) +type stat = + + (* block of statements { ... } *) + | AST_block of stat ext list + + (* assignment lvalue = expr *) + | AST_assign of (lvalue ext) * (expr ext) + + (* if-then-else; the else branch is optional *) + | AST_if of (expr ext) (* condition *) * + (stat ext) (* then branch *) * + (stat ext option) (* optional else *) + + (* while loop *) + | AST_while of (expr ext) (* condition *) * + (stat ext) (* body *) + + (* exits the program *) + | AST_HALT + + (* assertion: fail if the boolean expression does not hold *) + | AST_assert of expr ext + + (* prints the value of some variables *) + | AST_print of (lvalue ext) list + + + (* EXTENSIONS *) + (* support for them is OPTIONAL *) + + (* declaration of a local variable, live until the end of the current block *) + | AST_local of var_decl + + (* calls a function with arguments (no return value) *) + | AST_stat_call of (id ext) (* function name *) * + (expr ext list) (* arguments *) + + (* exits form the function, with optional return value *) + | AST_return of expr ext option + + (* exits from the innermost while loop *) + | AST_BREAK + + (* defines the position of goto target *) + | AST_label of id ext + + (* jump to a goto label *) + | AST_goto of id ext + + +(* supporting local declarations is OPTIONAL *) + +(* declare some variables with a common type *) +and var_decl = (typ ext) (* type *) * (var_init list) (* variable list *) + +(* each declared variable has an optional initializer *) +and var_init = (id ext) (* declared variable *) * + (expr ext option) (* initializer *) + + +(* supporting functions is OPTIONAL *) + +(* function declaration + (no return type, all functions return void) + *) +type fun_decl = + { (* function name *) + fun_name: id ext; + + (* formal arguments, with type *) + fun_args: ((typ ext) * (id ext)) list; + + (* type of the returned value, if any *) + fun_typ: typ option ext; + + (* function body *) + fun_body: stat ext list; + } + + +(* top-level statements *) +type toplevel = + + (* statement to execute & variable declarations *) + | AST_stat of stat ext + + (* function declaration *) + | AST_fun_decl of fun_decl ext + + +(* a program is a list of top-level statements *) +type prog = toplevel list ext diff --git a/frontend/file_parser.ml b/frontend/file_parser.ml new file mode 100644 index 0000000..fa7ff7d --- /dev/null +++ b/frontend/file_parser.ml @@ -0,0 +1,32 @@ +(* + Cours "Sémantique et Application à la Vérification de programmes" + + Antoine Miné 2014 + Ecole normale supérieure, Paris, France / CNRS / INRIA +*) + +(* + Opens and parses a file given as argument. +*) + +open Abstract_syntax_tree +open Abstract_syntax_printer +open Lexing + +(* parsing, with nice error messages *) + +let parse_file (filename:string) : prog = + let f = open_in filename in + let lex = from_channel f in + try + lex.lex_curr_p <- { lex.lex_curr_p with pos_fname = filename; }; + Parser.file Lexer.token lex + with + | Parser.Error -> + Printf.eprintf "Parse error (invalid syntax) near %s\n" + (string_of_position lex.lex_start_p); + failwith "Parse error" + | Failure "lexing: empty token" -> + Printf.eprintf "Parse error (invalid token) near %s\n" + (string_of_position lex.lex_start_p); + failwith "Parse error" diff --git a/frontend/file_parser.mli b/frontend/file_parser.mli new file mode 100644 index 0000000..7ce47f0 --- /dev/null +++ b/frontend/file_parser.mli @@ -0,0 +1,10 @@ +(* + Cours "Sémantique et Application à la Vérification de programmes" + + Antoine Miné 2014 + Ecole normale supérieure, Paris, France / CNRS / INRIA +*) + +val parse_file: string -> Abstract_syntax_tree.prog +(* Opens and parses a file given as argument. *) + diff --git a/frontend/lexer.mll b/frontend/lexer.mll new file mode 100644 index 0000000..bc9267f --- /dev/null +++ b/frontend/lexer.mll @@ -0,0 +1,114 @@ +(* + Cours "Sémantique et Application à la Vérification de programmes" + + Antoine Miné 2014 + Ecole normale supérieure, Paris, France / CNRS / INRIA +*) + +(* + Lexer for a very simple C-like "curly bracket" language. +*) + +{ +open Lexing +open Abstract_syntax_tree +open Parser + +(* keyword table *) +let kwd_table = Hashtbl.create 10 +let _ = + List.iter (fun (a,b) -> Hashtbl.add kwd_table a b) + [ + (* types *) + "bool", TOK_BOOL; + "int", TOK_INT; + "void", TOK_VOID; + "auto", TOK_AUTO; + + (* constants *) + "true", TOK_TRUE; + "false", TOK_FALSE; + + (* expression operators *) + "rand", TOK_RAND; + + (* control flow *) + "while", TOK_WHILE; + "if", TOK_IF; + "else", TOK_ELSE; + "halt", TOK_HALT; + "return", TOK_RETURN; + "break", TOK_BREAK; + "goto", TOK_GOTO; + + (* special statements *) + "assert", TOK_ASSERT; + "print", TOK_PRINT; + ] +} + +(* special character classes *) +let space = [' ' '\t' '\r']+ +let newline = "\n" | "\r" | "\r\n" + +(* utilities *) +let digit = ['0'-'9'] +let digit_ = ['0'-'9' '_'] + +(* integers *) +let int_dec = digit digit_* +let int_bin = ("0b" | "0B") ['0'-'1'] ['0'-'1' '_']* +let int_oct = ("0o" | "0O") ['0'-'7'] ['0'-'7' '_']* +let int_hex = ("0x" | "0X") ['0'-'9' 'a'-'f' 'A'-'F'] ['0'-'9' 'a'-'f' 'A'-'F' '_']* +let const_int = int_bin | int_oct | int_dec | int_hex + + +(* tokens *) +rule token = parse + +(* identifier (TOK_id) or reserved keyword *) +| ['a'-'z' 'A'-'Z' '_'] ['a'-'z' 'A'-'Z' '0'-'9' '_']* as id +{ try Hashtbl.find kwd_table id with Not_found -> TOK_id id } + +(* symbols *) +| "(" { TOK_LPAREN } +| ")" { TOK_RPAREN } +| "{" { TOK_LCURLY } +| "}" { TOK_RCURLY } +| "*" { TOK_STAR } +| "+" { TOK_PLUS } +| "-" { TOK_MINUS } +| "!" { TOK_EXCLAIM } +| "/" { TOK_DIVIDE } +| "%" { TOK_PERCENT } +| "<" { TOK_LESS } +| ">" { TOK_GREATER } +| "<=" { TOK_LESS_EQUAL } +| ">=" { TOK_GREATER_EQUAL } +| "==" { TOK_EQUAL_EQUAL } +| "!=" { TOK_NOT_EQUAL } +| "&&" { TOK_AND_AND } +| "||" { TOK_BAR_BAR } +| ";" { TOK_SEMICOLON } +| ":" { TOK_COLON } +| "," { TOK_COMMA } +| "=" { TOK_EQUAL } + +(* literals *) +| const_int as c { TOK_int c } + +(* spaces, comments *) +| "/*" { comment lexbuf; token lexbuf } +| "//" [^ '\n' '\r']* { token lexbuf } +| newline { new_line lexbuf; token lexbuf } +| space { token lexbuf } + +(* end of files *) +| eof { TOK_EOF } + + +(* nested comments (handled recursively) *) +and comment = parse +| "*/" { () } +| [^ '\n' '\r'] { comment lexbuf } +| newline { new_line lexbuf; comment lexbuf } diff --git a/frontend/parser.mly b/frontend/parser.mly new file mode 100644 index 0000000..f65e6c7 --- /dev/null +++ b/frontend/parser.mly @@ -0,0 +1,247 @@ +(* + Cours "Sémantique et Application à la Vérification de programmes" + + Antoine Miné 2014 + Ecole normale supérieure, Paris, France / CNRS / INRIA +*) + + +(* + Parser for a very simple C-like "curly bracket" language. + + There should be exactly one shift/reduce conflict, due to nested + if-then-else constructs. The resolution picked by menhir should be correct. + *) + +%{ +open Abstract_syntax_tree +%} + +/* tokens */ +/**********/ + +%token TOK_BOOL +%token TOK_INT +%token TOK_VOID +%token TOK_AUTO +%token TOK_TRUE +%token TOK_FALSE +%token TOK_WHILE +%token TOK_IF +%token TOK_ELSE +%token TOK_HALT +%token TOK_RETURN +%token TOK_BREAK +%token TOK_RAND +%token TOK_GOTO +%token TOK_ASSERT +%token TOK_PRINT + +%token TOK_LPAREN +%token TOK_RPAREN +%token TOK_LCURLY +%token TOK_RCURLY +%token TOK_STAR +%token TOK_PLUS +%token TOK_MINUS +%token TOK_EXCLAIM +%token TOK_DIVIDE +%token TOK_PERCENT +%token TOK_LESS +%token TOK_GREATER +%token TOK_LESS_EQUAL +%token TOK_GREATER_EQUAL +%token TOK_EQUAL_EQUAL +%token TOK_NOT_EQUAL +%token TOK_AND_AND +%token TOK_BAR_BAR +%token TOK_SEMICOLON +%token TOK_COLON +%token TOK_COMMA +%token TOK_EQUAL + +%token TOK_id +%token TOK_int + +%token TOK_EOF + +/* priorities of binary operators (lowest to highest) */ +%left TOK_BAR_BAR +%left TOK_AND_AND +%left TOK_EQUAL_EQUAL TOK_NOT_EQUAL +%left TOK_LESS TOK_GREATER TOK_LESS_EQUAL TOK_GREATER_EQUAL +%left TOK_PLUS TOK_MINUS +%left TOK_STAR TOK_DIVIDE TOK_PERCENT + + +/* entry-points */ +/****************/ + +%start file + + +%% + + +/* toplevel */ +/************/ + +file: t=ext(list(toplevel)) TOK_EOF { t } + +toplevel: +| d=ext(stat) { AST_stat d } +| d=ext(fun_decl) { AST_fun_decl d } + + +/* expressions */ +/***************/ + +primary_expr: +| TOK_LPAREN e=expr TOK_RPAREN { e } +| e=ext(TOK_id) { AST_identifier e } +| e=ext(TOK_int) { AST_int_const e } +| TOK_TRUE { AST_bool_const true } +| TOK_FALSE { AST_bool_const false } +| TOK_RAND TOK_LPAREN e1=ext(sign_int_literal) + TOK_COMMA e2=ext(sign_int_literal) TOK_RPAREN + { AST_int_rand (e1, e2) } +| e=ext(TOK_id) TOK_LPAREN l=separated_list(TOK_COMMA,ext(expr)) TOK_RPAREN TOK_SEMICOLON + { AST_expr_call (e, l) } + +/* integer with optional sign */ +sign_int_literal: +| i=TOK_int { i } +| TOK_PLUS i=TOK_int { i } +| TOK_MINUS i=TOK_int { "-"^i } + + +unary_expr: +| e=primary_expr { e } +| o=unary_op e=ext(unary_expr) { AST_unary (o, e) } + +%inline unary_op: +| TOK_PLUS { AST_UNARY_PLUS } +| TOK_MINUS { AST_UNARY_MINUS } +| TOK_EXCLAIM { AST_NOT } + + +binary_expr: +| e=unary_expr { e } +| e=ext(binary_expr) o=binary_op f=ext(binary_expr) { AST_binary (o, e, f) } + +%inline binary_op: +| TOK_STAR { AST_MULTIPLY } +| TOK_DIVIDE { AST_DIVIDE } +| TOK_PERCENT { AST_MODULO } +| TOK_PLUS { AST_PLUS } +| TOK_MINUS { AST_MINUS } +| TOK_LESS { AST_LESS } +| TOK_GREATER { AST_GREATER } +| TOK_LESS_EQUAL { AST_LESS_EQUAL } +| TOK_GREATER_EQUAL { AST_GREATER_EQUAL } +| TOK_EQUAL_EQUAL { AST_EQUAL } +| TOK_NOT_EQUAL { AST_NOT_EQUAL } +| TOK_AND_AND { AST_AND } +| TOK_BAR_BAR { AST_OR } + +expr: +| e=binary_expr { e } + +lvalue: +| i=TOK_id { i } + + +/* declarations */ +/****************/ + +var_decl: +| s=ext(typ) i=separated_list(TOK_COMMA,init_declarator) TOK_SEMICOLON + { s, i } + +init_declarator: +| v=ext(TOK_id) { v, None } +| v=ext(TOK_id) TOK_EQUAL i=ext(expr) { v, Some i } + +fun_decl: +| t=ext(typ_or_void) i=ext(TOK_id) + TOK_LPAREN p=separated_list(TOK_COMMA,param_decl) TOK_RPAREN + b=block + { { Abstract_syntax_tree.fun_name = i; + Abstract_syntax_tree.fun_typ = t; + Abstract_syntax_tree.fun_args = p; + Abstract_syntax_tree.fun_body = b; } + } + +param_decl: +| s=ext(typ) v=ext(TOK_id) { s, v } + +typ: +| TOK_INT { AST_TYP_INT } +| TOK_BOOL { AST_TYP_BOOL } +| TOK_AUTO { AST_TYP_AUTO } + +%inline typ_or_void: +| t=typ { Some t } +| TOK_VOID { None } + + +/* statements */ +/**************/ + +block: +| TOK_LCURLY l=list(ext(stat)) TOK_RCURLY { l } + +stat: +| l=block + { AST_block l } + +| e=ext(lvalue) TOK_EQUAL f=ext(expr) TOK_SEMICOLON + { AST_assign (e, f) } + +| TOK_IF TOK_LPAREN e=ext(expr) TOK_RPAREN s=ext(stat) + { AST_if (e, s, None) } + +| TOK_IF TOK_LPAREN e=ext(expr) TOK_RPAREN s=ext(stat) TOK_ELSE t=ext(stat) + { AST_if (e, s, Some t) } + +| TOK_WHILE TOK_LPAREN e=ext(expr) TOK_RPAREN s=ext(stat) + { AST_while (e, s) } + +| TOK_ASSERT TOK_LPAREN e=ext(expr) TOK_RPAREN TOK_SEMICOLON + { AST_assert e } + +| TOK_PRINT TOK_LPAREN l=separated_list(TOK_COMMA,ext(lvalue)) TOK_RPAREN TOK_SEMICOLON + { AST_print l } + +| v=var_decl + { AST_local v } + +| e=ext(TOK_id) TOK_LPAREN l=separated_list(TOK_COMMA,ext(expr)) TOK_RPAREN TOK_SEMICOLON + { AST_stat_call (e, l) } + +| TOK_RETURN e=option(ext(expr)) TOK_SEMICOLON + { AST_return e } + +| TOK_BREAK TOK_SEMICOLON + { AST_BREAK } + +| TOK_HALT TOK_SEMICOLON + { AST_HALT } + +| TOK_GOTO l=ext(TOK_id) TOK_SEMICOLON + { AST_goto l } + +| l=ext(TOK_id) TOK_COLON + { AST_label l } + + + +/* utilities */ +/*************/ + +/* adds extent information to rule */ +%inline ext(X): +| x=X { x, ($startpos, $endpos) } + + +%% diff --git a/libs/mapext.ml b/libs/mapext.ml new file mode 100644 index 0000000..51f41ee --- /dev/null +++ b/libs/mapext.ml @@ -0,0 +1,741 @@ +(* + Cours "Sémantique et Application à la Vérification de programmes" + + Antoine Miné 2014 + Ecole normale supérieure, Paris, France / CNRS / INRIA +*) + +(* + This file is derived from the map.ml file from the OCaml distribution. + Changes are marked with the [AM] symbol. + Based on rev. 10468 2010-05-25 13:29:43Z + + Original copyright follows. +*) + +(***********************************************************************) +(* *) +(* Objective Caml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. All rights reserved. This file is distributed *) +(* under the terms of the GNU Library General Public License, with *) +(* the special exception on linking described in file ../LICENSE. *) +(* *) +(***********************************************************************) + +module type OrderedType = + sig + type t + val compare: t -> t -> int + end + +module type S = + sig + type key + type +'a t + val empty: 'a t + val is_empty: 'a t -> bool + val mem: key -> 'a t -> bool + val add: key -> 'a -> 'a t -> 'a t + val singleton: key -> 'a -> 'a t + val remove: key -> 'a t -> 'a t + val merge: (key -> 'a option -> 'b option -> 'c option) -> 'a t -> 'b t -> 'c t + val compare: ('a -> 'a -> int) -> 'a t -> 'a t -> int + val equal: ('a -> 'a -> bool) -> 'a t -> 'a t -> bool + val iter: (key -> 'a -> unit) -> 'a t -> unit + val fold: (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b + val for_all: (key -> 'a -> bool) -> 'a t -> bool + val exists: (key -> 'a -> bool) -> 'a t -> bool + val filter: (key -> 'a -> bool) -> 'a t -> 'a t + val partition: (key -> 'a -> bool) -> 'a t -> 'a t * 'a t + val cardinal: 'a t -> int + val bindings: 'a t -> (key * 'a) list + val min_binding: 'a t -> (key * 'a) + val max_binding: 'a t -> (key * 'a) + val choose: 'a t -> (key * 'a) + val split: key -> 'a t -> 'a t * 'a option * 'a t + val find: key -> 'a t -> 'a + val map: ('a -> 'b) -> 'a t -> 'b t + val mapi: (key -> 'a -> 'b) -> 'a t -> 'b t + + + (* [AM] additions by Antoine Mine' *) + + val of_list: (key * 'a) list -> 'a t + + val map2: (key -> 'a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t + val iter2: (key -> 'a -> 'b -> unit) -> 'a t -> 'b t -> unit + val fold2: (key -> 'a -> 'b -> 'c -> 'c) -> 'a t -> 'b t -> 'c -> 'c + val for_all2: (key -> 'a -> 'b -> bool) -> 'a t -> 'b t -> bool + val exists2: (key -> 'a -> 'b -> bool) -> 'a t -> 'b t -> bool + + val map2z: (key -> 'a -> 'a -> 'a) -> 'a t -> 'a t -> 'a t + val iter2z: (key -> 'a -> 'a -> unit) -> 'a t -> 'a t -> unit + val fold2z: (key -> 'a -> 'a -> 'b -> 'b) -> 'a t -> 'a t -> 'b -> 'b + val for_all2z: (key -> 'a -> 'a -> bool) -> 'a t -> 'a t -> bool + val exists2z: (key -> 'a -> 'a -> bool) -> 'a t -> 'a t -> bool + + val map2o: (key -> 'a -> 'c) -> (key -> 'b -> 'c) -> (key -> 'a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t + val iter2o: (key -> 'a -> unit) -> (key -> 'b -> unit) -> (key -> 'a -> 'b -> unit) -> 'a t -> 'b t -> unit + val fold2o: (key -> 'a -> 'c -> 'c) -> (key -> 'b -> 'c -> 'c) -> (key -> 'a -> 'b -> 'c -> 'c) -> 'a t -> 'b t -> 'c -> 'c + val for_all2o: (key -> 'a -> bool) -> (key -> 'b -> bool) -> (key -> 'a -> 'b -> bool) -> 'a t -> 'b t -> bool + val exists2o: (key -> 'a -> bool) -> (key -> 'b -> bool) -> (key -> 'a -> 'b -> bool) -> 'a t -> 'b t -> bool + + val map2zo: (key -> 'a -> 'a) -> (key -> 'a -> 'a) -> (key -> 'a -> 'a -> 'a) -> 'a t -> 'a t -> 'a t + val iter2zo: (key -> 'a -> unit) -> (key -> 'a -> unit) -> (key -> 'a -> 'a -> unit) -> 'a t -> 'a t -> unit + val fold2zo: (key -> 'a -> 'b -> 'b) -> (key -> 'a -> 'b -> 'b) -> (key -> 'a -> 'a -> 'b -> 'b) -> 'a t -> 'a t -> 'b -> 'b + val for_all2zo: (key -> 'a -> bool) -> (key -> 'a -> bool) -> (key -> 'a -> 'a -> bool) -> 'a t -> 'a t -> bool + val exists2zo: (key -> 'a -> bool) -> (key -> 'a -> bool) -> (key -> 'a -> 'a -> bool) -> 'a t -> 'a t -> bool + + val map_slice: (key -> 'a -> 'a) -> 'a t -> key -> key -> 'a t + val iter_slice: (key -> 'a -> unit) -> 'a t -> key -> key -> unit + val fold_slice: (key -> 'a -> 'b -> 'b) -> 'a t -> key -> key -> 'b -> 'b + val for_all_slice: (key -> 'a -> bool) -> 'a t -> key -> key -> bool + val exists_slice: (key -> 'a -> bool) -> 'a t -> key -> key -> bool + + val key_equal: 'a t -> 'a t -> bool + val key_subset: 'a t -> 'a t -> bool + + val find_greater: key -> 'a t -> key * 'a + val find_less: key -> 'a t -> key * 'a + val find_greater_equal: key -> 'a t -> key * 'a + val find_less_equal: key -> 'a t -> key * 'a + + end + +module Make(Ord: OrderedType) = (struct + + type key = Ord.t + + type 'a t = + Empty + | Node of 'a t * key * 'a * 'a t * int + + let height = function + Empty -> 0 + | Node(_,_,_,_,h) -> h + + let create l x d r = + let hl = height l and hr = height r in + Node(l, x, d, r, (if hl >= hr then hl + 1 else hr + 1)) + + let singleton x d = Node(Empty, x, d, Empty, 1) + + let bal l x d r = + let hl = match l with Empty -> 0 | Node(_,_,_,_,h) -> h in + let hr = match r with Empty -> 0 | Node(_,_,_,_,h) -> h in + if hl > hr + 2 then begin + match l with + Empty -> invalid_arg "Mapext.bal" + | Node(ll, lv, ld, lr, _) -> + if height ll >= height lr then + create ll lv ld (create lr x d r) + else begin + match lr with + Empty -> invalid_arg "Mapext.bal" + | Node(lrl, lrv, lrd, lrr, _)-> + create (create ll lv ld lrl) lrv lrd (create lrr x d r) + end + end else if hr > hl + 2 then begin + match r with + Empty -> invalid_arg "Mapext.bal" + | Node(rl, rv, rd, rr, _) -> + if height rr >= height rl then + create (create l x d rl) rv rd rr + else begin + match rl with + Empty -> invalid_arg "Mapext.bal" + | Node(rll, rlv, rld, rlr, _) -> + create (create l x d rll) rlv rld (create rlr rv rd rr) + end + end else + Node(l, x, d, r, (if hl >= hr then hl + 1 else hr + 1)) + + let empty = Empty + + let is_empty = function Empty -> true | _ -> false + + let rec add x data = function + Empty -> + Node(Empty, x, data, Empty, 1) + | Node(l, v, d, r, h) -> + let c = Ord.compare x v in + if c = 0 then + Node(l, x, data, r, h) + else if c < 0 then + bal (add x data l) v d r + else + bal l v d (add x data r) + + let rec find x = function + Empty -> + raise Not_found + | Node(l, v, d, r, _) -> + let c = Ord.compare x v in + if c = 0 then d + else find x (if c < 0 then l else r) + + let rec mem x = function + Empty -> + false + | Node(l, v, d, r, _) -> + let c = Ord.compare x v in + c = 0 || mem x (if c < 0 then l else r) + + let rec min_binding = function + Empty -> raise Not_found + | Node(Empty, x, d, r, _) -> (x, d) + | Node(l, x, d, r, _) -> min_binding l + + let rec max_binding = function + Empty -> raise Not_found + | Node(l, x, d, Empty, _) -> (x, d) + | Node(l, x, d, r, _) -> max_binding r + + let rec remove_min_binding = function + Empty -> invalid_arg "Mapext.remove_min_elt" + | Node(Empty, x, d, r, _) -> r + | Node(l, x, d, r, _) -> bal (remove_min_binding l) x d r + + let merge t1 t2 = + match (t1, t2) with + (Empty, t) -> t + | (t, Empty) -> t + | (_, _) -> + let (x, d) = min_binding t2 in + bal t1 x d (remove_min_binding t2) + + let rec remove x = function + Empty -> + Empty + | Node(l, v, d, r, h) -> + let c = Ord.compare x v in + if c = 0 then + merge l r + else if c < 0 then + bal (remove x l) v d r + else + bal l v d (remove x r) + + let rec iter f = function + Empty -> () + | Node(l, v, d, r, _) -> + iter f l; f v d; iter f r + + let rec map f = function + Empty -> + Empty + | Node(l, v, d, r, h) -> + let l' = map f l in + let d' = f d in + let r' = map f r in + Node(l', v, d', r', h) + + let rec mapi f = function + Empty -> + Empty + | Node(l, v, d, r, h) -> + let l' = mapi f l in + let d' = f v d in + let r' = mapi f r in + Node(l', v, d', r', h) + + let rec fold f m accu = + match m with + Empty -> accu + | Node(l, v, d, r, _) -> + fold f r (f v d (fold f l accu)) + + (* [AM] changed to call p in the key order *) + let rec for_all p = function + Empty -> true + | Node(l, v, d, r, _) -> for_all p l && p v d && for_all p r + + (* [AM] changed to call p in the key order *) + let rec exists p = function + Empty -> false + | Node(l, v, d, r, _) -> exists p l || p v d || exists p r + + (* [AM] changed to call p in the key order *) + let filter p s = + fold (fun k d a -> if p k d then add k d a else a) s Empty + + let partition p s = + let rec part (t, f as accu) = function + | Empty -> accu + | Node(l, v, d, r, _) -> + part (part (if p v d then (add v d t, f) else (t, add v d f)) l) r in + part (Empty, Empty) s + + (* Same as create and bal, but no assumptions are made on the + relative heights of l and r. *) + + let rec join l v d r = + match (l, r) with + (Empty, _) -> add v d r + | (_, Empty) -> add v d l + | (Node(ll, lv, ld, lr, lh), Node(rl, rv, rd, rr, rh)) -> + if lh > rh + 2 then bal ll lv ld (join lr v d r) else + if rh > lh + 2 then bal (join l v d rl) rv rd rr else + create l v d r + + (* Merge two trees l and r into one. + All elements of l must precede the elements of r. + No assumption on the heights of l and r. *) + + let concat t1 t2 = + match (t1, t2) with + (Empty, t) -> t + | (t, Empty) -> t + | (_, _) -> + let (x, d) = min_binding t2 in + join t1 x d (remove_min_binding t2) + + let concat_or_join t1 v d t2 = + match d with + | Some d -> join t1 v d t2 + | None -> concat t1 t2 + + let rec split x = function + Empty -> + (Empty, None, Empty) + | Node(l, v, d, r, _) -> + let c = Ord.compare x v in + if c = 0 then (l, Some d, r) + else if c < 0 then + let (ll, pres, rl) = split x l in (ll, pres, join rl v d r) + else + let (lr, pres, rr) = split x r in (join l v d lr, pres, rr) + + let rec merge f s1 s2 = + match (s1, s2) with + (Empty, Empty) -> Empty + | (Node (l1, v1, d1, r1, h1), _) when h1 >= height s2 -> + let (l2, d2, r2) = split v1 s2 in + concat_or_join (merge f l1 l2) v1 (f v1 (Some d1) d2) (merge f r1 r2) + | (_, Node (l2, v2, d2, r2, h2)) -> + let (l1, d1, r1) = split v2 s1 in + concat_or_join (merge f l1 l2) v2 (f v2 d1 (Some d2)) (merge f r1 r2) + | _ -> + assert false + + type 'a enumeration = End | More of key * 'a * 'a t * 'a enumeration + + let rec cons_enum m e = + match m with + Empty -> e + | Node(l, v, d, r, _) -> cons_enum l (More(v, d, r, e)) + + let compare cmp m1 m2 = + let rec compare_aux e1 e2 = + match (e1, e2) with + (End, End) -> 0 + | (End, _) -> -1 + | (_, End) -> 1 + | (More(v1, d1, r1, e1), More(v2, d2, r2, e2)) -> + let c = Ord.compare v1 v2 in + if c <> 0 then c else + let c = cmp d1 d2 in + if c <> 0 then c else + compare_aux (cons_enum r1 e1) (cons_enum r2 e2) + in compare_aux (cons_enum m1 End) (cons_enum m2 End) + + let equal cmp m1 m2 = + let rec equal_aux e1 e2 = + match (e1, e2) with + (End, End) -> true + | (End, _) -> false + | (_, End) -> false + | (More(v1, d1, r1, e1), More(v2, d2, r2, e2)) -> + Ord.compare v1 v2 = 0 && cmp d1 d2 && + equal_aux (cons_enum r1 e1) (cons_enum r2 e2) + in equal_aux (cons_enum m1 End) (cons_enum m2 End) + + let rec cardinal = function + Empty -> 0 + | Node(l, _, _, r, _) -> cardinal l + 1 + cardinal r + + let rec bindings_aux accu = function + Empty -> accu + | Node(l, v, d, r, _) -> bindings_aux ((v, d) :: bindings_aux accu r) l + + let bindings s = + bindings_aux [] s + + let choose = min_binding + + + + (* [AM] additions by Antoine Mine' *) + (* ******************************* *) + + + let of_list l = + List.fold_left (fun acc (k,x) -> add k x acc) empty l + + + (* similar to split, but returns unbalanced trees *) + let rec cut k = function + Empty -> Empty,None,Empty + | Node (l1,k1,d1,r1,h1) -> + let c = Ord.compare k k1 in + if c < 0 then + let l2,d2,r2 = cut k l1 in (l2,d2,Node (r2,k1,d1,r1,h1)) + else if c > 0 then + let l2,d2,r2 = cut k r1 in (Node (l1,k1,d1,l2,h1),d2,r2) + else (l1,Some d1,r1) + + + (* binary operations that fail on maps with different keys *) + + (* functions are called in increasing key order *) + + let rec map2 f m1 m2 = + match m1 with + | Empty -> if m2 = Empty then Empty else invalid_arg "Mapext.map2" + | Node (l1,k,d1,r1,h1) -> + match cut k m2 with + | l2, Some d2, r2 -> + Node (map2 f l1 l2, k, f k d1 d2, map2 f r1 r2, h1) + | _, None, _ -> invalid_arg "Mapext.map2" + + let rec iter2 f m1 m2 = + match m1 with + | Empty -> if m2 = Empty then () else invalid_arg "Mapext.iter2" + | Node (l1,k,d1,r1,h1) -> + match cut k m2 with + | l2, Some d2, r2 -> iter2 f l1 l2; f k d1 d2; iter2 f r1 r2 + | _, None, _ -> invalid_arg "Mapext.iter2" + + let rec fold2 f m1 m2 acc = + match m1 with + | Empty -> if m2 = Empty then acc else invalid_arg "Mapext.fold2" + | Node (l1,k,d1,r1,h1) -> + match cut k m2 with + | l2, Some d2, r2 -> + fold2 f r1 r2 (f k d1 d2 (fold2 f l1 l2 acc)) + | _, None, _ -> invalid_arg "Mapext.fold2" + + let rec for_all2 f m1 m2 = + match m1 with + | Empty -> if m2 = Empty then true else invalid_arg "Mapext.for_all2" + | Node (l1,k,d1,r1,h1) -> + match cut k m2 with + | l2, Some d2, r2 -> + for_all2 f l1 l2 && f k d1 d2 && for_all2 f r1 r2 + | _, None, _ -> invalid_arg "Mapext.for_all2" + + let rec exists2 f m1 m2 = + match m1 with + | Empty -> if m2 = Empty then false else invalid_arg "Mapext.exists2" + | Node (l1,k,d1,r1,h1) -> + match cut k m2 with + | l2, Some d2, r2 -> + exists2 f l1 l2 || f k d1 d2 || exists2 f r1 r2 + | _, None, _ -> invalid_arg "Mapext.exists2" + + + (* as above, but ignore physically equal subtrees + - for map, assumes: f k d d = d + - for iter, assumes: f k d d has no effect + - for fold, assumes: k f d d acc = acc + - for for_all, assumes: f k d d = true + - for exists, assumes: f k d d = false + *) + + let rec map2z f m1 m2 = + if m1 == m2 then m1 else + match m1 with + | Empty -> if m2 = Empty then Empty else invalid_arg "Mapext.map2z" + | Node (l1,k,d1,r1,h1) -> + match cut k m2 with + | l2, Some d2, r2 -> + let d = if d1 == d2 then d1 else f k d1 d2 in + Node (map2z f l1 l2, k, d, map2z f r1 r2, h1) + | _, None, _ -> invalid_arg "Mapext.map2z" + + let rec iter2z f m1 m2 = + if m1 == m2 then () else + match m1 with + | Empty -> if m2 = Empty then () else invalid_arg "Mapext.iter2z" + | Node (l1,k,d1,r1,h1) -> + match cut k m2 with + | l2, Some d2, r2 -> + iter2z f l1 l2; (if d1 != d2 then f k d1 d2); iter2z f r1 r2 + | _, None, _ -> invalid_arg "Mapext.iter2z" + + let rec fold2z f m1 m2 acc = + if m1 == m2 then acc else + match m1 with + | Empty -> if m2 = Empty then acc else invalid_arg "Mapext.fold2z" + | Node (l1,k,d1,r1,h1) -> + match cut k m2 with + | l2, Some d2, r2 -> + let acc = fold2z f l1 l2 acc in + let acc = if d1 == d2 then acc else f k d1 d2 acc in + fold2z f r1 r2 acc + | _, None, _ -> invalid_arg "Mapext.fold2z" + + let rec for_all2z f m1 m2 = + (m1 == m2) || + (match m1 with + | Empty -> if m2 = Empty then true else invalid_arg "Mapext.for_all2z" + | Node (l1,k,d1,r1,h1) -> + match cut k m2 with + | l2, Some d2, r2 -> + (for_all2z f l1 l2) && + (d1 == d2 || f k d1 d2) && + (for_all2z f r1 r2) + | _, None, _ -> invalid_arg "Mapext.for_all2z" + ) + + let rec exists2z f m1 m2 = + (m1 != m2) && + (match m1 with + | Empty -> if m2 = Empty then false else invalid_arg "Mapext.exists2z" + | Node (l1,k,d1,r1,h1) -> + match cut k m2 with + | l2, Some d2, r2 -> + (exists2z f l1 l2) || + (d1 != d2 && f k d1 d2) || + (exists2z f r1 r2) + | _, None, _ -> invalid_arg "Mapext.exists2z" + ) + + + (* as above, but allow maps with different keys *) + + let rec map2o f1 f2 f m1 m2 = + match m1 with + | Empty -> mapi f2 m2 + | Node (l1,k,d1,r1,h1) -> + let l2, d2, r2 = cut k m2 in + let l = map2o f1 f2 f l1 l2 in + let d = match d2 with None -> f1 k d1 | Some d2 -> f k d1 d2 in + let r = map2o f1 f2 f r1 r2 in + join l k d r + + let rec iter2o f1 f2 f m1 m2 = + match m1 with + | Empty -> iter f2 m2 + | Node (l1,k,d1,r1,h1) -> + let l2, d2, r2 = cut k m2 in + iter2o f1 f2 f l1 l2; + (match d2 with None -> f1 k d1 | Some d2 -> f k d1 d2); + iter2o f1 f2 f r1 r2 + + let rec fold2o f1 f2 f m1 m2 acc = + match m1 with + | Empty -> fold f2 m2 acc + | Node (l1,k,d1,r1,h1) -> + let l2, d2, r2 = cut k m2 in + let acc = fold2o f1 f2 f l1 l2 acc in + let acc = match d2 with + | None -> f1 k d1 acc | Some d2 -> f k d1 d2 acc + in + fold2o f1 f2 f r1 r2 acc + + let rec for_all2o f1 f2 f m1 m2 = + match m1 with + | Empty -> for_all f2 m2 + | Node (l1,k,d1,r1,h1) -> + let l2, d2, r2 = cut k m2 in + (for_all2o f1 f2 f l1 l2) && + (match d2 with None -> f1 k d1 | Some d2 -> f k d1 d2) && + (for_all2o f1 f2 f r1 r2) + + let rec exists2o f1 f2 f m1 m2 = + match m1 with + | Empty -> exists f2 m2 + | Node (l1,k,d1,r1,h1) -> + let l2, d2, r2 = cut k m2 in + (exists2o f1 f2 f l1 l2) || + (match d2 with None -> f1 k d1 | Some d2 -> f k d1 d2) || + (exists2o f1 f2 f r1 r2) + + + (* all together now *) + + let rec map2zo f1 f2 f m1 m2 = + if m1 == m2 then m1 else + match m1 with + | Empty -> mapi f2 m2 + | Node (l1,k,d1,r1,h1) -> + let l2, d2, r2 = cut k m2 in + let l = map2zo f1 f2 f l1 l2 in + let d = match d2 with + | None -> f1 k d1 + | Some d2 -> if d1 == d2 then d1 else f k d1 d2 + in + let r = map2zo f1 f2 f r1 r2 in + join l k d r + + let rec iter2zo f1 f2 f m1 m2 = + if m1 == m2 then () else + match m1 with + | Empty -> iter f2 m2 + | Node (l1,k,d1,r1,h1) -> + let l2, d2, r2 = cut k m2 in + iter2zo f1 f2 f l1 l2; + (match d2 with + | None -> f1 k d1 + | Some d2 -> if d1 != d2 then f k d1 d2); + iter2zo f1 f2 f r1 r2 + + let rec fold2zo f1 f2 f m1 m2 acc = + if m1 == m2 then acc else + match m1 with + | Empty -> fold f2 m2 acc + | Node (l1,k,d1,r1,h1) -> + let l2, d2, r2 = cut k m2 in + let acc = fold2zo f1 f2 f l1 l2 acc in + let acc = match d2 with + | None -> f1 k d1 acc + | Some d2 -> if d1 == d2 then acc else f k d1 d2 acc + in + fold2zo f1 f2 f r1 r2 acc + + let rec for_all2zo f1 f2 f m1 m2 = + (m1 == m2) || + (match m1 with + | Empty -> for_all f2 m2 + | Node (l1,k,d1,r1,h1) -> + let l2, d2, r2 = cut k m2 in + (for_all2zo f1 f2 f l1 l2) && + (match d2 with None -> f1 k d1 | Some d2 -> d1 == d2 || f k d1 d2) && + (for_all2zo f1 f2 f r1 r2) + ) + + let rec exists2zo f1 f2 f m1 m2 = + (m1 != m2) && + (match m1 with + | Empty -> exists f2 m2 + | Node (l1,k,d1,r1,h1) -> + let l2, d2, r2 = cut k m2 in + (exists2zo f1 f2 f l1 l2) || + (match d2 with None -> f1 k d1 | Some d2 -> d1 != d2 && f k d1 d2) || + (exists2zo f1 f2 f r1 r2) + ) + + + (* iterators limited to keys between two bounds *) + + let rec map_slice f m lo hi = + match m with + | Empty -> Empty + | Node (l,k,d,r,h) -> + let c1, c2 = Ord.compare k lo, Ord.compare k hi in + let l = if c1 > 0 then map_slice f l lo k else l in + let d = if c1 >= 0 && c2 <= 0 then f k d else d in + let r = if c2 < 0 then map_slice f r k hi else r in + Node (l,k,d,r,h) + + let rec iter_slice f m lo hi = + match m with + | Empty -> () + | Node (l,k,d,r,_) -> + let c1, c2 = Ord.compare k lo, Ord.compare k hi in + if c1 > 0 then iter_slice f l lo k; + if c1 >= 0 && c2 <= 0 then f k d; + if c2 < 0 then iter_slice f r k hi + + let rec fold_slice f m lo hi acc = + match m with + | Empty -> acc + | Node (l,k,d,r,_) -> + let c1, c2 = Ord.compare k lo, Ord.compare k hi in + let acc = if c1 > 0 then fold_slice f l lo k acc else acc in + let acc = if c1 >= 0 && c2 <= 0 then f k d acc else acc in + if c2 < 0 then fold_slice f r k hi acc else acc + + let rec for_all_slice f m lo hi = + match m with + | Empty -> true + | Node (l,k,d,r,_) -> + let c1, c2 = Ord.compare k lo, Ord.compare k hi in + (c1 <= 0 || for_all_slice f l lo k) && + (c1 < 0 || c2 > 0 || f k d) && + (c2 >= 0 || for_all_slice f r k hi) + + let rec exists_slice f m lo hi = + match m with + | Empty -> false + | Node (l,k,d,r,_) -> + let c1, c2 = Ord.compare k lo, Ord.compare k hi in + (c1 > 0 && exists_slice f l lo k) || + (c1 >= 0 && c2 <= 0 && f k d) || + (c2 < 0 && exists_slice f r k hi) + + + (* key set comparison *) + + let rec key_equal m1 m2 = + (m1 == m2) || + (match m1 with + | Empty -> m2 = Empty + | Node (l1, k, _, r1, _) -> + match cut k m2 with + | _, None, _ -> false + | l2, Some _, r2 -> key_equal l1 l2 && key_equal r1 r2 + ) + + let rec key_subset m1 m2 = + (m1 == m2) || + (match m1 with + | Empty -> true + | Node (l1, k, _, r1, _) -> + match cut k m2 with + | _, None, _ -> false + | l2, Some _, r2 -> key_subset l1 l2 && key_subset r1 r2 + ) + + + (* nagivation *) + + let find_greater_equal k m = + let rec aux m found = match m with + | Empty -> (match found with None -> raise Not_found | Some x -> x) + | Node (l, kk, d, r, _) -> + let c = Ord.compare k kk in + if c = 0 then kk, d else + if c > 0 then aux r found else + aux l (Some (kk, d)) + in + aux m None + + let find_greater k m = + let rec aux m found = match m with + | Empty -> (match found with None -> raise Not_found | Some x -> x) + | Node (l, kk, d, r, _) -> + let c = Ord.compare k kk in + if c >= 0 then aux r found else + aux l (Some (kk, d)) + in + aux m None + + let find_less_equal k m = + let rec aux m found = match m with + | Empty -> (match found with None -> raise Not_found | Some x -> x) + | Node (l, kk, d, r, _) -> + let c = Ord.compare k kk in + if c = 0 then kk, d else + if c < 0 then aux l found else + aux r (Some (kk, d)) + in + aux m None + + let find_less k m = + let rec aux m found = match m with + | Empty -> (match found with None -> raise Not_found | Some x -> x) + | Node (l, kk, d, r, _) -> + let c = Ord.compare k kk in + if c <= 0 then aux l found else + aux r (Some (kk, d)) + in + aux m None + + +end: S with type key = Ord.t) diff --git a/libs/mapext.mli b/libs/mapext.mli new file mode 100644 index 0000000..abee2c0 --- /dev/null +++ b/libs/mapext.mli @@ -0,0 +1,473 @@ +(* + Cours "Sémantique et Application à la Vérification de programmes" + + Antoine Miné 2014 + Ecole normale supérieure, Paris, France / CNRS / INRIA +*) + +(* + This file is derived from the mapi.ml file from the OCaml distribution. + Changes are marked with the [AM] symbol. + Based on rev. 10632 2010-07-24 14:16:58Z. + + Original copyright follows. +*) + + +(***********************************************************************) +(* *) +(* Objective Caml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. All rights reserved. This file is distributed *) +(* under the terms of the GNU Library General Public License, with *) +(* the special exception on linking described in file ../LICENSE. *) +(* *) +(***********************************************************************) + +(* $Id: mapext.mli,v 1.1 2014-02-24 16:25:06 mine Exp $ *) + +(** Association tables over ordered types. + + This module implements applicative association tables, also known as + finite maps or dictionaries, given a total ordering function + over the keys. + All operations over maps are purely applicative (no side-effects). + The implementation uses balanced binary trees, and therefore searching + and insertion take time logarithmic in the size of the map. +*) + +module type OrderedType = + sig + type t + (** The type of the map keys. *) + val compare : t -> t -> int + (** A total ordering function over the keys. + This is a two-argument function [f] such that + [f e1 e2] is zero if the keys [e1] and [e2] are equal, + [f e1 e2] is strictly negative if [e1] is smaller than [e2], + and [f e1 e2] is strictly positive if [e1] is greater than [e2]. + Example: a suitable ordering function is the generic structural + comparison function {!Pervasives.compare}. *) + end +(** Input signature of the functor {!Map.Make}. *) + +module type S = + sig + type key + (** The type of the map keys. *) + + type (+'a) t + (** The type of maps from type [key] to type ['a]. *) + + val empty: 'a t + (** The empty map. *) + + val is_empty: 'a t -> bool + (** Test whether a map is empty or not. *) + + val mem: key -> 'a t -> bool + (** [mem x m] returns [true] if [m] contains a binding for [x], + and [false] otherwise. *) + + val add: key -> 'a -> 'a t -> 'a t + (** [add x y m] returns a map containing the same bindings as + [m], plus a binding of [x] to [y]. If [x] was already bound + in [m], its previous binding disappears. *) + + val singleton: key -> 'a -> 'a t + (** [singleton x y] returns the one-element map that contains a binding [y] + for [x]. + @since 3.12.0 + *) + + val remove: key -> 'a t -> 'a t + (** [remove x m] returns a map containing the same bindings as + [m], except for [x] which is unbound in the returned map. *) + + val merge: + (key -> 'a option -> 'b option -> 'c option) -> 'a t -> 'b t -> 'c t + (** [merge f m1 m2] computes a map whose keys is a subset of keys of [m1] + and of [m2]. The presence of each such binding, and the corresponding + value, is determined with the function [f]. + @since 3.12.0 + *) + + val compare: ('a -> 'a -> int) -> 'a t -> 'a t -> int + (** Total ordering between maps. The first argument is a total ordering + used to compare data associated with equal keys in the two maps. *) + + val equal: ('a -> 'a -> bool) -> 'a t -> 'a t -> bool + (** [equal cmp m1 m2] tests whether the maps [m1] and [m2] are + equal, that is, contain equal keys and associate them with + equal data. [cmp] is the equality predicate used to compare + the data associated with the keys. *) + + val iter: (key -> 'a -> unit) -> 'a t -> unit + (** [iter f m] applies [f] to all bindings in map [m]. + [f] receives the key as first argument, and the associated value + as second argument. The bindings are passed to [f] in increasing + order with respect to the ordering over the type of the keys. *) + + val fold: (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b + (** [fold f m a] computes [(f kN dN ... (f k1 d1 a)...)], + where [k1 ... kN] are the keys of all bindings in [m] + (in increasing order), and [d1 ... dN] are the associated data. *) + + val for_all: (key -> 'a -> bool) -> 'a t -> bool + (* [AM] now guarantees the evaluation order *) + (** [for_all p m] checks if all the bindings of the map + satisfy the predicate [p]. + The predicate [p] is tested on bindings according to the key order. + @since 3.12.0 + *) + + val exists: (key -> 'a -> bool) -> 'a t -> bool + (* [AM] now guarantees the evaluation order *) + (** [exists p m] checks if at least one binding of the map + satisfy the predicate [p]. + The predicate [p] is tested on bindings according to the key order. + @since 3.12.0 + *) + + val filter: (key -> 'a -> bool) -> 'a t -> 'a t + (* [AM] now guarantees the evaluation order *) + (** [filter p m] returns the map with all the bindings in [m] + that satisfy predicate [p]. + The predicate [p] is tested on bindings according to the key order. + @since 3.12.0 + *) + + val partition: (key -> 'a -> bool) -> 'a t -> 'a t * 'a t + (** [partition p m] returns a pair of maps [(m1, m2)], where + [m1] contains all the bindings of [s] that satisfy the + predicate [p], and [m2] is the map with all the bindings of + [s] that do not satisfy [p]. + @since 3.12.0 + *) + + val cardinal: 'a t -> int + (** Return the number of bindings of a map. + @since 3.12.0 + *) + + val bindings: 'a t -> (key * 'a) list + (** Return the list of all bindings of the given map. + The returned list is sorted in increasing order with respect + to the ordering [Ord.compare], where [Ord] is the argument + given to {!Map.Make}. + @since 3.12.0 + *) + + val min_binding: 'a t -> (key * 'a) + (** Return the smallest binding of the given map + (with respect to the [Ord.compare] ordering), or raise + [Not_found] if the map is empty. + @since 3.12.0 + *) + + val max_binding: 'a t -> (key * 'a) + (** Same as {!Map.S.min_binding}, but returns the largest binding + of the given map. + @since 3.12.0 + *) + + val choose: 'a t -> (key * 'a) + (** Return one binding of the given map, or raise [Not_found] if + the map is empty. Which binding is chosen is unspecified, + but equal bindings will be chosen for equal maps. + @since 3.12.0 + *) + + val split: key -> 'a t -> 'a t * 'a option * 'a t + (** [split x m] returns a triple [(l, data, r)], where + [l] is the map with all the bindings of [m] whose key + is strictly less than [x]; + [r] is the map with all the bindings of [m] whose key + is strictly greater than [x]; + [data] is [None] if [m] contains no binding for [x], + or [Some v] if [m] binds [v] to [x]. + @since 3.12.0 + *) + + val find: key -> 'a t -> 'a + (** [find x m] returns the current binding of [x] in [m], + or raises [Not_found] if no such binding exists. *) + + val map: ('a -> 'b) -> 'a t -> 'b t + (** [map f m] returns a map with same domain as [m], where the + associated value [a] of all bindings of [m] has been + replaced by the result of the application of [f] to [a]. + The bindings are passed to [f] in increasing order + with respect to the ordering over the type of the keys. *) + + val mapi: (key -> 'a -> 'b) -> 'a t -> 'b t + (** Same as {!Map.S.map}, but the function receives as arguments both the + key and the associated value for each binding of the map. *) + + + (* [AM] additions *) + + (** {2 Additional functions} *) + + val of_list: (key * 'a) list -> 'a t + (** [of_list l] converts an association list to a map. *) + + val map2: (key -> 'a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t + (** [map2 f m1 m2] is similar to [map] but applies [f] to pairs + of bindings [a1] from [m1] and [a2] from [m2] corresponding to + the same key to construct a new map with the same key set. + [m1] and [m2] must have the same key sets. + The binging are passed to [f] in increasing order of key. *) + + val iter2: (key -> 'a -> 'b -> unit) -> 'a t -> 'b t -> unit + (** [iter2 f m1 m2] is similar to [map] but applies [f] to pairs + of bindings [a1] from [m1] and [a2] from [m2] corresponding to + the same key. + [m1] and [m2] must have the same key sets. + The binging are passed to [f] in increasing order of key. *) + + val fold2: (key -> 'a -> 'b -> 'c -> 'c) -> 'a t -> 'b t -> 'c -> 'c + (** [fold2 f m1 m2 x] is similar to [fold] but applies [f] to pairs + of bindings [a1] from [m1] and [a2] from [m2] corresponding to + the same key. + [m1] and [m2] must have the same key sets. + The bindings are passed to [f] in increasing order of keys. *) + + val for_all2: (key -> 'a -> 'b -> bool) -> 'a t -> 'b t -> bool + (** [for_all2 f m1 m2] is similar to [for_all] but applies [f] to pairs + of bindings [a1] from [m1] and [a2] from [m2] corresponding to + the same key. + [m1] and [m2] must have the same key sets. + The bindings are passed to [f] in increasing order of keys. *) + + val exists2: (key -> 'a -> 'b -> bool) -> 'a t -> 'b t -> bool + (** [exists2 f m1 m2] is similar to [exists] but applies [f] to pairs + of bindings [a1] from [m1] and [a2] from [m2] corresponding to + the same key. + [m1] and [m2] must have the same key sets. + The bindings are passed to [f] in increasing order of keys. *) + + + + + val map2z: (key -> 'a -> 'a -> 'a) -> 'a t -> 'a t -> 'a t + (** [map2z f m1 m2] is similar to [map2 f m1 m2], but physically + equal subtrees are put unchanged into the result instead of + being traversed. + This is more efficient than [map2], and equivalent if [f] is + side-effect free and idem-potent ([f k a a = a]). + [m1] and [m2] must have the same key sets. + The bindings are passed to [f] in increasing order of keys. *) + + val iter2z: (key -> 'a -> 'a -> unit) -> 'a t -> 'a t -> unit + (** [iter2z f m1 m2] is similar to [iter2 f m1 m2], but physically + equal subtrees are ignored. + This is more efficient than [iter2], and equivalent if + [f k a a] has no effect. + [m1] and [m2] must have the same key sets. + The bindings are passed to [f] in increasing order of keys. *) + + val fold2z: (key -> 'a -> 'a -> 'b -> 'b) -> 'a t -> 'a t -> 'b -> 'b + (** [fold2z f m1 m2 a] is similar to [fold2 f m1 m2 a], but physically + equal subtrees are ignored. + This is more efficient than [fold2], and equivalent if + [f k a a x = x] and has no effect. + [m1] and [m2] must have the same key sets. + The bindings are passed to [f] in increasing order of keys. *) + + val for_all2z: (key -> 'a -> 'a -> bool) -> 'a t -> 'a t -> bool + (** [for_all2z f m1 m2] is similar to [for_all2 f m1 m2], but returns + [true] for physically equal subtrees without traversing them. + This is more efficient than [for_all2z], and equivalent if + [f k a a = true] and has no effect. + [m1] and [m2] must have the same key sets. + The bindings are passed to [f] in increasing order of keys. *) + + val exists2z: (key -> 'a -> 'a -> bool) -> 'a t -> 'a t -> bool + (** [exists2z f m1 m2] is similar to [exists2 f m1 m2], but returns + [false] for physically equal subtrees without traversing them. + This is more efficient than [exists2z], and equivalent if + [f k a a = false] and has no effect. + [m1] and [m2] must have the same key sets. + The bindings are passed to [f] in increasing order of keys. *) + + + + + val map2o: (key -> 'a -> 'c) -> (key -> 'b -> 'c) -> (key -> 'a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t + (** [map2o f1 f2 f m1 m2] is similar to [map2 f m1 m2], but + accepts maps defined over different sets of keys. + To get a new binding, [f1] is used for keys appearing only + in [m1], [f2] for keys appearing only in [m2], and [f] for + keys appearing in both maps. + The returned map has bindings for all keys appearing in either + [m1] or [m2]. + The bindings are passed to [f], [f1], [f2] in increasing order of keys. *) + + val iter2o: (key -> 'a -> unit) -> (key -> 'b -> unit) -> (key -> 'a -> 'b -> unit) -> 'a t -> 'b t -> unit + (** [iter2o f1 f2 f m1 m2] is similar to [iter2 f m1 m2], but + accepts maps defined over different sets of keys. + [f1] is called for keys appearing only in [m1], + [f2] for keys appearing only in [m2], + and [f] for keys appearing in both maps. + The bindings are passed to [f], [f1], [f2] in increasing order of keys. *) + + val fold2o: (key -> 'a -> 'c -> 'c) -> (key -> 'b -> 'c -> 'c) -> (key -> 'a -> 'b -> 'c -> 'c) -> 'a t -> 'b t -> 'c -> 'c + (** [fold2o f1 f2 f m1 m2 a] is similar to [fold2 f m1 m2 a], but + accepts maps defined over different sets of keys. + [f1] is called for keys appearing only in [m1], + [f2] for keys appearing only in [m2], + and [f] for keys appearing in both maps. + The bindings are passed to [f], [f1], [f2] in increasing order of keys. *) + + val for_all2o: (key -> 'a -> bool) -> (key -> 'b -> bool) -> (key -> 'a -> 'b -> bool) -> 'a t -> 'b t -> bool + (** [for_all2o f1 f2 f m1 m2] is similar to [for_all2 f m1 m2], but + accepts maps defined over different sets of keys. + [f1] is called for keys appearing only in [m1], + [f2] for keys appearing only in [m2], + and [f] for keys appearing in both maps. + The bindings are passed to [f], [f1], [f2] in increasing order of keys. *) + + val exists2o: (key -> 'a -> bool) -> (key -> 'b -> bool) -> (key -> 'a -> 'b -> bool) -> 'a t -> 'b t -> bool + (** [fexists2o f1 f2 f m1 m2] is similar to [fexists2 f m1 m2], but + accepts maps defined over different sets of keys. + [f1] is called for keys appearing only in [m1], + [f2] for keys appearing only in [m2], + and [f] for keys appearing in both maps. + The bindings are passed to [f], [f1], [f2] in increasing order of keys. *) + + + + val map2zo: (key -> 'a -> 'a) -> (key -> 'a -> 'a) -> (key -> 'a -> 'a -> 'a) -> 'a t -> 'a t -> 'a t + (** [map2zo f1 f2 f m1 m2] is similar to [map2o f1 f2 f m1 m2] but, + similary to [map2z], [f] is not called on physically equal + subtrees. + This is more efficient than [map2o], and equivalent if [f] is + side-effect free and idem-potent ([f k a a = a]). + The returned map has bindings for all keys appearing in either + [m1] or [m2]. + The bindings are passed to [f], [f1], [f2] in increasing order of keys. *) + + val iter2zo: (key -> 'a -> unit) -> (key -> 'a -> unit) -> (key -> 'a -> 'a -> unit) -> 'a t -> 'a t -> unit + (** [iter2zo f1 f2 f m1 m2] is similar to [iter2o f1 f2 f m1 m2] but, + similary to [iter2z], [f] is not called on physically equal + subtrees. + This is more efficient than [iter2o], and equivalent if [f] is + side-effect free. + The bindings are passed to [f], [f1], [f2] in increasing order of keys. *) + + val fold2zo: (key -> 'a -> 'b -> 'b) -> (key -> 'a -> 'b -> 'b) -> (key -> 'a -> 'a -> 'b -> 'b) -> 'a t -> 'a t -> 'b -> 'b + (** [fold2zo f1 f2 f m1 m2 a] is similar to [fold2o f1 f2 f m1 m2 a] but, + similary to [fold2z], [f] is not called on physically equal + subtrees. + This is more efficient than [fold2o], and equivalent if + [f k a a x = x] and has no side-effect. + The bindings are passed to [f], [f1], [f2] in increasing order of keys. *) + + val for_all2zo: (key -> 'a -> bool) -> (key -> 'a -> bool) -> (key -> 'a -> 'a -> bool) -> 'a t -> 'a t -> bool + (** [for_all2zo f1 f2 f m1 m2] is similar to [for_all2o f1 f2 f m1 m2] but, + similary to [for_all2z], [f] is not called on physically equal + subtrees. + This is more efficient than [for_all2o], and equivalent if + [f k a a = true] and has no side-effect. + The bindings are passed to [f], [f1], [f2] in increasing order of keys. *) + + val exists2zo: (key -> 'a -> bool) -> (key -> 'a -> bool) -> (key -> 'a -> 'a -> bool) -> 'a t -> 'a t -> bool + (** [exists2zo f1 f2 f m1 m2] is similar to [exists2o f1 f2 f m1 m2] but, + similary to [exists2z], [f] is not called on physically equal + subtrees. + This is more efficient than [exists2o], and equivalent if + [f k a a = false] and has no side-effect. + The bindings are passed to [f], [f1], [f2] in increasing order of keys. *) + + val map_slice: (key -> 'a -> 'a) -> 'a t -> key -> key -> 'a t + (** [map_slice f m k1 k2] is similar to [map f m], but only applies + [f] to bindings with key greater or equal to [k1] and smaller + or equal to [k2] to construct the returned map. Bindings with + keys outside this range in [m] are put unchanged in the result. + It is as if, outside this range, [f k a = a] and has no effect. + The result has the same key set as [m]. + The bindings are passed to [f] in increasing order of keys, + between [k1] and [k2]. *) + + val iter_slice: (key -> 'a -> unit) -> 'a t -> key -> key -> unit + (** [iter_slice f m k1 k2] is similar to [iter f m], but only calls + [f] on bindings with key greater or equal to [k1] and smaller + or equal to [k2]. + It is as if, outside this range, [f k a] has no effect. + The bindings are passed to [f] in increasing order of keys, + between [k1] and [k2]. *) + + val fold_slice: (key -> 'a -> 'b -> 'b) -> 'a t -> key -> key -> 'b -> 'b + (** [fold_slice f m k1 k2 a] is similar to [fold f m], but only calls + [f] on bindings with key greater or equal to [k1] and smaller + or equal to [k2]. + It is as if, outside this range, [f k a x = x] and has no effect. + The bindings are passed to [f] in increasing order of keys, + between [k1] and [k2]. *) + + val for_all_slice: (key -> 'a -> bool) -> 'a t -> key -> key -> bool + (** [for_all_slice f m k1 k2 a] is similar to [for_all f m], but only calls + [f] on bindings with key greater or equal to [k1] and smaller + or equal to [k2]. + It is as if, outside this range, [f k a = true] and has no effect. + The bindings are passed to [f] in increasing order of keys, + between [k1] and [k2]. *) + + val exists_slice: (key -> 'a -> bool) -> 'a t -> key -> key -> bool + (** [exists_slice f m k1 k2 a] is similar to [exists f m], but only calls + [f] on bindings with key greater or equal to [k1] and smaller + or equal to [k2]. + It is as if, outside this range, [f k a = false] and has no effect. + The bindings are passed to [f] in increasing order of keys, + between [k1] and [k2]. *) + + val key_equal: 'a t -> 'a t -> bool + (** [key_equal m1 m2] returns true if [m1] and [m2] are defined + over exactly the same set of keys (but with possibly different + values). + *) + + val key_subset: 'a t -> 'a t -> bool + (** [key_equal m1 m2] returns true if [m1] is defined on a subset of + the keys of [m2] (but with possibly different values). + *) + + val find_greater: key -> 'a t -> key * 'a + (** [find_greater k m] returns the binding (key and value) in [m] + with key strictly greater than [k] and as small as possible. + Raises [Not_found] if [m] has no binding for a key strictly greater + than [k]. + *) + + val find_less: key -> 'a t -> key * 'a + (** [find_less k m] returns the binding (key and value) in [m] + with key strictly less than [k] and as large as possible. + Raises [Not_found] if [m] has no binding for a key strictly less + than [k]. + *) + + val find_greater_equal: key -> 'a t -> key * 'a + (** [find_greater_euql k m] returns the binding (key and value) in [m] + with key greater or equal to [k] and as small as possible. + Raises [Not_found] if [m] has no binding for a key greater or equal + to [k]. + *) + + val find_less_equal: key -> 'a t -> key * 'a + (** [find_less_equal k m] returns the binding (key and value) in [m] + with key less or equal to [k] and as large as possible. + Raises [Not_found] if [m] has no binding for a key less or equal + to [k]. + *) + + + end +(** Output signature of the functor {!Map.Make}. *) + +module Make (Ord : OrderedType) : S with type key = Ord.t +(** Functor building an implementation of the map structure + given a totally ordered type. *) diff --git a/main.ml b/main.ml new file mode 100644 index 0000000..2db911e --- /dev/null +++ b/main.ml @@ -0,0 +1,27 @@ +(* + Cours "Sémantique et Application à la Vérification de programmes" + + Antoine Miné 2014 + Ecole normale supérieure, Paris, France / CNRS / INRIA +*) + +(* + Simple driver: parses the file given as argument and prints it back. + + You should modify this file to call your functions instead! +*) + + +(* parse and print filename *) +let doit filename = + let prog = File_parser.parse_file filename in + Abstract_syntax_printer.print_prog Format.std_formatter prog + + +(* parses arguments to get filename *) +let main () = + match Array.to_list Sys.argv with + | _::filename::_ -> doit filename + | _ -> invalid_arg "no source file specified" + +let _ = main () diff --git a/tests/README.txt b/tests/README.txt new file mode 100644 index 0000000..ff2a94c --- /dev/null +++ b/tests/README.txt @@ -0,0 +1,32 @@ +The sources/ directory contains a set of small program examples to test your +analyzer. + +The files are ordered by increasing complexity and language features. +They are classified into categories according to the file name prefix, +as follow: +- 00*: variable declarations, initialization with a constant +- 01*: printing, local declarations +- 02*: assignment, arithmetic operators +- 03*: if-then-else, comparisons and boolean operators +- 04*: assertions +- 05*: loops +- 06*: realistic examples mixing all of the above + +The results/ directory gives the output of the analysis using our +reference analyzer, with the constant, the interval, and the polyhedra +domains. +All the analyses are preformed using a loop unrolling of 3 and a widening +delay of 3. +Our analyzer outputs a line for each print instruction and for each assertion +failure, as well as the abstract environment when the program stops. +Note that, due to loop unrolling, a print or assert statement may be executed +more than once. Note also that, during fixpoint computation, the output of +print and assert statements is disabled; it is re-enabled only after the +fixpoint is reached, so that we do not print any information about the +iterates (which may not be invariants). + +For each source file and each domain (constants, intervals, polyhedra), we +provide the file output by the reference analyzer. +We also provide for each domain a summary file (named all.*.txt) that contains +each file followed by the analysis result, which may be more convenient to +read. diff --git a/tests/results/0000_noinit_var.constants.txt b/tests/results/0000_noinit_var.constants.txt new file mode 100644 index 0000000..1e125b7 --- /dev/null +++ b/tests/results/0000_noinit_var.constants.txt @@ -0,0 +1 @@ +Output: [ x in top ] diff --git a/tests/results/0000_noinit_var.intervals.txt b/tests/results/0000_noinit_var.intervals.txt new file mode 100644 index 0000000..eda51d2 --- /dev/null +++ b/tests/results/0000_noinit_var.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [-oo;+oo] ] diff --git a/tests/results/0000_noinit_var.polyhedra.txt b/tests/results/0000_noinit_var.polyhedra.txt new file mode 100644 index 0000000..f62b6cf --- /dev/null +++ b/tests/results/0000_noinit_var.polyhedra.txt @@ -0,0 +1 @@ +Output: top diff --git a/tests/results/0001_noinit_2var.constants.txt b/tests/results/0001_noinit_2var.constants.txt new file mode 100644 index 0000000..b7ada66 --- /dev/null +++ b/tests/results/0001_noinit_2var.constants.txt @@ -0,0 +1 @@ +Output: [ x in top, y in top ] diff --git a/tests/results/0001_noinit_2var.intervals.txt b/tests/results/0001_noinit_2var.intervals.txt new file mode 100644 index 0000000..f1b9aa5 --- /dev/null +++ b/tests/results/0001_noinit_2var.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [-oo;+oo], y in [-oo;+oo] ] diff --git a/tests/results/0001_noinit_2var.polyhedra.txt b/tests/results/0001_noinit_2var.polyhedra.txt new file mode 100644 index 0000000..f62b6cf --- /dev/null +++ b/tests/results/0001_noinit_2var.polyhedra.txt @@ -0,0 +1 @@ +Output: top diff --git a/tests/results/0002_init_var.constants.txt b/tests/results/0002_init_var.constants.txt new file mode 100644 index 0000000..6423d75 --- /dev/null +++ b/tests/results/0002_init_var.constants.txt @@ -0,0 +1 @@ +Output: [ x in {0} ] diff --git a/tests/results/0002_init_var.intervals.txt b/tests/results/0002_init_var.intervals.txt new file mode 100644 index 0000000..9fe0945 --- /dev/null +++ b/tests/results/0002_init_var.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [0;0] ] diff --git a/tests/results/0002_init_var.polyhedra.txt b/tests/results/0002_init_var.polyhedra.txt new file mode 100644 index 0000000..072e333 --- /dev/null +++ b/tests/results/0002_init_var.polyhedra.txt @@ -0,0 +1 @@ +Output: [|x=0|] diff --git a/tests/results/0003_init_2var.constants.txt b/tests/results/0003_init_2var.constants.txt new file mode 100644 index 0000000..9e88fcd --- /dev/null +++ b/tests/results/0003_init_2var.constants.txt @@ -0,0 +1 @@ +Output: [ x in {0}, y in {1} ] diff --git a/tests/results/0003_init_2var.intervals.txt b/tests/results/0003_init_2var.intervals.txt new file mode 100644 index 0000000..dd131bf --- /dev/null +++ b/tests/results/0003_init_2var.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [0;0], y in [1;1] ] diff --git a/tests/results/0003_init_2var.polyhedra.txt b/tests/results/0003_init_2var.polyhedra.txt new file mode 100644 index 0000000..efeddf5 --- /dev/null +++ b/tests/results/0003_init_2var.polyhedra.txt @@ -0,0 +1 @@ +Output: [|y-1=0; x=0|] diff --git a/tests/results/0004_init_2var2.constants.txt b/tests/results/0004_init_2var2.constants.txt new file mode 100644 index 0000000..91cb6ba --- /dev/null +++ b/tests/results/0004_init_2var2.constants.txt @@ -0,0 +1 @@ +Output: [ x in {9}, y in {12} ] diff --git a/tests/results/0004_init_2var2.intervals.txt b/tests/results/0004_init_2var2.intervals.txt new file mode 100644 index 0000000..709f31a --- /dev/null +++ b/tests/results/0004_init_2var2.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [9;9], y in [12;12] ] diff --git a/tests/results/0004_init_2var2.polyhedra.txt b/tests/results/0004_init_2var2.polyhedra.txt new file mode 100644 index 0000000..5b868c5 --- /dev/null +++ b/tests/results/0004_init_2var2.polyhedra.txt @@ -0,0 +1 @@ +Output: [|y-12=0; x-9=0|] diff --git a/tests/results/0100_print_var.constants.txt b/tests/results/0100_print_var.constants.txt new file mode 100644 index 0000000..7fd6b1c --- /dev/null +++ b/tests/results/0100_print_var.constants.txt @@ -0,0 +1,2 @@ +sources/0100_print_var.c:2.0-9: [ x in {2} ] +Output: [ x in {2} ] diff --git a/tests/results/0100_print_var.intervals.txt b/tests/results/0100_print_var.intervals.txt new file mode 100644 index 0000000..2fa1f97 --- /dev/null +++ b/tests/results/0100_print_var.intervals.txt @@ -0,0 +1,2 @@ +sources/0100_print_var.c:2.0-9: [ x in [2;2] ] +Output: [ x in [2;2] ] diff --git a/tests/results/0100_print_var.polyhedra.txt b/tests/results/0100_print_var.polyhedra.txt new file mode 100644 index 0000000..a0e67dd --- /dev/null +++ b/tests/results/0100_print_var.polyhedra.txt @@ -0,0 +1,2 @@ +sources/0100_print_var.c:2.0-9: [|x-2=0|] +Output: [|x-2=0|] diff --git a/tests/results/0101_print_2var.constants.txt b/tests/results/0101_print_2var.constants.txt new file mode 100644 index 0000000..3a18b6c --- /dev/null +++ b/tests/results/0101_print_2var.constants.txt @@ -0,0 +1,2 @@ +sources/0101_print_2var.c:3.0-9: [ y in {15} ] +Output: [ x in {3}, y in {15} ] diff --git a/tests/results/0101_print_2var.intervals.txt b/tests/results/0101_print_2var.intervals.txt new file mode 100644 index 0000000..3a748f7 --- /dev/null +++ b/tests/results/0101_print_2var.intervals.txt @@ -0,0 +1,2 @@ +sources/0101_print_2var.c:3.0-9: [ y in [15;15] ] +Output: [ x in [3;3], y in [15;15] ] diff --git a/tests/results/0101_print_2var.polyhedra.txt b/tests/results/0101_print_2var.polyhedra.txt new file mode 100644 index 0000000..8d5d333 --- /dev/null +++ b/tests/results/0101_print_2var.polyhedra.txt @@ -0,0 +1,2 @@ +sources/0101_print_2var.c:3.0-9: [|y-15=0|] +Output: [|y-15=0; x-3=0|] diff --git a/tests/results/0102_print_3var.constants.txt b/tests/results/0102_print_3var.constants.txt new file mode 100644 index 0000000..46882af --- /dev/null +++ b/tests/results/0102_print_3var.constants.txt @@ -0,0 +1,2 @@ +sources/0102_print_3var.c:4.0-11: [ z in {99}, x in {3} ] +Output: [ x in {3}, y in {15}, z in {99} ] diff --git a/tests/results/0102_print_3var.intervals.txt b/tests/results/0102_print_3var.intervals.txt new file mode 100644 index 0000000..1ec6fc8 --- /dev/null +++ b/tests/results/0102_print_3var.intervals.txt @@ -0,0 +1,2 @@ +sources/0102_print_3var.c:4.0-11: [ z in [99;99], x in [3;3] ] +Output: [ x in [3;3], y in [15;15], z in [99;99] ] diff --git a/tests/results/0102_print_3var.polyhedra.txt b/tests/results/0102_print_3var.polyhedra.txt new file mode 100644 index 0000000..c7ec366 --- /dev/null +++ b/tests/results/0102_print_3var.polyhedra.txt @@ -0,0 +1,2 @@ +sources/0102_print_3var.c:4.0-11: [|z-99=0; x-3=0|] +Output: [|z-99=0; y-15=0; x-3=0|] diff --git a/tests/results/0103_local.constants.txt b/tests/results/0103_local.constants.txt new file mode 100644 index 0000000..5383bb9 --- /dev/null +++ b/tests/results/0103_local.constants.txt @@ -0,0 +1,2 @@ +sources/0103_local.c:4.2-5.0: [ x in {12}, y in {9} ] +Output: [ x in {12} ] diff --git a/tests/results/0103_local.intervals.txt b/tests/results/0103_local.intervals.txt new file mode 100644 index 0000000..360baa1 --- /dev/null +++ b/tests/results/0103_local.intervals.txt @@ -0,0 +1,2 @@ +sources/0103_local.c:4.2-5.0: [ x in [12;12], y in [9;9] ] +Output: [ x in [12;12] ] diff --git a/tests/results/0103_local.polyhedra.txt b/tests/results/0103_local.polyhedra.txt new file mode 100644 index 0000000..7a39013 --- /dev/null +++ b/tests/results/0103_local.polyhedra.txt @@ -0,0 +1,2 @@ +sources/0103_local.c:4.2-5.0: [|y-9=0; x-12=0|] +Output: [|x-12=0|] diff --git a/tests/results/0200_assign_cst.constants.txt b/tests/results/0200_assign_cst.constants.txt new file mode 100644 index 0000000..479ad69 --- /dev/null +++ b/tests/results/0200_assign_cst.constants.txt @@ -0,0 +1,4 @@ +sources/0200_assign_cst.c:2.0-9: [ x in top ] +sources/0200_assign_cst.c:4.0-9: [ x in {12} ] +sources/0200_assign_cst.c:6.0-9: [ x in {15} ] +Output: [ x in {15} ] diff --git a/tests/results/0200_assign_cst.intervals.txt b/tests/results/0200_assign_cst.intervals.txt new file mode 100644 index 0000000..ed4ccb7 --- /dev/null +++ b/tests/results/0200_assign_cst.intervals.txt @@ -0,0 +1,4 @@ +sources/0200_assign_cst.c:2.0-9: [ x in [-oo;+oo] ] +sources/0200_assign_cst.c:4.0-9: [ x in [12;12] ] +sources/0200_assign_cst.c:6.0-9: [ x in [15;15] ] +Output: [ x in [15;15] ] diff --git a/tests/results/0200_assign_cst.polyhedra.txt b/tests/results/0200_assign_cst.polyhedra.txt new file mode 100644 index 0000000..1761595 --- /dev/null +++ b/tests/results/0200_assign_cst.polyhedra.txt @@ -0,0 +1,4 @@ +sources/0200_assign_cst.c:2.0-9: top +sources/0200_assign_cst.c:4.0-9: [|x-12=0|] +sources/0200_assign_cst.c:6.0-9: [|x-15=0|] +Output: [|x-15=0|] diff --git a/tests/results/0201_assign_cst2.constants.txt b/tests/results/0201_assign_cst2.constants.txt new file mode 100644 index 0000000..bf39084 --- /dev/null +++ b/tests/results/0201_assign_cst2.constants.txt @@ -0,0 +1,4 @@ +sources/0201_assign_cst2.c:2.0-11: [ x in top, y in top ] +sources/0201_assign_cst2.c:4.0-11: [ x in {12}, y in top ] +sources/0201_assign_cst2.c:7.0-11: [ x in {99}, y in {15} ] +Output: [ x in {99}, y in {15} ] diff --git a/tests/results/0201_assign_cst2.intervals.txt b/tests/results/0201_assign_cst2.intervals.txt new file mode 100644 index 0000000..5c3c77e --- /dev/null +++ b/tests/results/0201_assign_cst2.intervals.txt @@ -0,0 +1,4 @@ +sources/0201_assign_cst2.c:2.0-11: [ x in [-oo;+oo], y in [-oo;+oo] ] +sources/0201_assign_cst2.c:4.0-11: [ x in [12;12], y in [-oo;+oo] ] +sources/0201_assign_cst2.c:7.0-11: [ x in [99;99], y in [15;15] ] +Output: [ x in [99;99], y in [15;15] ] diff --git a/tests/results/0201_assign_cst2.polyhedra.txt b/tests/results/0201_assign_cst2.polyhedra.txt new file mode 100644 index 0000000..59df732 --- /dev/null +++ b/tests/results/0201_assign_cst2.polyhedra.txt @@ -0,0 +1,4 @@ +sources/0201_assign_cst2.c:2.0-11: top +sources/0201_assign_cst2.c:4.0-11: [|x-12=0|] +sources/0201_assign_cst2.c:7.0-11: [|y-15=0; x-99=0|] +Output: [|y-15=0; x-99=0|] diff --git a/tests/results/0202_assign_expr.constants.txt b/tests/results/0202_assign_expr.constants.txt new file mode 100644 index 0000000..c9ec364 --- /dev/null +++ b/tests/results/0202_assign_expr.constants.txt @@ -0,0 +1 @@ +Output: [ x in {4} ] diff --git a/tests/results/0202_assign_expr.intervals.txt b/tests/results/0202_assign_expr.intervals.txt new file mode 100644 index 0000000..da16d45 --- /dev/null +++ b/tests/results/0202_assign_expr.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [4;4] ] diff --git a/tests/results/0202_assign_expr.polyhedra.txt b/tests/results/0202_assign_expr.polyhedra.txt new file mode 100644 index 0000000..d9a3c72 --- /dev/null +++ b/tests/results/0202_assign_expr.polyhedra.txt @@ -0,0 +1 @@ +Output: [|x-4=0|] diff --git a/tests/results/0203_assign_expr2.constants.txt b/tests/results/0203_assign_expr2.constants.txt new file mode 100644 index 0000000..5bb2601 --- /dev/null +++ b/tests/results/0203_assign_expr2.constants.txt @@ -0,0 +1,2 @@ +sources/0203_assign_expr2.c:5.0-9: [ x in {30} ] +Output: [ x in {30}, y in {16} ] diff --git a/tests/results/0203_assign_expr2.intervals.txt b/tests/results/0203_assign_expr2.intervals.txt new file mode 100644 index 0000000..26e14b0 --- /dev/null +++ b/tests/results/0203_assign_expr2.intervals.txt @@ -0,0 +1,2 @@ +sources/0203_assign_expr2.c:5.0-9: [ x in [30;30] ] +Output: [ x in [30;30], y in [16;16] ] diff --git a/tests/results/0203_assign_expr2.polyhedra.txt b/tests/results/0203_assign_expr2.polyhedra.txt new file mode 100644 index 0000000..089a14e --- /dev/null +++ b/tests/results/0203_assign_expr2.polyhedra.txt @@ -0,0 +1,2 @@ +sources/0203_assign_expr2.c:5.0-9: [|x-30=0|] +Output: [|y-16=0; x-30=0|] diff --git a/tests/results/0204_assign_rand.constants.txt b/tests/results/0204_assign_rand.constants.txt new file mode 100644 index 0000000..79463fd --- /dev/null +++ b/tests/results/0204_assign_rand.constants.txt @@ -0,0 +1,2 @@ +sources/0204_assign_rand.c:3.0-9: [ x in top ] +Output: [ x in top ] diff --git a/tests/results/0204_assign_rand.intervals.txt b/tests/results/0204_assign_rand.intervals.txt new file mode 100644 index 0000000..6ff24c2 --- /dev/null +++ b/tests/results/0204_assign_rand.intervals.txt @@ -0,0 +1,2 @@ +sources/0204_assign_rand.c:3.0-9: [ x in [1;99] ] +Output: [ x in [1;99] ] diff --git a/tests/results/0204_assign_rand.polyhedra.txt b/tests/results/0204_assign_rand.polyhedra.txt new file mode 100644 index 0000000..b32fd5e --- /dev/null +++ b/tests/results/0204_assign_rand.polyhedra.txt @@ -0,0 +1,2 @@ +sources/0204_assign_rand.c:3.0-9: [|-x+99>=0; x-1>=0|] +Output: [|-x+99>=0; x-1>=0|] diff --git a/tests/results/0205_assign_rand2.constants.txt b/tests/results/0205_assign_rand2.constants.txt new file mode 100644 index 0000000..d907e00 --- /dev/null +++ b/tests/results/0205_assign_rand2.constants.txt @@ -0,0 +1,2 @@ +sources/0205_assign_rand2.c:3.0-9: bottom +Output: bottom diff --git a/tests/results/0205_assign_rand2.intervals.txt b/tests/results/0205_assign_rand2.intervals.txt new file mode 100644 index 0000000..d907e00 --- /dev/null +++ b/tests/results/0205_assign_rand2.intervals.txt @@ -0,0 +1,2 @@ +sources/0205_assign_rand2.c:3.0-9: bottom +Output: bottom diff --git a/tests/results/0205_assign_rand2.polyhedra.txt b/tests/results/0205_assign_rand2.polyhedra.txt new file mode 100644 index 0000000..d907e00 --- /dev/null +++ b/tests/results/0205_assign_rand2.polyhedra.txt @@ -0,0 +1,2 @@ +sources/0205_assign_rand2.c:3.0-9: bottom +Output: bottom diff --git a/tests/results/0206_assign_add.constants.txt b/tests/results/0206_assign_add.constants.txt new file mode 100644 index 0000000..f03759a --- /dev/null +++ b/tests/results/0206_assign_add.constants.txt @@ -0,0 +1 @@ +Output: [ x in {7} ] diff --git a/tests/results/0206_assign_add.intervals.txt b/tests/results/0206_assign_add.intervals.txt new file mode 100644 index 0000000..09adbb5 --- /dev/null +++ b/tests/results/0206_assign_add.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [7;7] ] diff --git a/tests/results/0206_assign_add.polyhedra.txt b/tests/results/0206_assign_add.polyhedra.txt new file mode 100644 index 0000000..532172f --- /dev/null +++ b/tests/results/0206_assign_add.polyhedra.txt @@ -0,0 +1 @@ +Output: [|x-7=0|] diff --git a/tests/results/0207_assign_add2.constants.txt b/tests/results/0207_assign_add2.constants.txt new file mode 100644 index 0000000..1e125b7 --- /dev/null +++ b/tests/results/0207_assign_add2.constants.txt @@ -0,0 +1 @@ +Output: [ x in top ] diff --git a/tests/results/0207_assign_add2.intervals.txt b/tests/results/0207_assign_add2.intervals.txt new file mode 100644 index 0000000..8b42f78 --- /dev/null +++ b/tests/results/0207_assign_add2.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [11;15] ] diff --git a/tests/results/0207_assign_add2.polyhedra.txt b/tests/results/0207_assign_add2.polyhedra.txt new file mode 100644 index 0000000..9ea10ba --- /dev/null +++ b/tests/results/0207_assign_add2.polyhedra.txt @@ -0,0 +1 @@ +Output: [|-x+15>=0; x-11>=0|] diff --git a/tests/results/0208_assign_add3.constants.txt b/tests/results/0208_assign_add3.constants.txt new file mode 100644 index 0000000..1e125b7 --- /dev/null +++ b/tests/results/0208_assign_add3.constants.txt @@ -0,0 +1 @@ +Output: [ x in top ] diff --git a/tests/results/0208_assign_add3.intervals.txt b/tests/results/0208_assign_add3.intervals.txt new file mode 100644 index 0000000..eda51d2 --- /dev/null +++ b/tests/results/0208_assign_add3.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [-oo;+oo] ] diff --git a/tests/results/0208_assign_add3.polyhedra.txt b/tests/results/0208_assign_add3.polyhedra.txt new file mode 100644 index 0000000..f62b6cf --- /dev/null +++ b/tests/results/0208_assign_add3.polyhedra.txt @@ -0,0 +1 @@ +Output: top diff --git a/tests/results/0209_assign_neg.constants.txt b/tests/results/0209_assign_neg.constants.txt new file mode 100644 index 0000000..0f5f195 --- /dev/null +++ b/tests/results/0209_assign_neg.constants.txt @@ -0,0 +1 @@ +Output: [ x in {-9} ] diff --git a/tests/results/0209_assign_neg.intervals.txt b/tests/results/0209_assign_neg.intervals.txt new file mode 100644 index 0000000..0fd9c55 --- /dev/null +++ b/tests/results/0209_assign_neg.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [-9;-9] ] diff --git a/tests/results/0209_assign_neg.polyhedra.txt b/tests/results/0209_assign_neg.polyhedra.txt new file mode 100644 index 0000000..6781630 --- /dev/null +++ b/tests/results/0209_assign_neg.polyhedra.txt @@ -0,0 +1 @@ +Output: [|x+9=0|] diff --git a/tests/results/0210_assign_neg2.constants.txt b/tests/results/0210_assign_neg2.constants.txt new file mode 100644 index 0000000..1e125b7 --- /dev/null +++ b/tests/results/0210_assign_neg2.constants.txt @@ -0,0 +1 @@ +Output: [ x in top ] diff --git a/tests/results/0210_assign_neg2.intervals.txt b/tests/results/0210_assign_neg2.intervals.txt new file mode 100644 index 0000000..73d88cf --- /dev/null +++ b/tests/results/0210_assign_neg2.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [-10;1] ] diff --git a/tests/results/0210_assign_neg2.polyhedra.txt b/tests/results/0210_assign_neg2.polyhedra.txt new file mode 100644 index 0000000..072f308 --- /dev/null +++ b/tests/results/0210_assign_neg2.polyhedra.txt @@ -0,0 +1 @@ +Output: [|-x+1>=0; x+10>=0|] diff --git a/tests/results/0211_assign_sub.constants.txt b/tests/results/0211_assign_sub.constants.txt new file mode 100644 index 0000000..081af4c --- /dev/null +++ b/tests/results/0211_assign_sub.constants.txt @@ -0,0 +1 @@ +Output: [ x in {998} ] diff --git a/tests/results/0211_assign_sub.intervals.txt b/tests/results/0211_assign_sub.intervals.txt new file mode 100644 index 0000000..399e33f --- /dev/null +++ b/tests/results/0211_assign_sub.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [998;998] ] diff --git a/tests/results/0211_assign_sub.polyhedra.txt b/tests/results/0211_assign_sub.polyhedra.txt new file mode 100644 index 0000000..c769276 --- /dev/null +++ b/tests/results/0211_assign_sub.polyhedra.txt @@ -0,0 +1 @@ +Output: [|x-998=0|] diff --git a/tests/results/0212_assign_sub2.constants.txt b/tests/results/0212_assign_sub2.constants.txt new file mode 100644 index 0000000..1e125b7 --- /dev/null +++ b/tests/results/0212_assign_sub2.constants.txt @@ -0,0 +1 @@ +Output: [ x in top ] diff --git a/tests/results/0212_assign_sub2.intervals.txt b/tests/results/0212_assign_sub2.intervals.txt new file mode 100644 index 0000000..7280868 --- /dev/null +++ b/tests/results/0212_assign_sub2.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [-2;8] ] diff --git a/tests/results/0212_assign_sub2.polyhedra.txt b/tests/results/0212_assign_sub2.polyhedra.txt new file mode 100644 index 0000000..677491d --- /dev/null +++ b/tests/results/0212_assign_sub2.polyhedra.txt @@ -0,0 +1 @@ +Output: [|-x+8>=0; x+2>=0|] diff --git a/tests/results/0213_assign_mul.constants.txt b/tests/results/0213_assign_mul.constants.txt new file mode 100644 index 0000000..a96ffa9 --- /dev/null +++ b/tests/results/0213_assign_mul.constants.txt @@ -0,0 +1 @@ +Output: [ x in {40} ] diff --git a/tests/results/0213_assign_mul.intervals.txt b/tests/results/0213_assign_mul.intervals.txt new file mode 100644 index 0000000..c4b8532 --- /dev/null +++ b/tests/results/0213_assign_mul.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [40;40] ] diff --git a/tests/results/0213_assign_mul.polyhedra.txt b/tests/results/0213_assign_mul.polyhedra.txt new file mode 100644 index 0000000..c6ed2d5 --- /dev/null +++ b/tests/results/0213_assign_mul.polyhedra.txt @@ -0,0 +1 @@ +Output: [|x-40=0|] diff --git a/tests/results/0214_assign_mul2.constants.txt b/tests/results/0214_assign_mul2.constants.txt new file mode 100644 index 0000000..1e125b7 --- /dev/null +++ b/tests/results/0214_assign_mul2.constants.txt @@ -0,0 +1 @@ +Output: [ x in top ] diff --git a/tests/results/0214_assign_mul2.intervals.txt b/tests/results/0214_assign_mul2.intervals.txt new file mode 100644 index 0000000..73894e9 --- /dev/null +++ b/tests/results/0214_assign_mul2.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [2;27] ] diff --git a/tests/results/0214_assign_mul2.polyhedra.txt b/tests/results/0214_assign_mul2.polyhedra.txt new file mode 100644 index 0000000..8994ea9 --- /dev/null +++ b/tests/results/0214_assign_mul2.polyhedra.txt @@ -0,0 +1 @@ +Output: [|-x+27>=0; x-2>=0|] diff --git a/tests/results/0215_assign_mul3.constants.txt b/tests/results/0215_assign_mul3.constants.txt new file mode 100644 index 0000000..1e125b7 --- /dev/null +++ b/tests/results/0215_assign_mul3.constants.txt @@ -0,0 +1 @@ +Output: [ x in top ] diff --git a/tests/results/0215_assign_mul3.intervals.txt b/tests/results/0215_assign_mul3.intervals.txt new file mode 100644 index 0000000..ed9922e --- /dev/null +++ b/tests/results/0215_assign_mul3.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [-50;30] ] diff --git a/tests/results/0215_assign_mul3.polyhedra.txt b/tests/results/0215_assign_mul3.polyhedra.txt new file mode 100644 index 0000000..245e58b --- /dev/null +++ b/tests/results/0215_assign_mul3.polyhedra.txt @@ -0,0 +1 @@ +Output: [|-x+30>=0; x+50>=0|] diff --git a/tests/results/0216_assign_mul4.constants.txt b/tests/results/0216_assign_mul4.constants.txt new file mode 100644 index 0000000..6423d75 --- /dev/null +++ b/tests/results/0216_assign_mul4.constants.txt @@ -0,0 +1 @@ +Output: [ x in {0} ] diff --git a/tests/results/0216_assign_mul4.intervals.txt b/tests/results/0216_assign_mul4.intervals.txt new file mode 100644 index 0000000..9fe0945 --- /dev/null +++ b/tests/results/0216_assign_mul4.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [0;0] ] diff --git a/tests/results/0216_assign_mul4.polyhedra.txt b/tests/results/0216_assign_mul4.polyhedra.txt new file mode 100644 index 0000000..072e333 --- /dev/null +++ b/tests/results/0216_assign_mul4.polyhedra.txt @@ -0,0 +1 @@ +Output: [|x=0|] diff --git a/tests/results/0217_assign_copy.constants.txt b/tests/results/0217_assign_copy.constants.txt new file mode 100644 index 0000000..48ead4c --- /dev/null +++ b/tests/results/0217_assign_copy.constants.txt @@ -0,0 +1,2 @@ +sources/0217_assign_copy.c:5.0-9: [ y in {12} ] +Output: [ x in {12}, y in {12} ] diff --git a/tests/results/0217_assign_copy.intervals.txt b/tests/results/0217_assign_copy.intervals.txt new file mode 100644 index 0000000..deede7b --- /dev/null +++ b/tests/results/0217_assign_copy.intervals.txt @@ -0,0 +1,2 @@ +sources/0217_assign_copy.c:5.0-9: [ y in [12;12] ] +Output: [ x in [12;12], y in [12;12] ] diff --git a/tests/results/0217_assign_copy.polyhedra.txt b/tests/results/0217_assign_copy.polyhedra.txt new file mode 100644 index 0000000..2390288 --- /dev/null +++ b/tests/results/0217_assign_copy.polyhedra.txt @@ -0,0 +1,2 @@ +sources/0217_assign_copy.c:5.0-9: [|y-12=0|] +Output: [|y-12=0; x-12=0|] diff --git a/tests/results/0218_assign_rel.constants.txt b/tests/results/0218_assign_rel.constants.txt new file mode 100644 index 0000000..33b1a1f --- /dev/null +++ b/tests/results/0218_assign_rel.constants.txt @@ -0,0 +1,2 @@ +sources/0218_assign_rel.c:5.0-9: [ y in {17} ] +Output: [ x in {15}, y in {17} ] diff --git a/tests/results/0218_assign_rel.intervals.txt b/tests/results/0218_assign_rel.intervals.txt new file mode 100644 index 0000000..3972546 --- /dev/null +++ b/tests/results/0218_assign_rel.intervals.txt @@ -0,0 +1,2 @@ +sources/0218_assign_rel.c:5.0-9: [ y in [17;17] ] +Output: [ x in [15;15], y in [17;17] ] diff --git a/tests/results/0218_assign_rel.polyhedra.txt b/tests/results/0218_assign_rel.polyhedra.txt new file mode 100644 index 0000000..4a1f8dd --- /dev/null +++ b/tests/results/0218_assign_rel.polyhedra.txt @@ -0,0 +1,2 @@ +sources/0218_assign_rel.c:5.0-9: [|y-17=0|] +Output: [|y-17=0; x-15=0|] diff --git a/tests/results/0219_assign_rel2.constants.txt b/tests/results/0219_assign_rel2.constants.txt new file mode 100644 index 0000000..8204d04 --- /dev/null +++ b/tests/results/0219_assign_rel2.constants.txt @@ -0,0 +1 @@ +Output: [ x in top, y in top, z in top ] diff --git a/tests/results/0219_assign_rel2.intervals.txt b/tests/results/0219_assign_rel2.intervals.txt new file mode 100644 index 0000000..6225596 --- /dev/null +++ b/tests/results/0219_assign_rel2.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [1;5], y in [2;10], z in [5;25] ] diff --git a/tests/results/0219_assign_rel2.polyhedra.txt b/tests/results/0219_assign_rel2.polyhedra.txt new file mode 100644 index 0000000..08949e1 --- /dev/null +++ b/tests/results/0219_assign_rel2.polyhedra.txt @@ -0,0 +1 @@ +Output: [|-x-2y+z=0; -x+5>=0; -y+10>=0; y-2>=0; x-1>=0|] diff --git a/tests/results/0300_if_true.constants.txt b/tests/results/0300_if_true.constants.txt new file mode 100644 index 0000000..d462831 --- /dev/null +++ b/tests/results/0300_if_true.constants.txt @@ -0,0 +1 @@ +Output: [ x in {9} ] diff --git a/tests/results/0300_if_true.intervals.txt b/tests/results/0300_if_true.intervals.txt new file mode 100644 index 0000000..0c6f646 --- /dev/null +++ b/tests/results/0300_if_true.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [9;9] ] diff --git a/tests/results/0300_if_true.polyhedra.txt b/tests/results/0300_if_true.polyhedra.txt new file mode 100644 index 0000000..90a38c5 --- /dev/null +++ b/tests/results/0300_if_true.polyhedra.txt @@ -0,0 +1 @@ +Output: [|x-9=0|] diff --git a/tests/results/0301_if_false.constants.txt b/tests/results/0301_if_false.constants.txt new file mode 100644 index 0000000..ebf94f0 --- /dev/null +++ b/tests/results/0301_if_false.constants.txt @@ -0,0 +1 @@ +Output: [ x in {1} ] diff --git a/tests/results/0301_if_false.intervals.txt b/tests/results/0301_if_false.intervals.txt new file mode 100644 index 0000000..725d6cd --- /dev/null +++ b/tests/results/0301_if_false.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [1;1] ] diff --git a/tests/results/0301_if_false.polyhedra.txt b/tests/results/0301_if_false.polyhedra.txt new file mode 100644 index 0000000..ea9534b --- /dev/null +++ b/tests/results/0301_if_false.polyhedra.txt @@ -0,0 +1 @@ +Output: [|x-1=0|] diff --git a/tests/results/0302_if_both.constants.txt b/tests/results/0302_if_both.constants.txt new file mode 100644 index 0000000..1e125b7 --- /dev/null +++ b/tests/results/0302_if_both.constants.txt @@ -0,0 +1 @@ +Output: [ x in top ] diff --git a/tests/results/0302_if_both.intervals.txt b/tests/results/0302_if_both.intervals.txt new file mode 100644 index 0000000..325829f --- /dev/null +++ b/tests/results/0302_if_both.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [1;9] ] diff --git a/tests/results/0302_if_both.polyhedra.txt b/tests/results/0302_if_both.polyhedra.txt new file mode 100644 index 0000000..f9f53a2 --- /dev/null +++ b/tests/results/0302_if_both.polyhedra.txt @@ -0,0 +1 @@ +Output: [|-x+9>=0; x-1>=0|] diff --git a/tests/results/0303_if_else_true.constants.txt b/tests/results/0303_if_else_true.constants.txt new file mode 100644 index 0000000..a5cfc34 --- /dev/null +++ b/tests/results/0303_if_else_true.constants.txt @@ -0,0 +1 @@ +Output: [ x in {5} ] diff --git a/tests/results/0303_if_else_true.intervals.txt b/tests/results/0303_if_else_true.intervals.txt new file mode 100644 index 0000000..215f0dd --- /dev/null +++ b/tests/results/0303_if_else_true.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [5;5] ] diff --git a/tests/results/0303_if_else_true.polyhedra.txt b/tests/results/0303_if_else_true.polyhedra.txt new file mode 100644 index 0000000..257804b --- /dev/null +++ b/tests/results/0303_if_else_true.polyhedra.txt @@ -0,0 +1 @@ +Output: [|x-5=0|] diff --git a/tests/results/0304_if_else_false.constants.txt b/tests/results/0304_if_else_false.constants.txt new file mode 100644 index 0000000..8bda3f6 --- /dev/null +++ b/tests/results/0304_if_else_false.constants.txt @@ -0,0 +1 @@ +Output: [ x in {10} ] diff --git a/tests/results/0304_if_else_false.intervals.txt b/tests/results/0304_if_else_false.intervals.txt new file mode 100644 index 0000000..fc10743 --- /dev/null +++ b/tests/results/0304_if_else_false.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [10;10] ] diff --git a/tests/results/0304_if_else_false.polyhedra.txt b/tests/results/0304_if_else_false.polyhedra.txt new file mode 100644 index 0000000..4824605 --- /dev/null +++ b/tests/results/0304_if_else_false.polyhedra.txt @@ -0,0 +1 @@ +Output: [|x-10=0|] diff --git a/tests/results/0305_if_else_both.constants.txt b/tests/results/0305_if_else_both.constants.txt new file mode 100644 index 0000000..1e125b7 --- /dev/null +++ b/tests/results/0305_if_else_both.constants.txt @@ -0,0 +1 @@ +Output: [ x in top ] diff --git a/tests/results/0305_if_else_both.intervals.txt b/tests/results/0305_if_else_both.intervals.txt new file mode 100644 index 0000000..5094331 --- /dev/null +++ b/tests/results/0305_if_else_both.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [5;10] ] diff --git a/tests/results/0305_if_else_both.polyhedra.txt b/tests/results/0305_if_else_both.polyhedra.txt new file mode 100644 index 0000000..5cee0c4 --- /dev/null +++ b/tests/results/0305_if_else_both.polyhedra.txt @@ -0,0 +1 @@ +Output: [|-x+10>=0; x-5>=0|] diff --git a/tests/results/0306_if_rel.constants.txt b/tests/results/0306_if_rel.constants.txt new file mode 100644 index 0000000..b7ada66 --- /dev/null +++ b/tests/results/0306_if_rel.constants.txt @@ -0,0 +1 @@ +Output: [ x in top, y in top ] diff --git a/tests/results/0306_if_rel.intervals.txt b/tests/results/0306_if_rel.intervals.txt new file mode 100644 index 0000000..720b91a --- /dev/null +++ b/tests/results/0306_if_rel.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [1;2], y in [1;3] ] diff --git a/tests/results/0306_if_rel.polyhedra.txt b/tests/results/0306_if_rel.polyhedra.txt new file mode 100644 index 0000000..d98e52e --- /dev/null +++ b/tests/results/0306_if_rel.polyhedra.txt @@ -0,0 +1 @@ +Output: [|2x+y-5=0; -x+2>=0; x-1>=0|] diff --git a/tests/results/0307_if_var.constants.txt b/tests/results/0307_if_var.constants.txt new file mode 100644 index 0000000..d30fa5d --- /dev/null +++ b/tests/results/0307_if_var.constants.txt @@ -0,0 +1,3 @@ +sources/0307_if_var.c:2.14-24: [ x in top ] +sources/0307_if_var.c:3.7-17: [ x in top ] +Output: [ x in top ] diff --git a/tests/results/0307_if_var.intervals.txt b/tests/results/0307_if_var.intervals.txt new file mode 100644 index 0000000..2290fb8 --- /dev/null +++ b/tests/results/0307_if_var.intervals.txt @@ -0,0 +1,3 @@ +sources/0307_if_var.c:2.14-24: [ x in [0;20] ] +sources/0307_if_var.c:3.7-17: [ x in [-10;-1] ] +Output: [ x in [-10;20] ] diff --git a/tests/results/0307_if_var.polyhedra.txt b/tests/results/0307_if_var.polyhedra.txt new file mode 100644 index 0000000..c9e0e7a --- /dev/null +++ b/tests/results/0307_if_var.polyhedra.txt @@ -0,0 +1,3 @@ +sources/0307_if_var.c:2.14-24: [|-x+20>=0; x>=0|] +sources/0307_if_var.c:3.7-17: [|-x-1>=0; x+10>=0|] +Output: [|-x+20>=0; x+10>=0|] diff --git a/tests/results/0308_if_var2.constants.txt b/tests/results/0308_if_var2.constants.txt new file mode 100644 index 0000000..1e125b7 --- /dev/null +++ b/tests/results/0308_if_var2.constants.txt @@ -0,0 +1 @@ +Output: [ x in top ] diff --git a/tests/results/0308_if_var2.intervals.txt b/tests/results/0308_if_var2.intervals.txt new file mode 100644 index 0000000..534d2d3 --- /dev/null +++ b/tests/results/0308_if_var2.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [-1;20] ] diff --git a/tests/results/0308_if_var2.polyhedra.txt b/tests/results/0308_if_var2.polyhedra.txt new file mode 100644 index 0000000..3378d1d --- /dev/null +++ b/tests/results/0308_if_var2.polyhedra.txt @@ -0,0 +1 @@ +Output: [|-x+20>=0; x+1>=0|] diff --git a/tests/results/0309_if_var_rel.constants.txt b/tests/results/0309_if_var_rel.constants.txt new file mode 100644 index 0000000..b7ada66 --- /dev/null +++ b/tests/results/0309_if_var_rel.constants.txt @@ -0,0 +1 @@ +Output: [ x in top, y in top ] diff --git a/tests/results/0309_if_var_rel.intervals.txt b/tests/results/0309_if_var_rel.intervals.txt new file mode 100644 index 0000000..a61ddd6 --- /dev/null +++ b/tests/results/0309_if_var_rel.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [-15;20], y in [-15;20] ] diff --git a/tests/results/0309_if_var_rel.polyhedra.txt b/tests/results/0309_if_var_rel.polyhedra.txt new file mode 100644 index 0000000..c11732e --- /dev/null +++ b/tests/results/0309_if_var_rel.polyhedra.txt @@ -0,0 +1 @@ +Output: [|-x+y>=0; -y+20>=0; 7x-y+90>=0|] diff --git a/tests/results/0310_cmp_le.constants.txt b/tests/results/0310_cmp_le.constants.txt new file mode 100644 index 0000000..b88d9db --- /dev/null +++ b/tests/results/0310_cmp_le.constants.txt @@ -0,0 +1,2 @@ +sources/0310_cmp_le.c:3.11-23: [ x in top, y in top ] +Output: [ x in top, y in top ] diff --git a/tests/results/0310_cmp_le.intervals.txt b/tests/results/0310_cmp_le.intervals.txt new file mode 100644 index 0000000..186a3c3 --- /dev/null +++ b/tests/results/0310_cmp_le.intervals.txt @@ -0,0 +1,2 @@ +sources/0310_cmp_le.c:3.11-23: [ x in [10;20], y in [15;30] ] +Output: [ x in [10;20], y in [15;30] ] diff --git a/tests/results/0310_cmp_le.polyhedra.txt b/tests/results/0310_cmp_le.polyhedra.txt new file mode 100644 index 0000000..d7bcb41 --- /dev/null +++ b/tests/results/0310_cmp_le.polyhedra.txt @@ -0,0 +1,3 @@ +sources/0310_cmp_le.c:3.11-23: [|-x+20>=0; -x+y>=0; -y+30>=0; y-15>=0; + x-10>=0|] +Output: [|-x+20>=0; -y+30>=0; y-15>=0; x-10>=0|] diff --git a/tests/results/0311_cmp_le2.constants.txt b/tests/results/0311_cmp_le2.constants.txt new file mode 100644 index 0000000..6a9db98 --- /dev/null +++ b/tests/results/0311_cmp_le2.constants.txt @@ -0,0 +1,2 @@ +sources/0311_cmp_le2.c:3.11-23: [ x in top, y in top ] +Output: [ x in top, y in top ] diff --git a/tests/results/0311_cmp_le2.intervals.txt b/tests/results/0311_cmp_le2.intervals.txt new file mode 100644 index 0000000..1c2ca5a --- /dev/null +++ b/tests/results/0311_cmp_le2.intervals.txt @@ -0,0 +1,2 @@ +sources/0311_cmp_le2.c:3.11-23: [ x in [10;17], y in [10;17] ] +Output: [ x in [10;20], y in [8;17] ] diff --git a/tests/results/0311_cmp_le2.polyhedra.txt b/tests/results/0311_cmp_le2.polyhedra.txt new file mode 100644 index 0000000..6fc97d1 --- /dev/null +++ b/tests/results/0311_cmp_le2.polyhedra.txt @@ -0,0 +1,2 @@ +sources/0311_cmp_le2.c:3.11-23: [|-x+y>=0; -y+17>=0; x-10>=0|] +Output: [|-x+20>=0; -y+17>=0; y-8>=0; x-10>=0|] diff --git a/tests/results/0312_cmp_le3.constants.txt b/tests/results/0312_cmp_le3.constants.txt new file mode 100644 index 0000000..748bd4b --- /dev/null +++ b/tests/results/0312_cmp_le3.constants.txt @@ -0,0 +1,2 @@ +sources/0312_cmp_le3.c:3.11-21: [ x in top ] +Output: [ x in top, y in top ] diff --git a/tests/results/0312_cmp_le3.intervals.txt b/tests/results/0312_cmp_le3.intervals.txt new file mode 100644 index 0000000..908661c --- /dev/null +++ b/tests/results/0312_cmp_le3.intervals.txt @@ -0,0 +1,2 @@ +sources/0312_cmp_le3.c:3.11-21: bottom +Output: [ x in [30;55], y in [10;20] ] diff --git a/tests/results/0312_cmp_le3.polyhedra.txt b/tests/results/0312_cmp_le3.polyhedra.txt new file mode 100644 index 0000000..32ffc17 --- /dev/null +++ b/tests/results/0312_cmp_le3.polyhedra.txt @@ -0,0 +1,2 @@ +sources/0312_cmp_le3.c:3.11-21: bottom +Output: [|-x+55>=0; -y+20>=0; y-10>=0; x-30>=0|] diff --git a/tests/results/0313_cmp_lt.constants.txt b/tests/results/0313_cmp_lt.constants.txt new file mode 100644 index 0000000..3685d47 --- /dev/null +++ b/tests/results/0313_cmp_lt.constants.txt @@ -0,0 +1,2 @@ +sources/0313_cmp_lt.c:3.10-22: [ x in top, y in top ] +Output: [ x in top, y in top ] diff --git a/tests/results/0313_cmp_lt.intervals.txt b/tests/results/0313_cmp_lt.intervals.txt new file mode 100644 index 0000000..3826912 --- /dev/null +++ b/tests/results/0313_cmp_lt.intervals.txt @@ -0,0 +1,2 @@ +sources/0313_cmp_lt.c:3.10-22: [ x in [10;14], y in [11;15] ] +Output: [ x in [10;20], y in [5;15] ] diff --git a/tests/results/0313_cmp_lt.polyhedra.txt b/tests/results/0313_cmp_lt.polyhedra.txt new file mode 100644 index 0000000..d70d1cc --- /dev/null +++ b/tests/results/0313_cmp_lt.polyhedra.txt @@ -0,0 +1,2 @@ +sources/0313_cmp_lt.c:3.10-22: [|-x+y-1>=0; -y+15>=0; x-10>=0|] +Output: [|-x+20>=0; -y+15>=0; y-5>=0; x-10>=0|] diff --git a/tests/results/0314_cmp_ge.constants.txt b/tests/results/0314_cmp_ge.constants.txt new file mode 100644 index 0000000..7722930 --- /dev/null +++ b/tests/results/0314_cmp_ge.constants.txt @@ -0,0 +1,2 @@ +sources/0314_cmp_ge.c:3.11-23: [ x in top, y in top ] +Output: [ x in top, y in top ] diff --git a/tests/results/0314_cmp_ge.intervals.txt b/tests/results/0314_cmp_ge.intervals.txt new file mode 100644 index 0000000..e49273e --- /dev/null +++ b/tests/results/0314_cmp_ge.intervals.txt @@ -0,0 +1,2 @@ +sources/0314_cmp_ge.c:3.11-23: [ x in [15;20], y in [15;20] ] +Output: [ x in [10;20], y in [15;30] ] diff --git a/tests/results/0314_cmp_ge.polyhedra.txt b/tests/results/0314_cmp_ge.polyhedra.txt new file mode 100644 index 0000000..74534e2 --- /dev/null +++ b/tests/results/0314_cmp_ge.polyhedra.txt @@ -0,0 +1,2 @@ +sources/0314_cmp_ge.c:3.11-23: [|-x+20>=0; y-15>=0; x-y>=0|] +Output: [|-x+20>=0; -y+30>=0; y-15>=0; x-10>=0|] diff --git a/tests/results/0315_cmp_gt.constants.txt b/tests/results/0315_cmp_gt.constants.txt new file mode 100644 index 0000000..8c9b15f --- /dev/null +++ b/tests/results/0315_cmp_gt.constants.txt @@ -0,0 +1,2 @@ +sources/0315_cmp_gt.c:3.10-22: [ x in top, y in top ] +Output: [ x in top, y in top ] diff --git a/tests/results/0315_cmp_gt.intervals.txt b/tests/results/0315_cmp_gt.intervals.txt new file mode 100644 index 0000000..f8b07c0 --- /dev/null +++ b/tests/results/0315_cmp_gt.intervals.txt @@ -0,0 +1,2 @@ +sources/0315_cmp_gt.c:3.10-22: [ x in [16;20], y in [15;19] ] +Output: [ x in [10;20], y in [15;30] ] diff --git a/tests/results/0315_cmp_gt.polyhedra.txt b/tests/results/0315_cmp_gt.polyhedra.txt new file mode 100644 index 0000000..2418ec8 --- /dev/null +++ b/tests/results/0315_cmp_gt.polyhedra.txt @@ -0,0 +1,2 @@ +sources/0315_cmp_gt.c:3.10-22: [|-x+20>=0; y-15>=0; x-y-1>=0|] +Output: [|-x+20>=0; -y+30>=0; y-15>=0; x-10>=0|] diff --git a/tests/results/0316_cmp_eq.constants.txt b/tests/results/0316_cmp_eq.constants.txt new file mode 100644 index 0000000..2cf2cae --- /dev/null +++ b/tests/results/0316_cmp_eq.constants.txt @@ -0,0 +1,2 @@ +sources/0316_cmp_eq.c:3.11-23: [ x in top, y in top ] +Output: [ x in top, y in top ] diff --git a/tests/results/0316_cmp_eq.intervals.txt b/tests/results/0316_cmp_eq.intervals.txt new file mode 100644 index 0000000..46c87c8 --- /dev/null +++ b/tests/results/0316_cmp_eq.intervals.txt @@ -0,0 +1,2 @@ +sources/0316_cmp_eq.c:3.11-23: [ x in [15;20], y in [15;20] ] +Output: [ x in [15;30], y in [10;20] ] diff --git a/tests/results/0316_cmp_eq.polyhedra.txt b/tests/results/0316_cmp_eq.polyhedra.txt new file mode 100644 index 0000000..abf553c --- /dev/null +++ b/tests/results/0316_cmp_eq.polyhedra.txt @@ -0,0 +1,2 @@ +sources/0316_cmp_eq.c:3.11-23: [|-x+y=0; -x+20>=0; x-15>=0|] +Output: [|-x+30>=0; -y+20>=0; y-10>=0; x-15>=0|] diff --git a/tests/results/0317_cmp_eq2.constants.txt b/tests/results/0317_cmp_eq2.constants.txt new file mode 100644 index 0000000..81a43de --- /dev/null +++ b/tests/results/0317_cmp_eq2.constants.txt @@ -0,0 +1,2 @@ +sources/0317_cmp_eq2.c:3.11-23: [ x in top, y in top ] +Output: [ x in top, y in top ] diff --git a/tests/results/0317_cmp_eq2.intervals.txt b/tests/results/0317_cmp_eq2.intervals.txt new file mode 100644 index 0000000..93841ec --- /dev/null +++ b/tests/results/0317_cmp_eq2.intervals.txt @@ -0,0 +1,2 @@ +sources/0317_cmp_eq2.c:3.11-23: bottom +Output: [ x in [15;20], y in [25;30] ] diff --git a/tests/results/0317_cmp_eq2.polyhedra.txt b/tests/results/0317_cmp_eq2.polyhedra.txt new file mode 100644 index 0000000..c6ba540 --- /dev/null +++ b/tests/results/0317_cmp_eq2.polyhedra.txt @@ -0,0 +1,2 @@ +sources/0317_cmp_eq2.c:3.11-23: bottom +Output: [|-x+20>=0; -y+30>=0; y-25>=0; x-15>=0|] diff --git a/tests/results/0318_cmp_ne.constants.txt b/tests/results/0318_cmp_ne.constants.txt new file mode 100644 index 0000000..f95b2e8 --- /dev/null +++ b/tests/results/0318_cmp_ne.constants.txt @@ -0,0 +1,2 @@ +sources/0318_cmp_ne.c:3.11-23: [ x in top, y in top ] +Output: [ x in top, y in top ] diff --git a/tests/results/0318_cmp_ne.intervals.txt b/tests/results/0318_cmp_ne.intervals.txt new file mode 100644 index 0000000..5908089 --- /dev/null +++ b/tests/results/0318_cmp_ne.intervals.txt @@ -0,0 +1,2 @@ +sources/0318_cmp_ne.c:3.11-23: [ x in [10;15], y in [10;15] ] +Output: [ x in [10;15], y in [10;15] ] diff --git a/tests/results/0318_cmp_ne.polyhedra.txt b/tests/results/0318_cmp_ne.polyhedra.txt new file mode 100644 index 0000000..8008082 --- /dev/null +++ b/tests/results/0318_cmp_ne.polyhedra.txt @@ -0,0 +1,3 @@ +sources/0318_cmp_ne.c:3.11-23: [|-x-y+29>=0; -x+15>=0; -y+15>=0; y-10>=0; + x-10>=0; x+y-21>=0|] +Output: [|-x+15>=0; -y+15>=0; y-10>=0; x-10>=0|] diff --git a/tests/results/0319_cmp_ne.constants.txt b/tests/results/0319_cmp_ne.constants.txt new file mode 100644 index 0000000..80005f9 --- /dev/null +++ b/tests/results/0319_cmp_ne.constants.txt @@ -0,0 +1,2 @@ +sources/0319_cmp_ne.c:3.11-23: [ x in top, y in {10} ] +Output: [ x in top, y in {10} ] diff --git a/tests/results/0319_cmp_ne.intervals.txt b/tests/results/0319_cmp_ne.intervals.txt new file mode 100644 index 0000000..cfd42ac --- /dev/null +++ b/tests/results/0319_cmp_ne.intervals.txt @@ -0,0 +1,2 @@ +sources/0319_cmp_ne.c:3.11-23: [ x in [11;15], y in [10;10] ] +Output: [ x in [10;15], y in [10;10] ] diff --git a/tests/results/0319_cmp_ne.polyhedra.txt b/tests/results/0319_cmp_ne.polyhedra.txt new file mode 100644 index 0000000..68272de --- /dev/null +++ b/tests/results/0319_cmp_ne.polyhedra.txt @@ -0,0 +1,2 @@ +sources/0319_cmp_ne.c:3.11-23: [|y-10=0; -x+15>=0; x-11>=0|] +Output: [|y-10=0; -x+15>=0; x-10>=0|] diff --git a/tests/results/0320_cmp_eq_ne.constants.txt b/tests/results/0320_cmp_eq_ne.constants.txt new file mode 100644 index 0000000..d09e55d --- /dev/null +++ b/tests/results/0320_cmp_eq_ne.constants.txt @@ -0,0 +1,3 @@ +sources/0320_cmp_eq_ne.c:3.11-4.0: [ x in {10}, y in {10} ] +sources/0320_cmp_eq_ne.c:4.4-16: [ x in top, y in {10} ] +Output: [ x in top, y in {10} ] diff --git a/tests/results/0320_cmp_eq_ne.intervals.txt b/tests/results/0320_cmp_eq_ne.intervals.txt new file mode 100644 index 0000000..696f4f7 --- /dev/null +++ b/tests/results/0320_cmp_eq_ne.intervals.txt @@ -0,0 +1,3 @@ +sources/0320_cmp_eq_ne.c:3.11-4.0: [ x in [10;10], y in [10;10] ] +sources/0320_cmp_eq_ne.c:4.4-16: [ x in [11;15], y in [10;10] ] +Output: [ x in [10;15], y in [10;10] ] diff --git a/tests/results/0320_cmp_eq_ne.polyhedra.txt b/tests/results/0320_cmp_eq_ne.polyhedra.txt new file mode 100644 index 0000000..82585b7 --- /dev/null +++ b/tests/results/0320_cmp_eq_ne.polyhedra.txt @@ -0,0 +1,3 @@ +sources/0320_cmp_eq_ne.c:3.11-4.0: [|y-10=0; x-10=0|] +sources/0320_cmp_eq_ne.c:4.4-16: [|y-10=0; -x+15>=0; x-11>=0|] +Output: [|y-10=0; -x+15>=0; x-10>=0|] diff --git a/tests/results/0321_cmp_rel.constants.txt b/tests/results/0321_cmp_rel.constants.txt new file mode 100644 index 0000000..8cbd76e --- /dev/null +++ b/tests/results/0321_cmp_rel.constants.txt @@ -0,0 +1,2 @@ +sources/0321_cmp_rel.c:3.15-25: [ y in top ] +Output: [ x in top, y in top ] diff --git a/tests/results/0321_cmp_rel.intervals.txt b/tests/results/0321_cmp_rel.intervals.txt new file mode 100644 index 0000000..0916a62 --- /dev/null +++ b/tests/results/0321_cmp_rel.intervals.txt @@ -0,0 +1,2 @@ +sources/0321_cmp_rel.c:3.15-25: [ y in [10;20] ] +Output: [ x in [10;20], y in [10;20] ] diff --git a/tests/results/0321_cmp_rel.polyhedra.txt b/tests/results/0321_cmp_rel.polyhedra.txt new file mode 100644 index 0000000..7a04a8a --- /dev/null +++ b/tests/results/0321_cmp_rel.polyhedra.txt @@ -0,0 +1,2 @@ +sources/0321_cmp_rel.c:3.15-25: [|-y+20>=0; y-15>=0|] +Output: [|-x+y=0; -x+20>=0; x-10>=0|] diff --git a/tests/results/0322_if_and.constants.txt b/tests/results/0322_if_and.constants.txt new file mode 100644 index 0000000..220ba86 --- /dev/null +++ b/tests/results/0322_if_and.constants.txt @@ -0,0 +1,3 @@ +sources/0322_if_and.c:3.22-34: [ x in top, y in top ] +sources/0322_if_and.c:4.7-19: [ x in top, y in top ] +Output: [ x in top, y in top ] diff --git a/tests/results/0322_if_and.intervals.txt b/tests/results/0322_if_and.intervals.txt new file mode 100644 index 0000000..3decd30 --- /dev/null +++ b/tests/results/0322_if_and.intervals.txt @@ -0,0 +1,3 @@ +sources/0322_if_and.c:3.22-34: [ x in [15;20], y in [35;40] ] +sources/0322_if_and.c:4.7-19: [ x in [10;20], y in [30;40] ] +Output: [ x in [10;20], y in [30;40] ] diff --git a/tests/results/0322_if_and.polyhedra.txt b/tests/results/0322_if_and.polyhedra.txt new file mode 100644 index 0000000..691b7ac --- /dev/null +++ b/tests/results/0322_if_and.polyhedra.txt @@ -0,0 +1,4 @@ +sources/0322_if_and.c:3.22-34: [|-x+20>=0; -y+40>=0; y-35>=0; x-15>=0|] +sources/0322_if_and.c:4.7-19: [|-x-y+54>=0; -x+20>=0; -y+40>=0; y-30>=0; + x-10>=0|] +Output: [|-x+20>=0; -y+40>=0; y-30>=0; x-10>=0|] diff --git a/tests/results/0323_if_or.constants.txt b/tests/results/0323_if_or.constants.txt new file mode 100644 index 0000000..8682e63 --- /dev/null +++ b/tests/results/0323_if_or.constants.txt @@ -0,0 +1,3 @@ +sources/0323_if_or.c:3.22-34: [ x in top, y in top ] +sources/0323_if_or.c:4.7-19: [ x in top, y in top ] +Output: [ x in top, y in top ] diff --git a/tests/results/0323_if_or.intervals.txt b/tests/results/0323_if_or.intervals.txt new file mode 100644 index 0000000..039c089 --- /dev/null +++ b/tests/results/0323_if_or.intervals.txt @@ -0,0 +1,3 @@ +sources/0323_if_or.c:3.22-34: [ x in [10;20], y in [30;40] ] +sources/0323_if_or.c:4.7-19: [ x in [10;14], y in [30;34] ] +Output: [ x in [10;20], y in [30;40] ] diff --git a/tests/results/0323_if_or.polyhedra.txt b/tests/results/0323_if_or.polyhedra.txt new file mode 100644 index 0000000..0854d10 --- /dev/null +++ b/tests/results/0323_if_or.polyhedra.txt @@ -0,0 +1,4 @@ +sources/0323_if_or.c:3.22-34: [|-x+20>=0; -y+40>=0; y-30>=0; x-10>=0; + x+y-45>=0|] +sources/0323_if_or.c:4.7-19: [|-x+14>=0; -y+34>=0; y-30>=0; x-10>=0|] +Output: [|-x+20>=0; -y+40>=0; y-30>=0; x-10>=0|] diff --git a/tests/results/0324_if_not.constants.txt b/tests/results/0324_if_not.constants.txt new file mode 100644 index 0000000..9e4038c --- /dev/null +++ b/tests/results/0324_if_not.constants.txt @@ -0,0 +1,3 @@ +sources/0324_if_not.c:3.25-37: [ x in top, y in top ] +sources/0324_if_not.c:4.7-19: [ x in top, y in top ] +Output: [ x in top, y in top ] diff --git a/tests/results/0324_if_not.intervals.txt b/tests/results/0324_if_not.intervals.txt new file mode 100644 index 0000000..e51107a --- /dev/null +++ b/tests/results/0324_if_not.intervals.txt @@ -0,0 +1,3 @@ +sources/0324_if_not.c:3.25-37: [ x in [10;20], y in [30;40] ] +sources/0324_if_not.c:4.7-19: [ x in [15;20], y in [30;34] ] +Output: [ x in [10;20], y in [30;40] ] diff --git a/tests/results/0324_if_not.polyhedra.txt b/tests/results/0324_if_not.polyhedra.txt new file mode 100644 index 0000000..4361881 --- /dev/null +++ b/tests/results/0324_if_not.polyhedra.txt @@ -0,0 +1,4 @@ +sources/0324_if_not.c:3.25-37: [|-5x+6y-110>=0; -x+20>=0; -y+40>=0; y-30>=0; + x-10>=0|] +sources/0324_if_not.c:4.7-19: [|-x+20>=0; -y+34>=0; y-30>=0; x-15>=0|] +Output: [|-x+20>=0; -y+40>=0; y-30>=0; x-10>=0|] diff --git a/tests/results/0325_if_bool.constants.txt b/tests/results/0325_if_bool.constants.txt new file mode 100644 index 0000000..714b57b --- /dev/null +++ b/tests/results/0325_if_bool.constants.txt @@ -0,0 +1,3 @@ +sources/0325_if_bool.c:3.40-52: [ x in top, y in top ] +sources/0325_if_bool.c:4.7-19: [ x in top, y in top ] +Output: [ x in top, y in top ] diff --git a/tests/results/0325_if_bool.intervals.txt b/tests/results/0325_if_bool.intervals.txt new file mode 100644 index 0000000..cd51d25 --- /dev/null +++ b/tests/results/0325_if_bool.intervals.txt @@ -0,0 +1,3 @@ +sources/0325_if_bool.c:3.40-52: [ x in [10;20], y in [10;20] ] +sources/0325_if_bool.c:4.7-19: [ x in [10;20], y in [10;20] ] +Output: [ x in [10;20], y in [10;20] ] diff --git a/tests/results/0325_if_bool.polyhedra.txt b/tests/results/0325_if_bool.polyhedra.txt new file mode 100644 index 0000000..54b93f7 --- /dev/null +++ b/tests/results/0325_if_bool.polyhedra.txt @@ -0,0 +1,5 @@ +sources/0325_if_bool.c:3.40-52: [|-x-y+35>=0; -x+20>=0; -y+20>=0; y-10>=0; + x-10>=0; x+y-25>=0|] +sources/0325_if_bool.c:4.7-19: [|-x+20>=0; -x+y+4>=0; -y+20>=0; y-10>=0; + x-y+4>=0; x-10>=0|] +Output: [|-x+20>=0; -y+20>=0; y-10>=0; x-10>=0|] diff --git a/tests/results/0400_assert_true.constants.txt b/tests/results/0400_assert_true.constants.txt new file mode 100644 index 0000000..7465c26 --- /dev/null +++ b/tests/results/0400_assert_true.constants.txt @@ -0,0 +1 @@ +Output: [ x in {2} ] diff --git a/tests/results/0400_assert_true.intervals.txt b/tests/results/0400_assert_true.intervals.txt new file mode 100644 index 0000000..8aa541a --- /dev/null +++ b/tests/results/0400_assert_true.intervals.txt @@ -0,0 +1 @@ +Output: [ x in [2;2] ] diff --git a/tests/results/0400_assert_true.polyhedra.txt b/tests/results/0400_assert_true.polyhedra.txt new file mode 100644 index 0000000..0472ac6 --- /dev/null +++ b/tests/results/0400_assert_true.polyhedra.txt @@ -0,0 +1 @@ +Output: [|x-2=0|] diff --git a/tests/results/0401_assert_false.constants.txt b/tests/results/0401_assert_false.constants.txt new file mode 100644 index 0000000..2dd50d8 --- /dev/null +++ b/tests/results/0401_assert_false.constants.txt @@ -0,0 +1,2 @@ +sources/0401_assert_false.c:2.0-15: ERROR: assertion failure +Output: bottom diff --git a/tests/results/0401_assert_false.intervals.txt b/tests/results/0401_assert_false.intervals.txt new file mode 100644 index 0000000..2dd50d8 --- /dev/null +++ b/tests/results/0401_assert_false.intervals.txt @@ -0,0 +1,2 @@ +sources/0401_assert_false.c:2.0-15: ERROR: assertion failure +Output: bottom diff --git a/tests/results/0401_assert_false.polyhedra.txt b/tests/results/0401_assert_false.polyhedra.txt new file mode 100644 index 0000000..2dd50d8 --- /dev/null +++ b/tests/results/0401_assert_false.polyhedra.txt @@ -0,0 +1,2 @@ +sources/0401_assert_false.c:2.0-15: ERROR: assertion failure +Output: bottom diff --git a/tests/results/0402_assert_both.constants.txt b/tests/results/0402_assert_both.constants.txt new file mode 100644 index 0000000..f0e4f75 --- /dev/null +++ b/tests/results/0402_assert_both.constants.txt @@ -0,0 +1,3 @@ +sources/0402_assert_both.c:2.0-15: ERROR: assertion failure +sources/0402_assert_both.c:3.0-14: ERROR: assertion failure +Output: [ x in top ] diff --git a/tests/results/0402_assert_both.intervals.txt b/tests/results/0402_assert_both.intervals.txt new file mode 100644 index 0000000..55a8f12 --- /dev/null +++ b/tests/results/0402_assert_both.intervals.txt @@ -0,0 +1,3 @@ +sources/0402_assert_both.c:2.0-15: ERROR: assertion failure +sources/0402_assert_both.c:3.0-14: ERROR: assertion failure +Output: [ x in [1;10] ] diff --git a/tests/results/0402_assert_both.polyhedra.txt b/tests/results/0402_assert_both.polyhedra.txt new file mode 100644 index 0000000..d46828e --- /dev/null +++ b/tests/results/0402_assert_both.polyhedra.txt @@ -0,0 +1,3 @@ +sources/0402_assert_both.c:2.0-15: ERROR: assertion failure +sources/0402_assert_both.c:3.0-14: ERROR: assertion failure +Output: [|-x+10>=0; x-1>=0|] diff --git a/tests/results/0403_assert_both2.constants.txt b/tests/results/0403_assert_both2.constants.txt new file mode 100644 index 0000000..a229c5a --- /dev/null +++ b/tests/results/0403_assert_both2.constants.txt @@ -0,0 +1,3 @@ +sources/0403_assert_both2.c:2.0-14: ERROR: assertion failure +sources/0403_assert_both2.c:3.0-15: ERROR: assertion failure +Output: [ x in top ] diff --git a/tests/results/0403_assert_both2.intervals.txt b/tests/results/0403_assert_both2.intervals.txt new file mode 100644 index 0000000..9dc7efd --- /dev/null +++ b/tests/results/0403_assert_both2.intervals.txt @@ -0,0 +1,2 @@ +sources/0403_assert_both2.c:2.0-14: ERROR: assertion failure +Output: [ x in [1;10] ] diff --git a/tests/results/0403_assert_both2.polyhedra.txt b/tests/results/0403_assert_both2.polyhedra.txt new file mode 100644 index 0000000..37cb40e --- /dev/null +++ b/tests/results/0403_assert_both2.polyhedra.txt @@ -0,0 +1,2 @@ +sources/0403_assert_both2.c:2.0-14: ERROR: assertion failure +Output: [|-x+10>=0; x-1>=0|] diff --git a/tests/results/0404_assert_rel.constants.txt b/tests/results/0404_assert_rel.constants.txt new file mode 100644 index 0000000..2160c42 --- /dev/null +++ b/tests/results/0404_assert_rel.constants.txt @@ -0,0 +1,2 @@ +sources/0404_assert_rel.c:4.0-13: ERROR: assertion failure +Output: [ x in top, y in top ] diff --git a/tests/results/0404_assert_rel.intervals.txt b/tests/results/0404_assert_rel.intervals.txt new file mode 100644 index 0000000..cfcc3b2 --- /dev/null +++ b/tests/results/0404_assert_rel.intervals.txt @@ -0,0 +1,2 @@ +sources/0404_assert_rel.c:4.0-13: ERROR: assertion failure +Output: [ x in [1;3], y in [1;3] ] diff --git a/tests/results/0404_assert_rel.polyhedra.txt b/tests/results/0404_assert_rel.polyhedra.txt new file mode 100644 index 0000000..7b5a252 --- /dev/null +++ b/tests/results/0404_assert_rel.polyhedra.txt @@ -0,0 +1 @@ +Output: [|-x+y=0; -x+3>=0; x-1>=0|] diff --git a/tests/results/0500_loop_count.constants.txt b/tests/results/0500_loop_count.constants.txt new file mode 100644 index 0000000..530df33 --- /dev/null +++ b/tests/results/0500_loop_count.constants.txt @@ -0,0 +1,5 @@ +sources/0500_loop_count.c:3.2-4.2: [ x in {0} ] +sources/0500_loop_count.c:3.2-4.2: [ x in {1} ] +sources/0500_loop_count.c:3.2-4.2: [ x in {2} ] +sources/0500_loop_count.c:3.2-4.2: [ x in top ] +Output: [ x in top ] diff --git a/tests/results/0500_loop_count.intervals.txt b/tests/results/0500_loop_count.intervals.txt new file mode 100644 index 0000000..ed48d45 --- /dev/null +++ b/tests/results/0500_loop_count.intervals.txt @@ -0,0 +1,5 @@ +sources/0500_loop_count.c:3.2-4.2: [ x in [0;0] ] +sources/0500_loop_count.c:3.2-4.2: [ x in [1;1] ] +sources/0500_loop_count.c:3.2-4.2: [ x in [2;2] ] +sources/0500_loop_count.c:3.2-4.2: [ x in [3;99] ] +Output: [ x in [100;100] ] diff --git a/tests/results/0500_loop_count.polyhedra.txt b/tests/results/0500_loop_count.polyhedra.txt new file mode 100644 index 0000000..effcc42 --- /dev/null +++ b/tests/results/0500_loop_count.polyhedra.txt @@ -0,0 +1,5 @@ +sources/0500_loop_count.c:3.2-4.2: [|x=0|] +sources/0500_loop_count.c:3.2-4.2: [|x-1=0|] +sources/0500_loop_count.c:3.2-4.2: [|x-2=0|] +sources/0500_loop_count.c:3.2-4.2: [|-x+99>=0; x-3>=0|] +Output: [|x-100=0|] diff --git a/tests/results/0501_loop_infinite.constants.txt b/tests/results/0501_loop_infinite.constants.txt new file mode 100644 index 0000000..e0eb2c9 --- /dev/null +++ b/tests/results/0501_loop_infinite.constants.txt @@ -0,0 +1,5 @@ +sources/0501_loop_infinite.c:3.2-4.0: [ x in {0} ] +sources/0501_loop_infinite.c:3.2-4.0: [ x in {0} ] +sources/0501_loop_infinite.c:3.2-4.0: [ x in {0} ] +sources/0501_loop_infinite.c:3.2-4.0: [ x in {0} ] +Output: bottom diff --git a/tests/results/0501_loop_infinite.intervals.txt b/tests/results/0501_loop_infinite.intervals.txt new file mode 100644 index 0000000..eab060c --- /dev/null +++ b/tests/results/0501_loop_infinite.intervals.txt @@ -0,0 +1,5 @@ +sources/0501_loop_infinite.c:3.2-4.0: [ x in [0;0] ] +sources/0501_loop_infinite.c:3.2-4.0: [ x in [0;0] ] +sources/0501_loop_infinite.c:3.2-4.0: [ x in [0;0] ] +sources/0501_loop_infinite.c:3.2-4.0: [ x in [0;0] ] +Output: bottom diff --git a/tests/results/0501_loop_infinite.polyhedra.txt b/tests/results/0501_loop_infinite.polyhedra.txt new file mode 100644 index 0000000..64d2853 --- /dev/null +++ b/tests/results/0501_loop_infinite.polyhedra.txt @@ -0,0 +1,5 @@ +sources/0501_loop_infinite.c:3.2-4.0: [|x=0|] +sources/0501_loop_infinite.c:3.2-4.0: [|x=0|] +sources/0501_loop_infinite.c:3.2-4.0: [|x=0|] +sources/0501_loop_infinite.c:3.2-4.0: [|x=0|] +Output: bottom diff --git a/tests/results/0502_loop_infinite2.constants.txt b/tests/results/0502_loop_infinite2.constants.txt new file mode 100644 index 0000000..015089f --- /dev/null +++ b/tests/results/0502_loop_infinite2.constants.txt @@ -0,0 +1,5 @@ +sources/0502_loop_infinite2.c:3.2-4.2: [ x in {0} ] +sources/0502_loop_infinite2.c:3.2-4.2: [ x in {-1} ] +sources/0502_loop_infinite2.c:3.2-4.2: [ x in {-2} ] +sources/0502_loop_infinite2.c:3.2-4.2: [ x in top ] +Output: [ x in top ] diff --git a/tests/results/0502_loop_infinite2.intervals.txt b/tests/results/0502_loop_infinite2.intervals.txt new file mode 100644 index 0000000..bd8f380 --- /dev/null +++ b/tests/results/0502_loop_infinite2.intervals.txt @@ -0,0 +1,5 @@ +sources/0502_loop_infinite2.c:3.2-4.2: [ x in [0;0] ] +sources/0502_loop_infinite2.c:3.2-4.2: [ x in [-1;-1] ] +sources/0502_loop_infinite2.c:3.2-4.2: [ x in [-2;-2] ] +sources/0502_loop_infinite2.c:3.2-4.2: [ x in [-oo;-3] ] +Output: bottom diff --git a/tests/results/0502_loop_infinite2.polyhedra.txt b/tests/results/0502_loop_infinite2.polyhedra.txt new file mode 100644 index 0000000..41c8ebb --- /dev/null +++ b/tests/results/0502_loop_infinite2.polyhedra.txt @@ -0,0 +1,5 @@ +sources/0502_loop_infinite2.c:3.2-4.2: [|x=0|] +sources/0502_loop_infinite2.c:3.2-4.2: [|x+1=0|] +sources/0502_loop_infinite2.c:3.2-4.2: [|x+2=0|] +sources/0502_loop_infinite2.c:3.2-4.2: [|-x-3>=0|] +Output: bottom diff --git a/tests/results/0503_loop_nondet.constants.txt b/tests/results/0503_loop_nondet.constants.txt new file mode 100644 index 0000000..1002f30 --- /dev/null +++ b/tests/results/0503_loop_nondet.constants.txt @@ -0,0 +1,5 @@ +sources/0503_loop_nondet.c:3.2-4.2: [ x in {0} ] +sources/0503_loop_nondet.c:3.2-4.2: [ x in {1} ] +sources/0503_loop_nondet.c:3.2-4.2: [ x in {2} ] +sources/0503_loop_nondet.c:3.2-4.2: [ x in top ] +Output: [ x in top ] diff --git a/tests/results/0503_loop_nondet.intervals.txt b/tests/results/0503_loop_nondet.intervals.txt new file mode 100644 index 0000000..b4af6d2 --- /dev/null +++ b/tests/results/0503_loop_nondet.intervals.txt @@ -0,0 +1,5 @@ +sources/0503_loop_nondet.c:3.2-4.2: [ x in [0;0] ] +sources/0503_loop_nondet.c:3.2-4.2: [ x in [1;1] ] +sources/0503_loop_nondet.c:3.2-4.2: [ x in [2;2] ] +sources/0503_loop_nondet.c:3.2-4.2: [ x in [3;+oo] ] +Output: [ x in [0;+oo] ] diff --git a/tests/results/0503_loop_nondet.polyhedra.txt b/tests/results/0503_loop_nondet.polyhedra.txt new file mode 100644 index 0000000..a358809 --- /dev/null +++ b/tests/results/0503_loop_nondet.polyhedra.txt @@ -0,0 +1,5 @@ +sources/0503_loop_nondet.c:3.2-4.2: [|x=0|] +sources/0503_loop_nondet.c:3.2-4.2: [|x-1=0|] +sources/0503_loop_nondet.c:3.2-4.2: [|x-2=0|] +sources/0503_loop_nondet.c:3.2-4.2: [|x-3>=0|] +Output: [|x>=0|] diff --git a/tests/results/0504_loop_rel.constants.txt b/tests/results/0504_loop_rel.constants.txt new file mode 100644 index 0000000..e3ca5e3 --- /dev/null +++ b/tests/results/0504_loop_rel.constants.txt @@ -0,0 +1,6 @@ +sources/0504_loop_rel.c:4.2-5.2: [ x in {0}, N in top ] +sources/0504_loop_rel.c:4.2-5.2: [ x in {1}, N in top ] +sources/0504_loop_rel.c:4.2-5.2: [ x in {2}, N in top ] +sources/0504_loop_rel.c:4.2-5.2: [ x in top, N in top ] +sources/0504_loop_rel.c:7.0-13: ERROR: assertion failure +Output: [ N in top, x in top ] diff --git a/tests/results/0504_loop_rel.intervals.txt b/tests/results/0504_loop_rel.intervals.txt new file mode 100644 index 0000000..2f0c86c --- /dev/null +++ b/tests/results/0504_loop_rel.intervals.txt @@ -0,0 +1,6 @@ +sources/0504_loop_rel.c:4.2-5.2: [ x in [0;0], N in [1;1000] ] +sources/0504_loop_rel.c:4.2-5.2: [ x in [1;1], N in [2;1000] ] +sources/0504_loop_rel.c:4.2-5.2: [ x in [2;2], N in [3;1000] ] +sources/0504_loop_rel.c:4.2-5.2: [ x in [3;999], N in [4;1000] ] +sources/0504_loop_rel.c:7.0-13: ERROR: assertion failure +Output: [ N in [0;1000], x in [0;1000] ] diff --git a/tests/results/0504_loop_rel.polyhedra.txt b/tests/results/0504_loop_rel.polyhedra.txt new file mode 100644 index 0000000..5d3d189 --- /dev/null +++ b/tests/results/0504_loop_rel.polyhedra.txt @@ -0,0 +1,5 @@ +sources/0504_loop_rel.c:4.2-5.2: [|x=0; -N+1000>=0; N-1>=0|] +sources/0504_loop_rel.c:4.2-5.2: [|x-1=0; -N+1000>=0; N-2>=0|] +sources/0504_loop_rel.c:4.2-5.2: [|x-2=0; -N+1000>=0; N-3>=0|] +sources/0504_loop_rel.c:4.2-5.2: [|-N+1000>=0; x-3>=0; N-x-1>=0|] +Output: [|-N+x=0; -N+1000>=0; N>=0|] diff --git a/tests/results/0505_loop_rel2.constants.txt b/tests/results/0505_loop_rel2.constants.txt new file mode 100644 index 0000000..762a610 --- /dev/null +++ b/tests/results/0505_loop_rel2.constants.txt @@ -0,0 +1,6 @@ +sources/0505_loop_rel2.c:4.2-5.2: [ x in {0}, N in top ] +sources/0505_loop_rel2.c:4.2-5.2: [ x in top, N in top ] +sources/0505_loop_rel2.c:4.2-5.2: [ x in top, N in top ] +sources/0505_loop_rel2.c:4.2-5.2: [ x in top, N in top ] +sources/0505_loop_rel2.c:7.0-22: ERROR: assertion failure +Output: [ N in top, x in top ] diff --git a/tests/results/0505_loop_rel2.intervals.txt b/tests/results/0505_loop_rel2.intervals.txt new file mode 100644 index 0000000..f1e9597 --- /dev/null +++ b/tests/results/0505_loop_rel2.intervals.txt @@ -0,0 +1,6 @@ +sources/0505_loop_rel2.c:4.2-5.2: [ x in [0;0], N in [1;1000] ] +sources/0505_loop_rel2.c:4.2-5.2: [ x in [0;3], N in [1;1000] ] +sources/0505_loop_rel2.c:4.2-5.2: [ x in [0;6], N in [1;1000] ] +sources/0505_loop_rel2.c:4.2-5.2: [ x in [0;999], N in [1;1000] ] +sources/0505_loop_rel2.c:7.0-22: ERROR: assertion failure +Output: [ N in [0;1000], x in [0;1002] ] diff --git a/tests/results/0505_loop_rel2.polyhedra.txt b/tests/results/0505_loop_rel2.polyhedra.txt new file mode 100644 index 0000000..cf93640 --- /dev/null +++ b/tests/results/0505_loop_rel2.polyhedra.txt @@ -0,0 +1,5 @@ +sources/0505_loop_rel2.c:4.2-5.2: [|x=0; -N+1000>=0; N-1>=0|] +sources/0505_loop_rel2.c:4.2-5.2: [|-N+1000>=0; -x+3>=0; x>=0; N-x-1>=0|] +sources/0505_loop_rel2.c:4.2-5.2: [|-N+1000>=0; -x+6>=0; x>=0; N-x-1>=0|] +sources/0505_loop_rel2.c:4.2-5.2: [|-N+1000>=0; x>=0; N-x-1>=0|] +Output: [|-N+1000>=0; -N+x>=0; N-x+2>=0; 3N-x>=0|] diff --git a/tests/results/0506_loop_limit.constants.txt b/tests/results/0506_loop_limit.constants.txt new file mode 100644 index 0000000..39f5f34 --- /dev/null +++ b/tests/results/0506_loop_limit.constants.txt @@ -0,0 +1,2 @@ +sources/0506_loop_limit.c:5.0-9: [ x in top ] +Output: [ x in top ] diff --git a/tests/results/0506_loop_limit.intervals.txt b/tests/results/0506_loop_limit.intervals.txt new file mode 100644 index 0000000..7cb2cef --- /dev/null +++ b/tests/results/0506_loop_limit.intervals.txt @@ -0,0 +1,2 @@ +sources/0506_loop_limit.c:5.0-9: [ x in [0;+oo] ] +Output: [ x in [0;+oo] ] diff --git a/tests/results/0506_loop_limit.polyhedra.txt b/tests/results/0506_loop_limit.polyhedra.txt new file mode 100644 index 0000000..4577a55 --- /dev/null +++ b/tests/results/0506_loop_limit.polyhedra.txt @@ -0,0 +1,2 @@ +sources/0506_loop_limit.c:5.0-9: [|x>=0|] +Output: [|x>=0|] diff --git a/tests/results/0507_loop_limit2.constants.txt b/tests/results/0507_loop_limit2.constants.txt new file mode 100644 index 0000000..b3c5933 --- /dev/null +++ b/tests/results/0507_loop_limit2.constants.txt @@ -0,0 +1,2 @@ +sources/0507_loop_limit2.c:6.0-9: [ x in top ] +Output: [ N in top, x in top ] diff --git a/tests/results/0507_loop_limit2.intervals.txt b/tests/results/0507_loop_limit2.intervals.txt new file mode 100644 index 0000000..738b69b --- /dev/null +++ b/tests/results/0507_loop_limit2.intervals.txt @@ -0,0 +1,2 @@ +sources/0507_loop_limit2.c:6.0-9: [ x in [0;+oo] ] +Output: [ N in [0;1000], x in [0;+oo] ] diff --git a/tests/results/0507_loop_limit2.polyhedra.txt b/tests/results/0507_loop_limit2.polyhedra.txt new file mode 100644 index 0000000..d2a1ea6 --- /dev/null +++ b/tests/results/0507_loop_limit2.polyhedra.txt @@ -0,0 +1,2 @@ +sources/0507_loop_limit2.c:6.0-9: [|-x+1000>=0; x>=0|] +Output: [|-N+1000>=0; x>=0; N-x>=0|] diff --git a/tests/results/0508_loop_init.constants.txt b/tests/results/0508_loop_init.constants.txt new file mode 100644 index 0000000..702e551 --- /dev/null +++ b/tests/results/0508_loop_init.constants.txt @@ -0,0 +1,2 @@ +sources/0508_loop_init.c:13.2-14.0: ERROR: assertion failure +Output: [ init in top, x in top ] diff --git a/tests/results/0508_loop_init.intervals.txt b/tests/results/0508_loop_init.intervals.txt new file mode 100644 index 0000000..c52a9a1 --- /dev/null +++ b/tests/results/0508_loop_init.intervals.txt @@ -0,0 +1 @@ +Output: [ init in [0;1], x in [-oo;+oo] ] diff --git a/tests/results/0508_loop_init.polyhedra.txt b/tests/results/0508_loop_init.polyhedra.txt new file mode 100644 index 0000000..4b8711f --- /dev/null +++ b/tests/results/0508_loop_init.polyhedra.txt @@ -0,0 +1 @@ +Output: [|-init+1>=0; init>=0|] diff --git a/tests/results/0509_loop_nested.constants.txt b/tests/results/0509_loop_nested.constants.txt new file mode 100644 index 0000000..cbca9fb --- /dev/null +++ b/tests/results/0509_loop_nested.constants.txt @@ -0,0 +1 @@ +Output: [ i in top, j in top ] diff --git a/tests/results/0509_loop_nested.intervals.txt b/tests/results/0509_loop_nested.intervals.txt new file mode 100644 index 0000000..c8ba912 --- /dev/null +++ b/tests/results/0509_loop_nested.intervals.txt @@ -0,0 +1 @@ +Output: [ i in [1000;1000], j in [2;999] ] diff --git a/tests/results/0509_loop_nested.polyhedra.txt b/tests/results/0509_loop_nested.polyhedra.txt new file mode 100644 index 0000000..f00ac71 --- /dev/null +++ b/tests/results/0509_loop_nested.polyhedra.txt @@ -0,0 +1 @@ +Output: [|j-999=0; i-1000=0|] diff --git a/tests/results/0510_loop_nested2.constants.txt b/tests/results/0510_loop_nested2.constants.txt new file mode 100644 index 0000000..cbca9fb --- /dev/null +++ b/tests/results/0510_loop_nested2.constants.txt @@ -0,0 +1 @@ +Output: [ i in top, j in top ] diff --git a/tests/results/0510_loop_nested2.intervals.txt b/tests/results/0510_loop_nested2.intervals.txt new file mode 100644 index 0000000..c8ba912 --- /dev/null +++ b/tests/results/0510_loop_nested2.intervals.txt @@ -0,0 +1 @@ +Output: [ i in [1000;1000], j in [2;999] ] diff --git a/tests/results/0510_loop_nested2.polyhedra.txt b/tests/results/0510_loop_nested2.polyhedra.txt new file mode 100644 index 0000000..f00ac71 --- /dev/null +++ b/tests/results/0510_loop_nested2.polyhedra.txt @@ -0,0 +1 @@ +Output: [|j-999=0; i-1000=0|] diff --git a/tests/results/0600_bubble_sort.constants.txt b/tests/results/0600_bubble_sort.constants.txt new file mode 100644 index 0000000..2a0bcda --- /dev/null +++ b/tests/results/0600_bubble_sort.constants.txt @@ -0,0 +1,33 @@ +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +Output: [ B in top, J in top, N in top, T in top ] diff --git a/tests/results/0600_bubble_sort.intervals.txt b/tests/results/0600_bubble_sort.intervals.txt new file mode 100644 index 0000000..7357141 --- /dev/null +++ b/tests/results/0600_bubble_sort.intervals.txt @@ -0,0 +1,25 @@ +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +Output: [ B in [0;0], J in [-oo;+oo], N in [0;100000], T in [-oo;+oo] ] diff --git a/tests/results/0600_bubble_sort.polyhedra.txt b/tests/results/0600_bubble_sort.polyhedra.txt new file mode 100644 index 0000000..e2a1918 --- /dev/null +++ b/tests/results/0600_bubble_sort.polyhedra.txt @@ -0,0 +1 @@ +Output: [|B=0; -N+100000>=0; N>=0|] diff --git a/tests/results/0601_heap_sort.constants.txt b/tests/results/0601_heap_sort.constants.txt new file mode 100644 index 0000000..3f8cad1 --- /dev/null +++ b/tests/results/0601_heap_sort.constants.txt @@ -0,0 +1,104 @@ +sources/0601_heap_sort.c:17.2-18.0: ERROR: assertion failure +sources/0601_heap_sort.c:21.3-22.3: ERROR: assertion failure +sources/0601_heap_sort.c:22.3-23.3: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:50.2-52.2: ERROR: assertion failure +sources/0601_heap_sort.c:55.4-56.2: ERROR: assertion failure +sources/0601_heap_sort.c:59.4-60.4: ERROR: assertion failure +sources/0601_heap_sort.c:60.4-61.4: ERROR: assertion failure +sources/0601_heap_sort.c:65.2-66.0: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:50.2-52.2: ERROR: assertion failure +sources/0601_heap_sort.c:55.4-56.2: ERROR: assertion failure +sources/0601_heap_sort.c:59.4-60.4: ERROR: assertion failure +sources/0601_heap_sort.c:60.4-61.4: ERROR: assertion failure +sources/0601_heap_sort.c:65.2-66.0: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:50.2-52.2: ERROR: assertion failure +sources/0601_heap_sort.c:55.4-56.2: ERROR: assertion failure +sources/0601_heap_sort.c:59.4-60.4: ERROR: assertion failure +sources/0601_heap_sort.c:60.4-61.4: ERROR: assertion failure +sources/0601_heap_sort.c:65.2-66.0: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:50.2-52.2: ERROR: assertion failure +sources/0601_heap_sort.c:55.4-56.2: ERROR: assertion failure +sources/0601_heap_sort.c:59.4-60.4: ERROR: assertion failure +sources/0601_heap_sort.c:60.4-61.4: ERROR: assertion failure +sources/0601_heap_sort.c:65.2-66.0: ERROR: assertion failure +Output: [ I in top, J in top, L in top, N in top, R in top ] diff --git a/tests/results/0601_heap_sort.intervals.txt b/tests/results/0601_heap_sort.intervals.txt new file mode 100644 index 0000000..e8ec3f7 --- /dev/null +++ b/tests/results/0601_heap_sort.intervals.txt @@ -0,0 +1,95 @@ +sources/0601_heap_sort.c:17.2-18.0: ERROR: assertion failure +sources/0601_heap_sort.c:21.3-22.3: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:50.2-52.2: ERROR: assertion failure +sources/0601_heap_sort.c:55.4-56.2: ERROR: assertion failure +sources/0601_heap_sort.c:59.4-60.4: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:50.2-52.2: ERROR: assertion failure +sources/0601_heap_sort.c:55.4-56.2: ERROR: assertion failure +sources/0601_heap_sort.c:59.4-60.4: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:50.2-52.2: ERROR: assertion failure +sources/0601_heap_sort.c:55.4-56.2: ERROR: assertion failure +sources/0601_heap_sort.c:59.4-60.4: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:50.2-52.2: ERROR: assertion failure +sources/0601_heap_sort.c:55.4-56.2: ERROR: assertion failure +sources/0601_heap_sort.c:59.4-60.4: ERROR: assertion failure +Output: [ I in [-oo;+oo], J in [-oo;+oo], L in [-oo;100000], N in [1;100000], R in [0;1] ] diff --git a/tests/results/0601_heap_sort.polyhedra.txt b/tests/results/0601_heap_sort.polyhedra.txt new file mode 100644 index 0000000..6dde246 --- /dev/null +++ b/tests/results/0601_heap_sort.polyhedra.txt @@ -0,0 +1 @@ +Output: [|-99999L+49999R+99999>=0; -2L+N+1>=0; -R+1>=0; L-1>=0|] diff --git a/tests/results/0602_rate_limiter.constants.txt b/tests/results/0602_rate_limiter.constants.txt new file mode 100644 index 0000000..e0768fb --- /dev/null +++ b/tests/results/0602_rate_limiter.constants.txt @@ -0,0 +1,2 @@ +sources/0602_rate_limiter.c:26.0-30: ERROR: assertion failure +Output: [ D in top, S in top, X in top, Y in top ] diff --git a/tests/results/0602_rate_limiter.intervals.txt b/tests/results/0602_rate_limiter.intervals.txt new file mode 100644 index 0000000..56f35e9 --- /dev/null +++ b/tests/results/0602_rate_limiter.intervals.txt @@ -0,0 +1,2 @@ +sources/0602_rate_limiter.c:26.0-30: ERROR: assertion failure +Output: [ D in [-oo;+oo], S in [-oo;+oo], X in [-oo;+oo], Y in [-128;128] ] diff --git a/tests/results/0602_rate_limiter.polyhedra.txt b/tests/results/0602_rate_limiter.polyhedra.txt new file mode 100644 index 0000000..b4c3d72 --- /dev/null +++ b/tests/results/0602_rate_limiter.polyhedra.txt @@ -0,0 +1,2 @@ +sources/0602_rate_limiter.c:26.0-30: ERROR: assertion failure +Output: [|-Y+128>=0; Y+128>=0|] diff --git a/tests/results/0603_rate_limiter2.constants.txt b/tests/results/0603_rate_limiter2.constants.txt new file mode 100644 index 0000000..de62fd6 --- /dev/null +++ b/tests/results/0603_rate_limiter2.constants.txt @@ -0,0 +1,5 @@ +sources/0603_rate_limiter2.c:20.2-21.0: ERROR: assertion failure +sources/0603_rate_limiter2.c:20.2-21.0: ERROR: assertion failure +sources/0603_rate_limiter2.c:20.2-21.0: ERROR: assertion failure +sources/0603_rate_limiter2.c:20.2-21.0: ERROR: assertion failure +Output: [ D in top, S in top, X in top, Y in top ] diff --git a/tests/results/0603_rate_limiter2.intervals.txt b/tests/results/0603_rate_limiter2.intervals.txt new file mode 100644 index 0000000..3c3ed17 --- /dev/null +++ b/tests/results/0603_rate_limiter2.intervals.txt @@ -0,0 +1,4 @@ +sources/0603_rate_limiter2.c:20.2-21.0: ERROR: assertion failure +sources/0603_rate_limiter2.c:20.2-21.0: ERROR: assertion failure +sources/0603_rate_limiter2.c:20.2-21.0: ERROR: assertion failure +Output: [ D in [-oo;+oo], S in [-oo;+oo], X in [-oo;+oo], Y in [-128;128] ] diff --git a/tests/results/0603_rate_limiter2.polyhedra.txt b/tests/results/0603_rate_limiter2.polyhedra.txt new file mode 100644 index 0000000..13697f6 --- /dev/null +++ b/tests/results/0603_rate_limiter2.polyhedra.txt @@ -0,0 +1 @@ +Output: [|-Y+128>=0; Y+128>=0|] diff --git a/tests/results/all.constants.txt b/tests/results/all.constants.txt new file mode 100644 index 0000000..ac3ee3f --- /dev/null +++ b/tests/results/all.constants.txt @@ -0,0 +1,1135 @@ +sources/0000_noinit_var.c + + 1 int x; + +Output: [ x in top ] + +------------------------------------- + +sources/0001_noinit_2var.c + + 1 int x; + 2 int y; + +Output: [ x in top, y in top ] + +------------------------------------- + +sources/0002_init_var.c + + 1 int x = 0; + +Output: [ x in {0} ] + +------------------------------------- + +sources/0003_init_2var.c + + 1 int x = 0; + 2 int y = 1; + +Output: [ x in {0}, y in {1} ] + +------------------------------------- + +sources/0004_init_2var2.c + + 1 int x = 9, y = 12; + +Output: [ x in {9}, y in {12} ] + +------------------------------------- + +sources/0100_print_var.c + + 1 int x = 2; + 2 print(x); + +sources/0100_print_var.c:2.0-9: [ x in {2} ] +Output: [ x in {2} ] + +------------------------------------- + +sources/0101_print_2var.c + + 1 int x = 3; + 2 int y = 15; + 3 print(y); + +sources/0101_print_2var.c:3.0-9: [ y in {15} ] +Output: [ x in {3}, y in {15} ] + +------------------------------------- + +sources/0102_print_3var.c + + 1 int x = 3; + 2 int y = 15; + 3 int z = 99; + 4 print(z,x); + +sources/0102_print_3var.c:4.0-11: [ z in {99}, x in {3} ] +Output: [ x in {3}, y in {15}, z in {99} ] + +------------------------------------- + +sources/0103_local.c + + 1 int x = 12; + 2 { + 3 int y = 9; + 4 print(x,y); + 5 } + +sources/0103_local.c:4.2-5.0: [ x in {12}, y in {9} ] +Output: [ x in {12} ] + +------------------------------------- + +sources/0200_assign_cst.c + + 1 int x; + 2 print(x); + 3 x = 12; + 4 print(x); + 5 x = 15; + 6 print(x); + +sources/0200_assign_cst.c:2.0-9: [ x in top ] +sources/0200_assign_cst.c:4.0-9: [ x in {12} ] +sources/0200_assign_cst.c:6.0-9: [ x in {15} ] +Output: [ x in {15} ] + +------------------------------------- + +sources/0201_assign_cst2.c + + 1 int x, y; + 2 print(x,y); + 3 x = 12; + 4 print(x,y); + 5 y = 15; + 6 x = 99; + 7 print(x,y); + +sources/0201_assign_cst2.c:2.0-11: [ x in top, y in top ] +sources/0201_assign_cst2.c:4.0-11: [ x in {12}, y in top ] +sources/0201_assign_cst2.c:7.0-11: [ x in {99}, y in {15} ] +Output: [ x in {99}, y in {15} ] + +------------------------------------- + +sources/0202_assign_expr.c + + 1 int x; + 2 x = 2 + 2; + +Output: [ x in {4} ] + +------------------------------------- + +sources/0203_assign_expr2.c + + 1 int x,y; + 2 x = 12; + 3 y = 16; + 4 x = x + y + 2; + 5 print(x); + +sources/0203_assign_expr2.c:5.0-9: [ x in {30} ] +Output: [ x in {30}, y in {16} ] + +------------------------------------- + +sources/0204_assign_rand.c + + 1 int x; + 2 x = rand(1,99); + 3 print(x); + +sources/0204_assign_rand.c:3.0-9: [ x in top ] +Output: [ x in top ] + +------------------------------------- + +sources/0205_assign_rand2.c + + 1 int x; + 2 x = rand(10,-5); + 3 print(x); + +sources/0205_assign_rand2.c:3.0-9: bottom +Output: bottom + +------------------------------------- + +sources/0206_assign_add.c + + 1 int x; + 2 x = 2 + 5; + +Output: [ x in {7} ] + +------------------------------------- + +sources/0207_assign_add2.c + + 1 int x; + 2 x = rand(1,5) + rand (10,10); + +Output: [ x in top ] + +------------------------------------- + +sources/0208_assign_add3.c + + 1 int x; + 2 x = x + 2; + +Output: [ x in top ] + +------------------------------------- + +sources/0209_assign_neg.c + + 1 int x; + 2 x = -9; + +Output: [ x in {-9} ] + +------------------------------------- + +sources/0210_assign_neg2.c + + 1 int x; + 2 x = -rand(-1,10); + 3 + +Output: [ x in top ] + +------------------------------------- + +sources/0211_assign_sub.c + + 1 int x; + 2 x = 999 - 1; + +Output: [ x in {998} ] + +------------------------------------- + +sources/0212_assign_sub2.c + + 1 int x; + 2 x = rand(1,10) - rand(2,3); + +Output: [ x in top ] + +------------------------------------- + +sources/0213_assign_mul.c + + 1 int x; + 2 x = 5 * 8; + +Output: [ x in {40} ] + +------------------------------------- + +sources/0214_assign_mul2.c + + 1 int x; + 2 x = rand(1,3) * rand(2,9); + +Output: [ x in top ] + +------------------------------------- + +sources/0215_assign_mul3.c + + 1 int x; + 2 x = rand(-5,3) * rand(-1,10); + +Output: [ x in top ] + +------------------------------------- + +sources/0216_assign_mul4.c + + 1 int x; + 2 x = x * 0; + +Output: [ x in {0} ] + +------------------------------------- + +sources/0217_assign_copy.c + + 1 int x; + 2 int y; + 3 x = 12; + 4 y = x; + 5 print(y); + +sources/0217_assign_copy.c:5.0-9: [ y in {12} ] +Output: [ x in {12}, y in {12} ] + +------------------------------------- + +sources/0218_assign_rel.c + + 1 int x; + 2 int y; + 3 x = 15; + 4 y = x + 2; + 5 print(y); + +sources/0218_assign_rel.c:5.0-9: [ y in {17} ] +Output: [ x in {15}, y in {17} ] + +------------------------------------- + +sources/0219_assign_rel2.c + + 1 int x = rand(1,5); + 2 int y = rand(2,10); + 3 int z = x + 2*y; + +Output: [ x in top, y in top, z in top ] + +------------------------------------- + +sources/0300_if_true.c + + 1 int x = 1; + 2 if (1 <= 2) x = 9; + +Output: [ x in {9} ] + +------------------------------------- + +sources/0301_if_false.c + + 1 int x = 1; + 2 if (1 >= 2) x = 9; + +Output: [ x in {1} ] + +------------------------------------- + +sources/0302_if_both.c + + 1 int x = 1; + 2 if (rand(0,1) == 0) x = 9; + +Output: [ x in top ] + +------------------------------------- + +sources/0303_if_else_true.c + + 1 int x = 1; + 2 if (1 <= 2) x = 5; else x = 10; + +Output: [ x in {5} ] + +------------------------------------- + +sources/0304_if_else_false.c + + 1 int x = 1; + 2 if (1 >= 2) x = 5; else x = 10; + +Output: [ x in {10} ] + +------------------------------------- + +sources/0305_if_else_both.c + + 1 int x = 1; + 2 if (rand(0,1) == 0) x = 5; else x = 10; + +Output: [ x in top ] + +------------------------------------- + +sources/0306_if_rel.c + + 1 int x,y; + 2 if (rand(0,1) == 0) { x = 1; y = 3; } + 3 else { x = 2; y = 1; } + +Output: [ x in top, y in top ] + +------------------------------------- + +sources/0307_if_var.c + + 1 int x = rand(-10,20); + 2 if (x >= 0) { print(x); } + 3 else { print(x); } + +sources/0307_if_var.c:2.14-24: [ x in top ] +sources/0307_if_var.c:3.7-17: [ x in top ] +Output: [ x in top ] + +------------------------------------- + +sources/0308_if_var2.c + + 1 int x = rand(-20,10); + 2 if (x < 2) x = -x; + +Output: [ x in top ] + +------------------------------------- + +sources/0309_if_var_rel.c + + 1 int x = rand(-10,25); + 2 int y = rand(-15,20); + 3 if (x >= y) x = y; + +Output: [ x in top, y in top ] + +------------------------------------- + +sources/0310_cmp_le.c + + 1 int x = rand(10,20); + 2 int y = rand(15,30); + 3 if (x <= y) print(x,y); + +sources/0310_cmp_le.c:3.11-23: [ x in top, y in top ] +Output: [ x in top, y in top ] + +------------------------------------- + +sources/0311_cmp_le2.c + + 1 int x = rand(10,20); + 2 int y = rand(8,17); + 3 if (x <= y) print(x,y); + +sources/0311_cmp_le2.c:3.11-23: [ x in top, y in top ] +Output: [ x in top, y in top ] + +------------------------------------- + +sources/0312_cmp_le3.c + + 1 int y = rand(10,20); + 2 int x = rand(30,55); + 3 if (x <= y) print(x); + +sources/0312_cmp_le3.c:3.11-21: [ x in top ] +Output: [ x in top, y in top ] + +------------------------------------- + +sources/0313_cmp_lt.c + + 1 int x = rand(10,20); + 2 int y = rand(5,15); + 3 if (x < y) print(x,y); + +sources/0313_cmp_lt.c:3.10-22: [ x in top, y in top ] +Output: [ x in top, y in top ] + +------------------------------------- + +sources/0314_cmp_ge.c + + 1 int x = rand(10,20); + 2 int y = rand(15,30); + 3 if (x >= y) print(x,y); + +sources/0314_cmp_ge.c:3.11-23: [ x in top, y in top ] +Output: [ x in top, y in top ] + +------------------------------------- + +sources/0315_cmp_gt.c + + 1 int x = rand(10,20); + 2 int y = rand(15,30); + 3 if (x > y) print(x,y); + +sources/0315_cmp_gt.c:3.10-22: [ x in top, y in top ] +Output: [ x in top, y in top ] + +------------------------------------- + +sources/0316_cmp_eq.c + + 1 int x = rand(15,30); + 2 int y = rand(10,20); + 3 if (x == y) print(x,y); + +sources/0316_cmp_eq.c:3.11-23: [ x in top, y in top ] +Output: [ x in top, y in top ] + +------------------------------------- + +sources/0317_cmp_eq2.c + + 1 int x = rand(15,20); + 2 int y = rand(25,30); + 3 if (x == y) print(x,y); + +sources/0317_cmp_eq2.c:3.11-23: [ x in top, y in top ] +Output: [ x in top, y in top ] + +------------------------------------- + +sources/0318_cmp_ne.c + + 1 int x = rand(10,15); + 2 int y = rand(10,15); + 3 if (x != y) print(x,y); + +sources/0318_cmp_ne.c:3.11-23: [ x in top, y in top ] +Output: [ x in top, y in top ] + +------------------------------------- + +sources/0319_cmp_ne.c + + 1 int x = rand(10,15); + 2 int y = 10; + 3 if (x != y) print(x,y); + +sources/0319_cmp_ne.c:3.11-23: [ x in top, y in {10} ] +Output: [ x in top, y in {10} ] + +------------------------------------- + +sources/0320_cmp_eq_ne.c + + 1 int x = rand(10,15); + 2 int y = 10; + 3 if (x == y) print(x,y); + 4 else print(x,y); + 5 + +sources/0320_cmp_eq_ne.c:3.11-4.0: [ x in {10}, y in {10} ] +sources/0320_cmp_eq_ne.c:4.4-16: [ x in top, y in {10} ] +Output: [ x in top, y in {10} ] + +------------------------------------- + +sources/0321_cmp_rel.c + + 1 int x = rand(10,20); + 2 int y = x; + 3 if (x >= 15) { print(y); } + +sources/0321_cmp_rel.c:3.15-25: [ y in top ] +Output: [ x in top, y in top ] + +------------------------------------- + +sources/0322_if_and.c + + 1 int x = rand(10,20); + 2 int y = rand(30,40); + 3 if (x>=15 && y>=35) { print(x,y); } + 4 else { print(x,y); } + +sources/0322_if_and.c:3.22-34: [ x in top, y in top ] +sources/0322_if_and.c:4.7-19: [ x in top, y in top ] +Output: [ x in top, y in top ] + +------------------------------------- + +sources/0323_if_or.c + + 1 int x = rand(10,20); + 2 int y = rand(30,40); + 3 if (x>=15 || y>=35) { print(x,y); } + 4 else { print(x,y); } + +sources/0323_if_or.c:3.22-34: [ x in top, y in top ] +sources/0323_if_or.c:4.7-19: [ x in top, y in top ] +Output: [ x in top, y in top ] + +------------------------------------- + +sources/0324_if_not.c + + 1 int x = rand(10,20); + 2 int y = rand(30,40); + 3 if (!(x>=15) || y>=35) { print(x,y); } + 4 else { print(x,y); } + +sources/0324_if_not.c:3.25-37: [ x in top, y in top ] +sources/0324_if_not.c:4.7-19: [ x in top, y in top ] +Output: [ x in top, y in top ] + +------------------------------------- + +sources/0325_if_bool.c + + 1 int x = rand(10,20); + 2 int y = rand(10,20); + 3 if (x<=15 && y>=15 || x>=15 && y<=15) { print(x,y); } + 4 else { print(x,y); } + +sources/0325_if_bool.c:3.40-52: [ x in top, y in top ] +sources/0325_if_bool.c:4.7-19: [ x in top, y in top ] +Output: [ x in top, y in top ] + +------------------------------------- + +sources/0400_assert_true.c + + 1 int x = 2; + 2 assert(x>=1); + +Output: [ x in {2} ] + +------------------------------------- + +sources/0401_assert_false.c + + 1 int x = 9; + 2 assert (x < 5); + +sources/0401_assert_false.c:2.0-15: ERROR: assertion failure +Output: bottom + +------------------------------------- + +sources/0402_assert_both.c + + 1 int x = rand (-5,10); + 2 assert(x >= 0); + 3 assert(x > 0); + 4 + +sources/0402_assert_both.c:2.0-15: ERROR: assertion failure +sources/0402_assert_both.c:3.0-14: ERROR: assertion failure +Output: [ x in top ] + +------------------------------------- + +sources/0403_assert_both2.c + + 1 int x = rand (-5,10); + 2 assert(x > 0); + 3 assert(x >= 0); + +sources/0403_assert_both2.c:2.0-14: ERROR: assertion failure +sources/0403_assert_both2.c:3.0-15: ERROR: assertion failure +Output: [ x in top ] + +------------------------------------- + +sources/0404_assert_rel.c + + 1 int x,y; + 2 if (rand(0,1)==0) { x = 1; y = 1; } + 3 else { x = 3 ; y = 3; } + 4 assert(x==y); + +sources/0404_assert_rel.c:4.0-13: ERROR: assertion failure +Output: [ x in top, y in top ] + +------------------------------------- + +sources/0500_loop_count.c + + 1 int x = 0; + 2 while (x < 100) { + 3 print(x); + 4 x = x + 1; + 5 } + +sources/0500_loop_count.c:3.2-4.2: [ x in {0} ] +sources/0500_loop_count.c:3.2-4.2: [ x in {1} ] +sources/0500_loop_count.c:3.2-4.2: [ x in {2} ] +sources/0500_loop_count.c:3.2-4.2: [ x in top ] +Output: [ x in top ] + +------------------------------------- + +sources/0501_loop_infinite.c + + 1 int x = 0; + 2 while (x < 10) { + 3 print(x); + 4 } + +sources/0501_loop_infinite.c:3.2-4.0: [ x in {0} ] +sources/0501_loop_infinite.c:3.2-4.0: [ x in {0} ] +sources/0501_loop_infinite.c:3.2-4.0: [ x in {0} ] +sources/0501_loop_infinite.c:3.2-4.0: [ x in {0} ] +Output: bottom + +------------------------------------- + +sources/0502_loop_infinite2.c + + 1 int x = 0; + 2 while (x < 100) { + 3 print(x); + 4 x = x - 1; + 5 } + +sources/0502_loop_infinite2.c:3.2-4.2: [ x in {0} ] +sources/0502_loop_infinite2.c:3.2-4.2: [ x in {-1} ] +sources/0502_loop_infinite2.c:3.2-4.2: [ x in {-2} ] +sources/0502_loop_infinite2.c:3.2-4.2: [ x in top ] +Output: [ x in top ] + +------------------------------------- + +sources/0503_loop_nondet.c + + 1 int x = 0; + 2 while (rand(0,1) == 0) { + 3 print(x); + 4 x = x + 1; + 5 } + +sources/0503_loop_nondet.c:3.2-4.2: [ x in {0} ] +sources/0503_loop_nondet.c:3.2-4.2: [ x in {1} ] +sources/0503_loop_nondet.c:3.2-4.2: [ x in {2} ] +sources/0503_loop_nondet.c:3.2-4.2: [ x in top ] +Output: [ x in top ] + +------------------------------------- + +sources/0504_loop_rel.c + + 1 int N = rand(0,1000); + 2 int x = 0; + 3 while (x < N) { + 4 print(x,N); + 5 x = x + 1; + 6 } + 7 assert(x==N); + +sources/0504_loop_rel.c:4.2-5.2: [ x in {0}, N in top ] +sources/0504_loop_rel.c:4.2-5.2: [ x in {1}, N in top ] +sources/0504_loop_rel.c:4.2-5.2: [ x in {2}, N in top ] +sources/0504_loop_rel.c:4.2-5.2: [ x in top, N in top ] +sources/0504_loop_rel.c:7.0-13: ERROR: assertion failure +Output: [ N in top, x in top ] + +------------------------------------- + +sources/0505_loop_rel2.c + + 1 int N = rand(0,1000); + 2 int x = 0; + 3 while (x < N) { + 4 print(x,N); + 5 x = x + rand(0,3); + 6 } + 7 assert(x>=N && x= 0); +14 } + +sources/0508_loop_init.c:13.2-14.0: ERROR: assertion failure +Output: [ init in top, x in top ] + +------------------------------------- + +sources/0509_loop_nested.c + + 1 int i=0, j=0; + 2 + 3 while (i < 1000) { + 4 j = 0; + 5 while (j < i) { + 6 j = j + 1; + 7 } + 8 i = i + 1; + 9 } + +Output: [ i in top, j in top ] + +------------------------------------- + +sources/0510_loop_nested2.c + + 1 int i,j; + 2 + 3 i = 0; + 4 while (i < 1000) { + 5 j = 0; + 6 while (j < i) { + 7 j = j + 1; + 8 } + 9 i = i + 1; +10 } + +Output: [ i in top, j in top ] + +------------------------------------- + +sources/0600_bubble_sort.c + + 1 // Example from Cousot Habwachs POPL 1978 + 2 + 3 // Bubble sort, where array operations are abstracted away + 4 // to get a non-deterministic scalar program + 5 + 6 // expected results: + 7 // - with polyhedra, no assertion failure (proof of absence of array overflow) + 8 // - with intervals, assertion failure + 9 +10 int B,J,T; +11 int N = rand(0,100000); // array size +12 +13 B = N; +14 while (B >= 1) { +15 J = 1; +16 T = 0; +17 while (J <= B-1) { +18 +19 // array bound-check +20 assert(1 <= J && J <= N); +21 assert(1 <= (J+1) && (J+1) <= N); +22 +23 // the non-deterministic test models comparing TAB[J] and TAB[J+1] +24 if (rand(0,1)==0) { +25 // where, we would exchange TAB[J] and TAB[J+1]; +26 T = J; +27 } +28 +29 J = J + 1; +30 } +31 B = T; +32 } + +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +Output: [ B in top, J in top, N in top, T in top ] + +------------------------------------- + +sources/0601_heap_sort.c + + 1 // Example from Cousot Habwachs POPL 1978 + 2 + 3 // Heap sort, where array operations are abstracted away + 4 // to get a non-deterministic scalar program + 5 + 6 // expected results: with polyhedra, no assertion failure + 7 + 8 int L,R,I,J; + 9 int N = rand(1,100000); // array size +10 +11 L = N/2 + 1; +12 R = N; +13 +14 if (L >= 2) { +15 L = L - 1; +16 // model the assignment "K = TAB[L]" +17 assert(1 <= L && L <= N); +18 } +19 else { +20 // model the assignments "K = TAB[R]; TAB[R] = TAB[1]" +21 assert(1 <= R && R <= N); +22 assert(1 <= 1 && 1 <= N); +23 R = R - 1; +24 } +25 +26 while (R >= 2) { +27 I = L; +28 J = 2*I; +29 +30 while (J <= R && rand(0,1)==0) { +31 if (J <= R-1) { +32 // model the comparison "TAB[J] < TAB[J+1]" +33 assert(1 <= J && J <= N); +34 assert(1 <= (J+1) && (J+1) <= N); +35 if (rand(0,1)==0) { J = J + 1; } +36 } +37 +38 // model the comparison "K < TAB[J]" +39 assert(1 <= J && J <= N); +40 if (rand(0,1)==0) { +41 // model the assignment "TAB[I] = TAB[J]" +42 assert(1 <= I && I <= N); +43 assert(1 <= J && J <= N); +44 I = J; +45 J = 2*J; +46 } +47 } +48 +49 // model the assignment "TAB[I] = K" +50 assert(1 <= I && I <= N); +51 +52 if (L >= 2) { +53 L = L - 1; +54 // model the assignment "K = TAB[L]" +55 assert(1 <= L && L <= N); +56 } +57 else { +58 // model the assignments "K = TAB[R]; TAB[R] = TAB[1]" +59 assert(1 <= R && R <= N); +60 assert(1 <= 1 && 1 <= N); +61 R = R - 1; +62 } +63 +64 // model the assignment "TAB[1] = K" +65 assert(1 <= 1 && 1 <= N); +66 } + +sources/0601_heap_sort.c:17.2-18.0: ERROR: assertion failure +sources/0601_heap_sort.c:21.3-22.3: ERROR: assertion failure +sources/0601_heap_sort.c:22.3-23.3: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:50.2-52.2: ERROR: assertion failure +sources/0601_heap_sort.c:55.4-56.2: ERROR: assertion failure +sources/0601_heap_sort.c:59.4-60.4: ERROR: assertion failure +sources/0601_heap_sort.c:60.4-61.4: ERROR: assertion failure +sources/0601_heap_sort.c:65.2-66.0: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:50.2-52.2: ERROR: assertion failure +sources/0601_heap_sort.c:55.4-56.2: ERROR: assertion failure +sources/0601_heap_sort.c:59.4-60.4: ERROR: assertion failure +sources/0601_heap_sort.c:60.4-61.4: ERROR: assertion failure +sources/0601_heap_sort.c:65.2-66.0: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:50.2-52.2: ERROR: assertion failure +sources/0601_heap_sort.c:55.4-56.2: ERROR: assertion failure +sources/0601_heap_sort.c:59.4-60.4: ERROR: assertion failure +sources/0601_heap_sort.c:60.4-61.4: ERROR: assertion failure +sources/0601_heap_sort.c:65.2-66.0: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:50.2-52.2: ERROR: assertion failure +sources/0601_heap_sort.c:55.4-56.2: ERROR: assertion failure +sources/0601_heap_sort.c:59.4-60.4: ERROR: assertion failure +sources/0601_heap_sort.c:60.4-61.4: ERROR: assertion failure +sources/0601_heap_sort.c:65.2-66.0: ERROR: assertion failure +Output: [ I in top, J in top, L in top, N in top, R in top ] + +------------------------------------- + +sources/0602_rate_limiter.c + + 1 // Example from Miné HOSC 2006 + 2 + 3 // Rate limiter: at each loop iteration, a new input is fetched (X) and + 4 // a new output (Y) is computed; Y tries to follow X but is limited to + 5 // change no more that a given slope (D) in absolute value + 6 + 7 // To prove that the assertion holds, this version needs the polyhedra + 8 // domain and an unrolling factor of at least 6 + 9 +10 int X; // input +11 int Y; // output +12 int S; // last output +13 int D; // maximum slope; +14 +15 Y = 0; +16 while (rand(0,1)==1) { +17 X = rand(-128,128); +18 D = rand(0,16); +19 S = Y; +20 int R = X - S; // current slope +21 Y = X; +22 if (R <= -D) Y = S - D; // slope too small +23 else if (R >= D) Y = S + D; // slope too large +24 } +25 +26 assert(Y >= -128 && Y <= 128); + +sources/0602_rate_limiter.c:26.0-30: ERROR: assertion failure +Output: [ D in top, S in top, X in top, Y in top ] + +------------------------------------- + +sources/0603_rate_limiter2.c + + 1 // This version is similar to the previous one, but the assertion is checked + 2 // inside the loop + 3 // No unrolling is necessary in this version! + 4 + 5 int X; // input + 6 int Y; // output + 7 int S; // last output + 8 int D; // maximum slope; + 9 +10 Y = 0; +11 while (rand(0,1)==1) { +12 X = rand(-128,128); +13 D = rand(0,16); +14 S = Y; +15 int R = X - S; // current slope +16 Y = X; +17 if (R <= -D) Y = S - D; // slope too small +18 else if (R >= D) Y = S + D; // slope too large +19 +20 assert(Y >= -128 && Y <= 128); +21 } + +sources/0603_rate_limiter2.c:20.2-21.0: ERROR: assertion failure +sources/0603_rate_limiter2.c:20.2-21.0: ERROR: assertion failure +sources/0603_rate_limiter2.c:20.2-21.0: ERROR: assertion failure +sources/0603_rate_limiter2.c:20.2-21.0: ERROR: assertion failure +Output: [ D in top, S in top, X in top, Y in top ] + +------------------------------------- + diff --git a/tests/results/all.intervals.txt b/tests/results/all.intervals.txt new file mode 100644 index 0000000..8e7dd94 --- /dev/null +++ b/tests/results/all.intervals.txt @@ -0,0 +1,1115 @@ +sources/0000_noinit_var.c + + 1 int x; + +Output: [ x in [-oo;+oo] ] + +------------------------------------- + +sources/0001_noinit_2var.c + + 1 int x; + 2 int y; + +Output: [ x in [-oo;+oo], y in [-oo;+oo] ] + +------------------------------------- + +sources/0002_init_var.c + + 1 int x = 0; + +Output: [ x in [0;0] ] + +------------------------------------- + +sources/0003_init_2var.c + + 1 int x = 0; + 2 int y = 1; + +Output: [ x in [0;0], y in [1;1] ] + +------------------------------------- + +sources/0004_init_2var2.c + + 1 int x = 9, y = 12; + +Output: [ x in [9;9], y in [12;12] ] + +------------------------------------- + +sources/0100_print_var.c + + 1 int x = 2; + 2 print(x); + +sources/0100_print_var.c:2.0-9: [ x in [2;2] ] +Output: [ x in [2;2] ] + +------------------------------------- + +sources/0101_print_2var.c + + 1 int x = 3; + 2 int y = 15; + 3 print(y); + +sources/0101_print_2var.c:3.0-9: [ y in [15;15] ] +Output: [ x in [3;3], y in [15;15] ] + +------------------------------------- + +sources/0102_print_3var.c + + 1 int x = 3; + 2 int y = 15; + 3 int z = 99; + 4 print(z,x); + +sources/0102_print_3var.c:4.0-11: [ z in [99;99], x in [3;3] ] +Output: [ x in [3;3], y in [15;15], z in [99;99] ] + +------------------------------------- + +sources/0103_local.c + + 1 int x = 12; + 2 { + 3 int y = 9; + 4 print(x,y); + 5 } + +sources/0103_local.c:4.2-5.0: [ x in [12;12], y in [9;9] ] +Output: [ x in [12;12] ] + +------------------------------------- + +sources/0200_assign_cst.c + + 1 int x; + 2 print(x); + 3 x = 12; + 4 print(x); + 5 x = 15; + 6 print(x); + +sources/0200_assign_cst.c:2.0-9: [ x in [-oo;+oo] ] +sources/0200_assign_cst.c:4.0-9: [ x in [12;12] ] +sources/0200_assign_cst.c:6.0-9: [ x in [15;15] ] +Output: [ x in [15;15] ] + +------------------------------------- + +sources/0201_assign_cst2.c + + 1 int x, y; + 2 print(x,y); + 3 x = 12; + 4 print(x,y); + 5 y = 15; + 6 x = 99; + 7 print(x,y); + +sources/0201_assign_cst2.c:2.0-11: [ x in [-oo;+oo], y in [-oo;+oo] ] +sources/0201_assign_cst2.c:4.0-11: [ x in [12;12], y in [-oo;+oo] ] +sources/0201_assign_cst2.c:7.0-11: [ x in [99;99], y in [15;15] ] +Output: [ x in [99;99], y in [15;15] ] + +------------------------------------- + +sources/0202_assign_expr.c + + 1 int x; + 2 x = 2 + 2; + +Output: [ x in [4;4] ] + +------------------------------------- + +sources/0203_assign_expr2.c + + 1 int x,y; + 2 x = 12; + 3 y = 16; + 4 x = x + y + 2; + 5 print(x); + +sources/0203_assign_expr2.c:5.0-9: [ x in [30;30] ] +Output: [ x in [30;30], y in [16;16] ] + +------------------------------------- + +sources/0204_assign_rand.c + + 1 int x; + 2 x = rand(1,99); + 3 print(x); + +sources/0204_assign_rand.c:3.0-9: [ x in [1;99] ] +Output: [ x in [1;99] ] + +------------------------------------- + +sources/0205_assign_rand2.c + + 1 int x; + 2 x = rand(10,-5); + 3 print(x); + +sources/0205_assign_rand2.c:3.0-9: bottom +Output: bottom + +------------------------------------- + +sources/0206_assign_add.c + + 1 int x; + 2 x = 2 + 5; + +Output: [ x in [7;7] ] + +------------------------------------- + +sources/0207_assign_add2.c + + 1 int x; + 2 x = rand(1,5) + rand (10,10); + +Output: [ x in [11;15] ] + +------------------------------------- + +sources/0208_assign_add3.c + + 1 int x; + 2 x = x + 2; + +Output: [ x in [-oo;+oo] ] + +------------------------------------- + +sources/0209_assign_neg.c + + 1 int x; + 2 x = -9; + +Output: [ x in [-9;-9] ] + +------------------------------------- + +sources/0210_assign_neg2.c + + 1 int x; + 2 x = -rand(-1,10); + 3 + +Output: [ x in [-10;1] ] + +------------------------------------- + +sources/0211_assign_sub.c + + 1 int x; + 2 x = 999 - 1; + +Output: [ x in [998;998] ] + +------------------------------------- + +sources/0212_assign_sub2.c + + 1 int x; + 2 x = rand(1,10) - rand(2,3); + +Output: [ x in [-2;8] ] + +------------------------------------- + +sources/0213_assign_mul.c + + 1 int x; + 2 x = 5 * 8; + +Output: [ x in [40;40] ] + +------------------------------------- + +sources/0214_assign_mul2.c + + 1 int x; + 2 x = rand(1,3) * rand(2,9); + +Output: [ x in [2;27] ] + +------------------------------------- + +sources/0215_assign_mul3.c + + 1 int x; + 2 x = rand(-5,3) * rand(-1,10); + +Output: [ x in [-50;30] ] + +------------------------------------- + +sources/0216_assign_mul4.c + + 1 int x; + 2 x = x * 0; + +Output: [ x in [0;0] ] + +------------------------------------- + +sources/0217_assign_copy.c + + 1 int x; + 2 int y; + 3 x = 12; + 4 y = x; + 5 print(y); + +sources/0217_assign_copy.c:5.0-9: [ y in [12;12] ] +Output: [ x in [12;12], y in [12;12] ] + +------------------------------------- + +sources/0218_assign_rel.c + + 1 int x; + 2 int y; + 3 x = 15; + 4 y = x + 2; + 5 print(y); + +sources/0218_assign_rel.c:5.0-9: [ y in [17;17] ] +Output: [ x in [15;15], y in [17;17] ] + +------------------------------------- + +sources/0219_assign_rel2.c + + 1 int x = rand(1,5); + 2 int y = rand(2,10); + 3 int z = x + 2*y; + +Output: [ x in [1;5], y in [2;10], z in [5;25] ] + +------------------------------------- + +sources/0300_if_true.c + + 1 int x = 1; + 2 if (1 <= 2) x = 9; + +Output: [ x in [9;9] ] + +------------------------------------- + +sources/0301_if_false.c + + 1 int x = 1; + 2 if (1 >= 2) x = 9; + +Output: [ x in [1;1] ] + +------------------------------------- + +sources/0302_if_both.c + + 1 int x = 1; + 2 if (rand(0,1) == 0) x = 9; + +Output: [ x in [1;9] ] + +------------------------------------- + +sources/0303_if_else_true.c + + 1 int x = 1; + 2 if (1 <= 2) x = 5; else x = 10; + +Output: [ x in [5;5] ] + +------------------------------------- + +sources/0304_if_else_false.c + + 1 int x = 1; + 2 if (1 >= 2) x = 5; else x = 10; + +Output: [ x in [10;10] ] + +------------------------------------- + +sources/0305_if_else_both.c + + 1 int x = 1; + 2 if (rand(0,1) == 0) x = 5; else x = 10; + +Output: [ x in [5;10] ] + +------------------------------------- + +sources/0306_if_rel.c + + 1 int x,y; + 2 if (rand(0,1) == 0) { x = 1; y = 3; } + 3 else { x = 2; y = 1; } + +Output: [ x in [1;2], y in [1;3] ] + +------------------------------------- + +sources/0307_if_var.c + + 1 int x = rand(-10,20); + 2 if (x >= 0) { print(x); } + 3 else { print(x); } + +sources/0307_if_var.c:2.14-24: [ x in [0;20] ] +sources/0307_if_var.c:3.7-17: [ x in [-10;-1] ] +Output: [ x in [-10;20] ] + +------------------------------------- + +sources/0308_if_var2.c + + 1 int x = rand(-20,10); + 2 if (x < 2) x = -x; + +Output: [ x in [-1;20] ] + +------------------------------------- + +sources/0309_if_var_rel.c + + 1 int x = rand(-10,25); + 2 int y = rand(-15,20); + 3 if (x >= y) x = y; + +Output: [ x in [-15;20], y in [-15;20] ] + +------------------------------------- + +sources/0310_cmp_le.c + + 1 int x = rand(10,20); + 2 int y = rand(15,30); + 3 if (x <= y) print(x,y); + +sources/0310_cmp_le.c:3.11-23: [ x in [10;20], y in [15;30] ] +Output: [ x in [10;20], y in [15;30] ] + +------------------------------------- + +sources/0311_cmp_le2.c + + 1 int x = rand(10,20); + 2 int y = rand(8,17); + 3 if (x <= y) print(x,y); + +sources/0311_cmp_le2.c:3.11-23: [ x in [10;17], y in [10;17] ] +Output: [ x in [10;20], y in [8;17] ] + +------------------------------------- + +sources/0312_cmp_le3.c + + 1 int y = rand(10,20); + 2 int x = rand(30,55); + 3 if (x <= y) print(x); + +sources/0312_cmp_le3.c:3.11-21: bottom +Output: [ x in [30;55], y in [10;20] ] + +------------------------------------- + +sources/0313_cmp_lt.c + + 1 int x = rand(10,20); + 2 int y = rand(5,15); + 3 if (x < y) print(x,y); + +sources/0313_cmp_lt.c:3.10-22: [ x in [10;14], y in [11;15] ] +Output: [ x in [10;20], y in [5;15] ] + +------------------------------------- + +sources/0314_cmp_ge.c + + 1 int x = rand(10,20); + 2 int y = rand(15,30); + 3 if (x >= y) print(x,y); + +sources/0314_cmp_ge.c:3.11-23: [ x in [15;20], y in [15;20] ] +Output: [ x in [10;20], y in [15;30] ] + +------------------------------------- + +sources/0315_cmp_gt.c + + 1 int x = rand(10,20); + 2 int y = rand(15,30); + 3 if (x > y) print(x,y); + +sources/0315_cmp_gt.c:3.10-22: [ x in [16;20], y in [15;19] ] +Output: [ x in [10;20], y in [15;30] ] + +------------------------------------- + +sources/0316_cmp_eq.c + + 1 int x = rand(15,30); + 2 int y = rand(10,20); + 3 if (x == y) print(x,y); + +sources/0316_cmp_eq.c:3.11-23: [ x in [15;20], y in [15;20] ] +Output: [ x in [15;30], y in [10;20] ] + +------------------------------------- + +sources/0317_cmp_eq2.c + + 1 int x = rand(15,20); + 2 int y = rand(25,30); + 3 if (x == y) print(x,y); + +sources/0317_cmp_eq2.c:3.11-23: bottom +Output: [ x in [15;20], y in [25;30] ] + +------------------------------------- + +sources/0318_cmp_ne.c + + 1 int x = rand(10,15); + 2 int y = rand(10,15); + 3 if (x != y) print(x,y); + +sources/0318_cmp_ne.c:3.11-23: [ x in [10;15], y in [10;15] ] +Output: [ x in [10;15], y in [10;15] ] + +------------------------------------- + +sources/0319_cmp_ne.c + + 1 int x = rand(10,15); + 2 int y = 10; + 3 if (x != y) print(x,y); + +sources/0319_cmp_ne.c:3.11-23: [ x in [11;15], y in [10;10] ] +Output: [ x in [10;15], y in [10;10] ] + +------------------------------------- + +sources/0320_cmp_eq_ne.c + + 1 int x = rand(10,15); + 2 int y = 10; + 3 if (x == y) print(x,y); + 4 else print(x,y); + 5 + +sources/0320_cmp_eq_ne.c:3.11-4.0: [ x in [10;10], y in [10;10] ] +sources/0320_cmp_eq_ne.c:4.4-16: [ x in [11;15], y in [10;10] ] +Output: [ x in [10;15], y in [10;10] ] + +------------------------------------- + +sources/0321_cmp_rel.c + + 1 int x = rand(10,20); + 2 int y = x; + 3 if (x >= 15) { print(y); } + +sources/0321_cmp_rel.c:3.15-25: [ y in [10;20] ] +Output: [ x in [10;20], y in [10;20] ] + +------------------------------------- + +sources/0322_if_and.c + + 1 int x = rand(10,20); + 2 int y = rand(30,40); + 3 if (x>=15 && y>=35) { print(x,y); } + 4 else { print(x,y); } + +sources/0322_if_and.c:3.22-34: [ x in [15;20], y in [35;40] ] +sources/0322_if_and.c:4.7-19: [ x in [10;20], y in [30;40] ] +Output: [ x in [10;20], y in [30;40] ] + +------------------------------------- + +sources/0323_if_or.c + + 1 int x = rand(10,20); + 2 int y = rand(30,40); + 3 if (x>=15 || y>=35) { print(x,y); } + 4 else { print(x,y); } + +sources/0323_if_or.c:3.22-34: [ x in [10;20], y in [30;40] ] +sources/0323_if_or.c:4.7-19: [ x in [10;14], y in [30;34] ] +Output: [ x in [10;20], y in [30;40] ] + +------------------------------------- + +sources/0324_if_not.c + + 1 int x = rand(10,20); + 2 int y = rand(30,40); + 3 if (!(x>=15) || y>=35) { print(x,y); } + 4 else { print(x,y); } + +sources/0324_if_not.c:3.25-37: [ x in [10;20], y in [30;40] ] +sources/0324_if_not.c:4.7-19: [ x in [15;20], y in [30;34] ] +Output: [ x in [10;20], y in [30;40] ] + +------------------------------------- + +sources/0325_if_bool.c + + 1 int x = rand(10,20); + 2 int y = rand(10,20); + 3 if (x<=15 && y>=15 || x>=15 && y<=15) { print(x,y); } + 4 else { print(x,y); } + +sources/0325_if_bool.c:3.40-52: [ x in [10;20], y in [10;20] ] +sources/0325_if_bool.c:4.7-19: [ x in [10;20], y in [10;20] ] +Output: [ x in [10;20], y in [10;20] ] + +------------------------------------- + +sources/0400_assert_true.c + + 1 int x = 2; + 2 assert(x>=1); + +Output: [ x in [2;2] ] + +------------------------------------- + +sources/0401_assert_false.c + + 1 int x = 9; + 2 assert (x < 5); + +sources/0401_assert_false.c:2.0-15: ERROR: assertion failure +Output: bottom + +------------------------------------- + +sources/0402_assert_both.c + + 1 int x = rand (-5,10); + 2 assert(x >= 0); + 3 assert(x > 0); + 4 + +sources/0402_assert_both.c:2.0-15: ERROR: assertion failure +sources/0402_assert_both.c:3.0-14: ERROR: assertion failure +Output: [ x in [1;10] ] + +------------------------------------- + +sources/0403_assert_both2.c + + 1 int x = rand (-5,10); + 2 assert(x > 0); + 3 assert(x >= 0); + +sources/0403_assert_both2.c:2.0-14: ERROR: assertion failure +Output: [ x in [1;10] ] + +------------------------------------- + +sources/0404_assert_rel.c + + 1 int x,y; + 2 if (rand(0,1)==0) { x = 1; y = 1; } + 3 else { x = 3 ; y = 3; } + 4 assert(x==y); + +sources/0404_assert_rel.c:4.0-13: ERROR: assertion failure +Output: [ x in [1;3], y in [1;3] ] + +------------------------------------- + +sources/0500_loop_count.c + + 1 int x = 0; + 2 while (x < 100) { + 3 print(x); + 4 x = x + 1; + 5 } + +sources/0500_loop_count.c:3.2-4.2: [ x in [0;0] ] +sources/0500_loop_count.c:3.2-4.2: [ x in [1;1] ] +sources/0500_loop_count.c:3.2-4.2: [ x in [2;2] ] +sources/0500_loop_count.c:3.2-4.2: [ x in [3;99] ] +Output: [ x in [100;100] ] + +------------------------------------- + +sources/0501_loop_infinite.c + + 1 int x = 0; + 2 while (x < 10) { + 3 print(x); + 4 } + +sources/0501_loop_infinite.c:3.2-4.0: [ x in [0;0] ] +sources/0501_loop_infinite.c:3.2-4.0: [ x in [0;0] ] +sources/0501_loop_infinite.c:3.2-4.0: [ x in [0;0] ] +sources/0501_loop_infinite.c:3.2-4.0: [ x in [0;0] ] +Output: bottom + +------------------------------------- + +sources/0502_loop_infinite2.c + + 1 int x = 0; + 2 while (x < 100) { + 3 print(x); + 4 x = x - 1; + 5 } + +sources/0502_loop_infinite2.c:3.2-4.2: [ x in [0;0] ] +sources/0502_loop_infinite2.c:3.2-4.2: [ x in [-1;-1] ] +sources/0502_loop_infinite2.c:3.2-4.2: [ x in [-2;-2] ] +sources/0502_loop_infinite2.c:3.2-4.2: [ x in [-oo;-3] ] +Output: bottom + +------------------------------------- + +sources/0503_loop_nondet.c + + 1 int x = 0; + 2 while (rand(0,1) == 0) { + 3 print(x); + 4 x = x + 1; + 5 } + +sources/0503_loop_nondet.c:3.2-4.2: [ x in [0;0] ] +sources/0503_loop_nondet.c:3.2-4.2: [ x in [1;1] ] +sources/0503_loop_nondet.c:3.2-4.2: [ x in [2;2] ] +sources/0503_loop_nondet.c:3.2-4.2: [ x in [3;+oo] ] +Output: [ x in [0;+oo] ] + +------------------------------------- + +sources/0504_loop_rel.c + + 1 int N = rand(0,1000); + 2 int x = 0; + 3 while (x < N) { + 4 print(x,N); + 5 x = x + 1; + 6 } + 7 assert(x==N); + +sources/0504_loop_rel.c:4.2-5.2: [ x in [0;0], N in [1;1000] ] +sources/0504_loop_rel.c:4.2-5.2: [ x in [1;1], N in [2;1000] ] +sources/0504_loop_rel.c:4.2-5.2: [ x in [2;2], N in [3;1000] ] +sources/0504_loop_rel.c:4.2-5.2: [ x in [3;999], N in [4;1000] ] +sources/0504_loop_rel.c:7.0-13: ERROR: assertion failure +Output: [ N in [0;1000], x in [0;1000] ] + +------------------------------------- + +sources/0505_loop_rel2.c + + 1 int N = rand(0,1000); + 2 int x = 0; + 3 while (x < N) { + 4 print(x,N); + 5 x = x + rand(0,3); + 6 } + 7 assert(x>=N && x= 0); +14 } + +Output: [ init in [0;1], x in [-oo;+oo] ] + +------------------------------------- + +sources/0509_loop_nested.c + + 1 int i=0, j=0; + 2 + 3 while (i < 1000) { + 4 j = 0; + 5 while (j < i) { + 6 j = j + 1; + 7 } + 8 i = i + 1; + 9 } + +Output: [ i in [1000;1000], j in [2;999] ] + +------------------------------------- + +sources/0510_loop_nested2.c + + 1 int i,j; + 2 + 3 i = 0; + 4 while (i < 1000) { + 5 j = 0; + 6 while (j < i) { + 7 j = j + 1; + 8 } + 9 i = i + 1; +10 } + +Output: [ i in [1000;1000], j in [2;999] ] + +------------------------------------- + +sources/0600_bubble_sort.c + + 1 // Example from Cousot Habwachs POPL 1978 + 2 + 3 // Bubble sort, where array operations are abstracted away + 4 // to get a non-deterministic scalar program + 5 + 6 // expected results: + 7 // - with polyhedra, no assertion failure (proof of absence of array overflow) + 8 // - with intervals, assertion failure + 9 +10 int B,J,T; +11 int N = rand(0,100000); // array size +12 +13 B = N; +14 while (B >= 1) { +15 J = 1; +16 T = 0; +17 while (J <= B-1) { +18 +19 // array bound-check +20 assert(1 <= J && J <= N); +21 assert(1 <= (J+1) && (J+1) <= N); +22 +23 // the non-deterministic test models comparing TAB[J] and TAB[J+1] +24 if (rand(0,1)==0) { +25 // where, we would exchange TAB[J] and TAB[J+1]; +26 T = J; +27 } +28 +29 J = J + 1; +30 } +31 B = T; +32 } + +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +sources/0600_bubble_sort.c:20.4-21.4: ERROR: assertion failure +sources/0600_bubble_sort.c:21.4-24.4: ERROR: assertion failure +Output: [ B in [0;0], J in [-oo;+oo], N in [0;100000], T in [-oo;+oo] ] + +------------------------------------- + +sources/0601_heap_sort.c + + 1 // Example from Cousot Habwachs POPL 1978 + 2 + 3 // Heap sort, where array operations are abstracted away + 4 // to get a non-deterministic scalar program + 5 + 6 // expected results: with polyhedra, no assertion failure + 7 + 8 int L,R,I,J; + 9 int N = rand(1,100000); // array size +10 +11 L = N/2 + 1; +12 R = N; +13 +14 if (L >= 2) { +15 L = L - 1; +16 // model the assignment "K = TAB[L]" +17 assert(1 <= L && L <= N); +18 } +19 else { +20 // model the assignments "K = TAB[R]; TAB[R] = TAB[1]" +21 assert(1 <= R && R <= N); +22 assert(1 <= 1 && 1 <= N); +23 R = R - 1; +24 } +25 +26 while (R >= 2) { +27 I = L; +28 J = 2*I; +29 +30 while (J <= R && rand(0,1)==0) { +31 if (J <= R-1) { +32 // model the comparison "TAB[J] < TAB[J+1]" +33 assert(1 <= J && J <= N); +34 assert(1 <= (J+1) && (J+1) <= N); +35 if (rand(0,1)==0) { J = J + 1; } +36 } +37 +38 // model the comparison "K < TAB[J]" +39 assert(1 <= J && J <= N); +40 if (rand(0,1)==0) { +41 // model the assignment "TAB[I] = TAB[J]" +42 assert(1 <= I && I <= N); +43 assert(1 <= J && J <= N); +44 I = J; +45 J = 2*J; +46 } +47 } +48 +49 // model the assignment "TAB[I] = K" +50 assert(1 <= I && I <= N); +51 +52 if (L >= 2) { +53 L = L - 1; +54 // model the assignment "K = TAB[L]" +55 assert(1 <= L && L <= N); +56 } +57 else { +58 // model the assignments "K = TAB[R]; TAB[R] = TAB[1]" +59 assert(1 <= R && R <= N); +60 assert(1 <= 1 && 1 <= N); +61 R = R - 1; +62 } +63 +64 // model the assignment "TAB[1] = K" +65 assert(1 <= 1 && 1 <= N); +66 } + +sources/0601_heap_sort.c:17.2-18.0: ERROR: assertion failure +sources/0601_heap_sort.c:21.3-22.3: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:50.2-52.2: ERROR: assertion failure +sources/0601_heap_sort.c:55.4-56.2: ERROR: assertion failure +sources/0601_heap_sort.c:59.4-60.4: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:50.2-52.2: ERROR: assertion failure +sources/0601_heap_sort.c:55.4-56.2: ERROR: assertion failure +sources/0601_heap_sort.c:59.4-60.4: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:50.2-52.2: ERROR: assertion failure +sources/0601_heap_sort.c:55.4-56.2: ERROR: assertion failure +sources/0601_heap_sort.c:59.4-60.4: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:33.6-34.6: ERROR: assertion failure +sources/0601_heap_sort.c:34.6-35.6: ERROR: assertion failure +sources/0601_heap_sort.c:39.4-40.4: ERROR: assertion failure +sources/0601_heap_sort.c:42.6-43.6: ERROR: assertion failure +sources/0601_heap_sort.c:43.6-44.6: ERROR: assertion failure +sources/0601_heap_sort.c:50.2-52.2: ERROR: assertion failure +sources/0601_heap_sort.c:55.4-56.2: ERROR: assertion failure +sources/0601_heap_sort.c:59.4-60.4: ERROR: assertion failure +Output: [ I in [-oo;+oo], J in [-oo;+oo], L in [-oo;100000], N in [1;100000], R in [0;1] ] + +------------------------------------- + +sources/0602_rate_limiter.c + + 1 // Example from Miné HOSC 2006 + 2 + 3 // Rate limiter: at each loop iteration, a new input is fetched (X) and + 4 // a new output (Y) is computed; Y tries to follow X but is limited to + 5 // change no more that a given slope (D) in absolute value + 6 + 7 // To prove that the assertion holds, this version needs the polyhedra + 8 // domain and an unrolling factor of at least 6 + 9 +10 int X; // input +11 int Y; // output +12 int S; // last output +13 int D; // maximum slope; +14 +15 Y = 0; +16 while (rand(0,1)==1) { +17 X = rand(-128,128); +18 D = rand(0,16); +19 S = Y; +20 int R = X - S; // current slope +21 Y = X; +22 if (R <= -D) Y = S - D; // slope too small +23 else if (R >= D) Y = S + D; // slope too large +24 } +25 +26 assert(Y >= -128 && Y <= 128); + +sources/0602_rate_limiter.c:26.0-30: ERROR: assertion failure +Output: [ D in [-oo;+oo], S in [-oo;+oo], X in [-oo;+oo], Y in [-128;128] ] + +------------------------------------- + +sources/0603_rate_limiter2.c + + 1 // This version is similar to the previous one, but the assertion is checked + 2 // inside the loop + 3 // No unrolling is necessary in this version! + 4 + 5 int X; // input + 6 int Y; // output + 7 int S; // last output + 8 int D; // maximum slope; + 9 +10 Y = 0; +11 while (rand(0,1)==1) { +12 X = rand(-128,128); +13 D = rand(0,16); +14 S = Y; +15 int R = X - S; // current slope +16 Y = X; +17 if (R <= -D) Y = S - D; // slope too small +18 else if (R >= D) Y = S + D; // slope too large +19 +20 assert(Y >= -128 && Y <= 128); +21 } + +sources/0603_rate_limiter2.c:20.2-21.0: ERROR: assertion failure +sources/0603_rate_limiter2.c:20.2-21.0: ERROR: assertion failure +sources/0603_rate_limiter2.c:20.2-21.0: ERROR: assertion failure +Output: [ D in [-oo;+oo], S in [-oo;+oo], X in [-oo;+oo], Y in [-128;128] ] + +------------------------------------- + diff --git a/tests/results/all.polyhedra.txt b/tests/results/all.polyhedra.txt new file mode 100644 index 0000000..65a3b93 --- /dev/null +++ b/tests/results/all.polyhedra.txt @@ -0,0 +1,998 @@ +sources/0000_noinit_var.c + + 1 int x; + +Output: top + +------------------------------------- + +sources/0001_noinit_2var.c + + 1 int x; + 2 int y; + +Output: top + +------------------------------------- + +sources/0002_init_var.c + + 1 int x = 0; + +Output: [|x=0|] + +------------------------------------- + +sources/0003_init_2var.c + + 1 int x = 0; + 2 int y = 1; + +Output: [|y-1=0; x=0|] + +------------------------------------- + +sources/0004_init_2var2.c + + 1 int x = 9, y = 12; + +Output: [|y-12=0; x-9=0|] + +------------------------------------- + +sources/0100_print_var.c + + 1 int x = 2; + 2 print(x); + +sources/0100_print_var.c:2.0-9: [|x-2=0|] +Output: [|x-2=0|] + +------------------------------------- + +sources/0101_print_2var.c + + 1 int x = 3; + 2 int y = 15; + 3 print(y); + +sources/0101_print_2var.c:3.0-9: [|y-15=0|] +Output: [|y-15=0; x-3=0|] + +------------------------------------- + +sources/0102_print_3var.c + + 1 int x = 3; + 2 int y = 15; + 3 int z = 99; + 4 print(z,x); + +sources/0102_print_3var.c:4.0-11: [|z-99=0; x-3=0|] +Output: [|z-99=0; y-15=0; x-3=0|] + +------------------------------------- + +sources/0103_local.c + + 1 int x = 12; + 2 { + 3 int y = 9; + 4 print(x,y); + 5 } + +sources/0103_local.c:4.2-5.0: [|y-9=0; x-12=0|] +Output: [|x-12=0|] + +------------------------------------- + +sources/0200_assign_cst.c + + 1 int x; + 2 print(x); + 3 x = 12; + 4 print(x); + 5 x = 15; + 6 print(x); + +sources/0200_assign_cst.c:2.0-9: top +sources/0200_assign_cst.c:4.0-9: [|x-12=0|] +sources/0200_assign_cst.c:6.0-9: [|x-15=0|] +Output: [|x-15=0|] + +------------------------------------- + +sources/0201_assign_cst2.c + + 1 int x, y; + 2 print(x,y); + 3 x = 12; + 4 print(x,y); + 5 y = 15; + 6 x = 99; + 7 print(x,y); + +sources/0201_assign_cst2.c:2.0-11: top +sources/0201_assign_cst2.c:4.0-11: [|x-12=0|] +sources/0201_assign_cst2.c:7.0-11: [|y-15=0; x-99=0|] +Output: [|y-15=0; x-99=0|] + +------------------------------------- + +sources/0202_assign_expr.c + + 1 int x; + 2 x = 2 + 2; + +Output: [|x-4=0|] + +------------------------------------- + +sources/0203_assign_expr2.c + + 1 int x,y; + 2 x = 12; + 3 y = 16; + 4 x = x + y + 2; + 5 print(x); + +sources/0203_assign_expr2.c:5.0-9: [|x-30=0|] +Output: [|y-16=0; x-30=0|] + +------------------------------------- + +sources/0204_assign_rand.c + + 1 int x; + 2 x = rand(1,99); + 3 print(x); + +sources/0204_assign_rand.c:3.0-9: [|-x+99>=0; x-1>=0|] +Output: [|-x+99>=0; x-1>=0|] + +------------------------------------- + +sources/0205_assign_rand2.c + + 1 int x; + 2 x = rand(10,-5); + 3 print(x); + +sources/0205_assign_rand2.c:3.0-9: bottom +Output: bottom + +------------------------------------- + +sources/0206_assign_add.c + + 1 int x; + 2 x = 2 + 5; + +Output: [|x-7=0|] + +------------------------------------- + +sources/0207_assign_add2.c + + 1 int x; + 2 x = rand(1,5) + rand (10,10); + +Output: [|-x+15>=0; x-11>=0|] + +------------------------------------- + +sources/0208_assign_add3.c + + 1 int x; + 2 x = x + 2; + +Output: top + +------------------------------------- + +sources/0209_assign_neg.c + + 1 int x; + 2 x = -9; + +Output: [|x+9=0|] + +------------------------------------- + +sources/0210_assign_neg2.c + + 1 int x; + 2 x = -rand(-1,10); + 3 + +Output: [|-x+1>=0; x+10>=0|] + +------------------------------------- + +sources/0211_assign_sub.c + + 1 int x; + 2 x = 999 - 1; + +Output: [|x-998=0|] + +------------------------------------- + +sources/0212_assign_sub2.c + + 1 int x; + 2 x = rand(1,10) - rand(2,3); + +Output: [|-x+8>=0; x+2>=0|] + +------------------------------------- + +sources/0213_assign_mul.c + + 1 int x; + 2 x = 5 * 8; + +Output: [|x-40=0|] + +------------------------------------- + +sources/0214_assign_mul2.c + + 1 int x; + 2 x = rand(1,3) * rand(2,9); + +Output: [|-x+27>=0; x-2>=0|] + +------------------------------------- + +sources/0215_assign_mul3.c + + 1 int x; + 2 x = rand(-5,3) * rand(-1,10); + +Output: [|-x+30>=0; x+50>=0|] + +------------------------------------- + +sources/0216_assign_mul4.c + + 1 int x; + 2 x = x * 0; + +Output: [|x=0|] + +------------------------------------- + +sources/0217_assign_copy.c + + 1 int x; + 2 int y; + 3 x = 12; + 4 y = x; + 5 print(y); + +sources/0217_assign_copy.c:5.0-9: [|y-12=0|] +Output: [|y-12=0; x-12=0|] + +------------------------------------- + +sources/0218_assign_rel.c + + 1 int x; + 2 int y; + 3 x = 15; + 4 y = x + 2; + 5 print(y); + +sources/0218_assign_rel.c:5.0-9: [|y-17=0|] +Output: [|y-17=0; x-15=0|] + +------------------------------------- + +sources/0219_assign_rel2.c + + 1 int x = rand(1,5); + 2 int y = rand(2,10); + 3 int z = x + 2*y; + +Output: [|-x-2y+z=0; -x+5>=0; -y+10>=0; y-2>=0; x-1>=0|] + +------------------------------------- + +sources/0300_if_true.c + + 1 int x = 1; + 2 if (1 <= 2) x = 9; + +Output: [|x-9=0|] + +------------------------------------- + +sources/0301_if_false.c + + 1 int x = 1; + 2 if (1 >= 2) x = 9; + +Output: [|x-1=0|] + +------------------------------------- + +sources/0302_if_both.c + + 1 int x = 1; + 2 if (rand(0,1) == 0) x = 9; + +Output: [|-x+9>=0; x-1>=0|] + +------------------------------------- + +sources/0303_if_else_true.c + + 1 int x = 1; + 2 if (1 <= 2) x = 5; else x = 10; + +Output: [|x-5=0|] + +------------------------------------- + +sources/0304_if_else_false.c + + 1 int x = 1; + 2 if (1 >= 2) x = 5; else x = 10; + +Output: [|x-10=0|] + +------------------------------------- + +sources/0305_if_else_both.c + + 1 int x = 1; + 2 if (rand(0,1) == 0) x = 5; else x = 10; + +Output: [|-x+10>=0; x-5>=0|] + +------------------------------------- + +sources/0306_if_rel.c + + 1 int x,y; + 2 if (rand(0,1) == 0) { x = 1; y = 3; } + 3 else { x = 2; y = 1; } + +Output: [|2x+y-5=0; -x+2>=0; x-1>=0|] + +------------------------------------- + +sources/0307_if_var.c + + 1 int x = rand(-10,20); + 2 if (x >= 0) { print(x); } + 3 else { print(x); } + +sources/0307_if_var.c:2.14-24: [|-x+20>=0; x>=0|] +sources/0307_if_var.c:3.7-17: [|-x-1>=0; x+10>=0|] +Output: [|-x+20>=0; x+10>=0|] + +------------------------------------- + +sources/0308_if_var2.c + + 1 int x = rand(-20,10); + 2 if (x < 2) x = -x; + +Output: [|-x+20>=0; x+1>=0|] + +------------------------------------- + +sources/0309_if_var_rel.c + + 1 int x = rand(-10,25); + 2 int y = rand(-15,20); + 3 if (x >= y) x = y; + +Output: [|-x+y>=0; -y+20>=0; 7x-y+90>=0|] + +------------------------------------- + +sources/0310_cmp_le.c + + 1 int x = rand(10,20); + 2 int y = rand(15,30); + 3 if (x <= y) print(x,y); + +sources/0310_cmp_le.c:3.11-23: [|-x+20>=0; -x+y>=0; -y+30>=0; y-15>=0; + x-10>=0|] +Output: [|-x+20>=0; -y+30>=0; y-15>=0; x-10>=0|] + +------------------------------------- + +sources/0311_cmp_le2.c + + 1 int x = rand(10,20); + 2 int y = rand(8,17); + 3 if (x <= y) print(x,y); + +sources/0311_cmp_le2.c:3.11-23: [|-x+y>=0; -y+17>=0; x-10>=0|] +Output: [|-x+20>=0; -y+17>=0; y-8>=0; x-10>=0|] + +------------------------------------- + +sources/0312_cmp_le3.c + + 1 int y = rand(10,20); + 2 int x = rand(30,55); + 3 if (x <= y) print(x); + +sources/0312_cmp_le3.c:3.11-21: bottom +Output: [|-x+55>=0; -y+20>=0; y-10>=0; x-30>=0|] + +------------------------------------- + +sources/0313_cmp_lt.c + + 1 int x = rand(10,20); + 2 int y = rand(5,15); + 3 if (x < y) print(x,y); + +sources/0313_cmp_lt.c:3.10-22: [|-x+y-1>=0; -y+15>=0; x-10>=0|] +Output: [|-x+20>=0; -y+15>=0; y-5>=0; x-10>=0|] + +------------------------------------- + +sources/0314_cmp_ge.c + + 1 int x = rand(10,20); + 2 int y = rand(15,30); + 3 if (x >= y) print(x,y); + +sources/0314_cmp_ge.c:3.11-23: [|-x+20>=0; y-15>=0; x-y>=0|] +Output: [|-x+20>=0; -y+30>=0; y-15>=0; x-10>=0|] + +------------------------------------- + +sources/0315_cmp_gt.c + + 1 int x = rand(10,20); + 2 int y = rand(15,30); + 3 if (x > y) print(x,y); + +sources/0315_cmp_gt.c:3.10-22: [|-x+20>=0; y-15>=0; x-y-1>=0|] +Output: [|-x+20>=0; -y+30>=0; y-15>=0; x-10>=0|] + +------------------------------------- + +sources/0316_cmp_eq.c + + 1 int x = rand(15,30); + 2 int y = rand(10,20); + 3 if (x == y) print(x,y); + +sources/0316_cmp_eq.c:3.11-23: [|-x+y=0; -x+20>=0; x-15>=0|] +Output: [|-x+30>=0; -y+20>=0; y-10>=0; x-15>=0|] + +------------------------------------- + +sources/0317_cmp_eq2.c + + 1 int x = rand(15,20); + 2 int y = rand(25,30); + 3 if (x == y) print(x,y); + +sources/0317_cmp_eq2.c:3.11-23: bottom +Output: [|-x+20>=0; -y+30>=0; y-25>=0; x-15>=0|] + +------------------------------------- + +sources/0318_cmp_ne.c + + 1 int x = rand(10,15); + 2 int y = rand(10,15); + 3 if (x != y) print(x,y); + +sources/0318_cmp_ne.c:3.11-23: [|-x-y+29>=0; -x+15>=0; -y+15>=0; y-10>=0; + x-10>=0; x+y-21>=0|] +Output: [|-x+15>=0; -y+15>=0; y-10>=0; x-10>=0|] + +------------------------------------- + +sources/0319_cmp_ne.c + + 1 int x = rand(10,15); + 2 int y = 10; + 3 if (x != y) print(x,y); + +sources/0319_cmp_ne.c:3.11-23: [|y-10=0; -x+15>=0; x-11>=0|] +Output: [|y-10=0; -x+15>=0; x-10>=0|] + +------------------------------------- + +sources/0320_cmp_eq_ne.c + + 1 int x = rand(10,15); + 2 int y = 10; + 3 if (x == y) print(x,y); + 4 else print(x,y); + 5 + +sources/0320_cmp_eq_ne.c:3.11-4.0: [|y-10=0; x-10=0|] +sources/0320_cmp_eq_ne.c:4.4-16: [|y-10=0; -x+15>=0; x-11>=0|] +Output: [|y-10=0; -x+15>=0; x-10>=0|] + +------------------------------------- + +sources/0321_cmp_rel.c + + 1 int x = rand(10,20); + 2 int y = x; + 3 if (x >= 15) { print(y); } + +sources/0321_cmp_rel.c:3.15-25: [|-y+20>=0; y-15>=0|] +Output: [|-x+y=0; -x+20>=0; x-10>=0|] + +------------------------------------- + +sources/0322_if_and.c + + 1 int x = rand(10,20); + 2 int y = rand(30,40); + 3 if (x>=15 && y>=35) { print(x,y); } + 4 else { print(x,y); } + +sources/0322_if_and.c:3.22-34: [|-x+20>=0; -y+40>=0; y-35>=0; x-15>=0|] +sources/0322_if_and.c:4.7-19: [|-x-y+54>=0; -x+20>=0; -y+40>=0; y-30>=0; + x-10>=0|] +Output: [|-x+20>=0; -y+40>=0; y-30>=0; x-10>=0|] + +------------------------------------- + +sources/0323_if_or.c + + 1 int x = rand(10,20); + 2 int y = rand(30,40); + 3 if (x>=15 || y>=35) { print(x,y); } + 4 else { print(x,y); } + +sources/0323_if_or.c:3.22-34: [|-x+20>=0; -y+40>=0; y-30>=0; x-10>=0; + x+y-45>=0|] +sources/0323_if_or.c:4.7-19: [|-x+14>=0; -y+34>=0; y-30>=0; x-10>=0|] +Output: [|-x+20>=0; -y+40>=0; y-30>=0; x-10>=0|] + +------------------------------------- + +sources/0324_if_not.c + + 1 int x = rand(10,20); + 2 int y = rand(30,40); + 3 if (!(x>=15) || y>=35) { print(x,y); } + 4 else { print(x,y); } + +sources/0324_if_not.c:3.25-37: [|-5x+6y-110>=0; -x+20>=0; -y+40>=0; y-30>=0; + x-10>=0|] +sources/0324_if_not.c:4.7-19: [|-x+20>=0; -y+34>=0; y-30>=0; x-15>=0|] +Output: [|-x+20>=0; -y+40>=0; y-30>=0; x-10>=0|] + +------------------------------------- + +sources/0325_if_bool.c + + 1 int x = rand(10,20); + 2 int y = rand(10,20); + 3 if (x<=15 && y>=15 || x>=15 && y<=15) { print(x,y); } + 4 else { print(x,y); } + +sources/0325_if_bool.c:3.40-52: [|-x-y+35>=0; -x+20>=0; -y+20>=0; y-10>=0; + x-10>=0; x+y-25>=0|] +sources/0325_if_bool.c:4.7-19: [|-x+20>=0; -x+y+4>=0; -y+20>=0; y-10>=0; + x-y+4>=0; x-10>=0|] +Output: [|-x+20>=0; -y+20>=0; y-10>=0; x-10>=0|] + +------------------------------------- + +sources/0400_assert_true.c + + 1 int x = 2; + 2 assert(x>=1); + +Output: [|x-2=0|] + +------------------------------------- + +sources/0401_assert_false.c + + 1 int x = 9; + 2 assert (x < 5); + +sources/0401_assert_false.c:2.0-15: ERROR: assertion failure +Output: bottom + +------------------------------------- + +sources/0402_assert_both.c + + 1 int x = rand (-5,10); + 2 assert(x >= 0); + 3 assert(x > 0); + 4 + +sources/0402_assert_both.c:2.0-15: ERROR: assertion failure +sources/0402_assert_both.c:3.0-14: ERROR: assertion failure +Output: [|-x+10>=0; x-1>=0|] + +------------------------------------- + +sources/0403_assert_both2.c + + 1 int x = rand (-5,10); + 2 assert(x > 0); + 3 assert(x >= 0); + +sources/0403_assert_both2.c:2.0-14: ERROR: assertion failure +Output: [|-x+10>=0; x-1>=0|] + +------------------------------------- + +sources/0404_assert_rel.c + + 1 int x,y; + 2 if (rand(0,1)==0) { x = 1; y = 1; } + 3 else { x = 3 ; y = 3; } + 4 assert(x==y); + +Output: [|-x+y=0; -x+3>=0; x-1>=0|] + +------------------------------------- + +sources/0500_loop_count.c + + 1 int x = 0; + 2 while (x < 100) { + 3 print(x); + 4 x = x + 1; + 5 } + +sources/0500_loop_count.c:3.2-4.2: [|x=0|] +sources/0500_loop_count.c:3.2-4.2: [|x-1=0|] +sources/0500_loop_count.c:3.2-4.2: [|x-2=0|] +sources/0500_loop_count.c:3.2-4.2: [|-x+99>=0; x-3>=0|] +Output: [|x-100=0|] + +------------------------------------- + +sources/0501_loop_infinite.c + + 1 int x = 0; + 2 while (x < 10) { + 3 print(x); + 4 } + +sources/0501_loop_infinite.c:3.2-4.0: [|x=0|] +sources/0501_loop_infinite.c:3.2-4.0: [|x=0|] +sources/0501_loop_infinite.c:3.2-4.0: [|x=0|] +sources/0501_loop_infinite.c:3.2-4.0: [|x=0|] +Output: bottom + +------------------------------------- + +sources/0502_loop_infinite2.c + + 1 int x = 0; + 2 while (x < 100) { + 3 print(x); + 4 x = x - 1; + 5 } + +sources/0502_loop_infinite2.c:3.2-4.2: [|x=0|] +sources/0502_loop_infinite2.c:3.2-4.2: [|x+1=0|] +sources/0502_loop_infinite2.c:3.2-4.2: [|x+2=0|] +sources/0502_loop_infinite2.c:3.2-4.2: [|-x-3>=0|] +Output: bottom + +------------------------------------- + +sources/0503_loop_nondet.c + + 1 int x = 0; + 2 while (rand(0,1) == 0) { + 3 print(x); + 4 x = x + 1; + 5 } + +sources/0503_loop_nondet.c:3.2-4.2: [|x=0|] +sources/0503_loop_nondet.c:3.2-4.2: [|x-1=0|] +sources/0503_loop_nondet.c:3.2-4.2: [|x-2=0|] +sources/0503_loop_nondet.c:3.2-4.2: [|x-3>=0|] +Output: [|x>=0|] + +------------------------------------- + +sources/0504_loop_rel.c + + 1 int N = rand(0,1000); + 2 int x = 0; + 3 while (x < N) { + 4 print(x,N); + 5 x = x + 1; + 6 } + 7 assert(x==N); + +sources/0504_loop_rel.c:4.2-5.2: [|x=0; -N+1000>=0; N-1>=0|] +sources/0504_loop_rel.c:4.2-5.2: [|x-1=0; -N+1000>=0; N-2>=0|] +sources/0504_loop_rel.c:4.2-5.2: [|x-2=0; -N+1000>=0; N-3>=0|] +sources/0504_loop_rel.c:4.2-5.2: [|-N+1000>=0; x-3>=0; N-x-1>=0|] +Output: [|-N+x=0; -N+1000>=0; N>=0|] + +------------------------------------- + +sources/0505_loop_rel2.c + + 1 int N = rand(0,1000); + 2 int x = 0; + 3 while (x < N) { + 4 print(x,N); + 5 x = x + rand(0,3); + 6 } + 7 assert(x>=N && x=0; N-1>=0|] +sources/0505_loop_rel2.c:4.2-5.2: [|-N+1000>=0; -x+3>=0; x>=0; N-x-1>=0|] +sources/0505_loop_rel2.c:4.2-5.2: [|-N+1000>=0; -x+6>=0; x>=0; N-x-1>=0|] +sources/0505_loop_rel2.c:4.2-5.2: [|-N+1000>=0; x>=0; N-x-1>=0|] +Output: [|-N+1000>=0; -N+x>=0; N-x+2>=0; 3N-x>=0|] + +------------------------------------- + +sources/0506_loop_limit.c + + 1 int x = 0; + 2 while (rand(0,1)==0) { + 3 if (x < 10000) x = x + 1; + 4 } + 5 print(x); + +sources/0506_loop_limit.c:5.0-9: [|x>=0|] +Output: [|x>=0|] + +------------------------------------- + +sources/0507_loop_limit2.c + + 1 int x = 0; + 2 int N = rand(0,1000); + 3 while (rand(0,1)==0) { + 4 if (x < N) x = x + 1; + 5 } + 6 print(x); + +sources/0507_loop_limit2.c:6.0-9: [|-x+1000>=0; x>=0|] +Output: [|-N+1000>=0; x>=0; N-x>=0|] + +------------------------------------- + +sources/0508_loop_init.c + + 1 int init; + 2 int x; + 3 + 4 init = 0; + 5 while (rand(0,1)==0) { + 6 if (init == 0) { + 7 x = 0; + 8 init = 1; + 9 } +10 else { +11 x = x + 1; +12 } +13 assert(x >= 0); +14 } + +Output: [|-init+1>=0; init>=0|] + +------------------------------------- + +sources/0509_loop_nested.c + + 1 int i=0, j=0; + 2 + 3 while (i < 1000) { + 4 j = 0; + 5 while (j < i) { + 6 j = j + 1; + 7 } + 8 i = i + 1; + 9 } + +Output: [|j-999=0; i-1000=0|] + +------------------------------------- + +sources/0510_loop_nested2.c + + 1 int i,j; + 2 + 3 i = 0; + 4 while (i < 1000) { + 5 j = 0; + 6 while (j < i) { + 7 j = j + 1; + 8 } + 9 i = i + 1; +10 } + +Output: [|j-999=0; i-1000=0|] + +------------------------------------- + +sources/0600_bubble_sort.c + + 1 // Example from Cousot Habwachs POPL 1978 + 2 + 3 // Bubble sort, where array operations are abstracted away + 4 // to get a non-deterministic scalar program + 5 + 6 // expected results: + 7 // - with polyhedra, no assertion failure (proof of absence of array overflow) + 8 // - with intervals, assertion failure + 9 +10 int B,J,T; +11 int N = rand(0,100000); // array size +12 +13 B = N; +14 while (B >= 1) { +15 J = 1; +16 T = 0; +17 while (J <= B-1) { +18 +19 // array bound-check +20 assert(1 <= J && J <= N); +21 assert(1 <= (J+1) && (J+1) <= N); +22 +23 // the non-deterministic test models comparing TAB[J] and TAB[J+1] +24 if (rand(0,1)==0) { +25 // where, we would exchange TAB[J] and TAB[J+1]; +26 T = J; +27 } +28 +29 J = J + 1; +30 } +31 B = T; +32 } + +Output: [|B=0; -N+100000>=0; N>=0|] + +------------------------------------- + +sources/0601_heap_sort.c + + 1 // Example from Cousot Habwachs POPL 1978 + 2 + 3 // Heap sort, where array operations are abstracted away + 4 // to get a non-deterministic scalar program + 5 + 6 // expected results: with polyhedra, no assertion failure + 7 + 8 int L,R,I,J; + 9 int N = rand(1,100000); // array size +10 +11 L = N/2 + 1; +12 R = N; +13 +14 if (L >= 2) { +15 L = L - 1; +16 // model the assignment "K = TAB[L]" +17 assert(1 <= L && L <= N); +18 } +19 else { +20 // model the assignments "K = TAB[R]; TAB[R] = TAB[1]" +21 assert(1 <= R && R <= N); +22 assert(1 <= 1 && 1 <= N); +23 R = R - 1; +24 } +25 +26 while (R >= 2) { +27 I = L; +28 J = 2*I; +29 +30 while (J <= R && rand(0,1)==0) { +31 if (J <= R-1) { +32 // model the comparison "TAB[J] < TAB[J+1]" +33 assert(1 <= J && J <= N); +34 assert(1 <= (J+1) && (J+1) <= N); +35 if (rand(0,1)==0) { J = J + 1; } +36 } +37 +38 // model the comparison "K < TAB[J]" +39 assert(1 <= J && J <= N); +40 if (rand(0,1)==0) { +41 // model the assignment "TAB[I] = TAB[J]" +42 assert(1 <= I && I <= N); +43 assert(1 <= J && J <= N); +44 I = J; +45 J = 2*J; +46 } +47 } +48 +49 // model the assignment "TAB[I] = K" +50 assert(1 <= I && I <= N); +51 +52 if (L >= 2) { +53 L = L - 1; +54 // model the assignment "K = TAB[L]" +55 assert(1 <= L && L <= N); +56 } +57 else { +58 // model the assignments "K = TAB[R]; TAB[R] = TAB[1]" +59 assert(1 <= R && R <= N); +60 assert(1 <= 1 && 1 <= N); +61 R = R - 1; +62 } +63 +64 // model the assignment "TAB[1] = K" +65 assert(1 <= 1 && 1 <= N); +66 } + +Output: [|-99999L+49999R+99999>=0; -2L+N+1>=0; -R+1>=0; L-1>=0|] + +------------------------------------- + +sources/0602_rate_limiter.c + + 1 // Example from Miné HOSC 2006 + 2 + 3 // Rate limiter: at each loop iteration, a new input is fetched (X) and + 4 // a new output (Y) is computed; Y tries to follow X but is limited to + 5 // change no more that a given slope (D) in absolute value + 6 + 7 // To prove that the assertion holds, this version needs the polyhedra + 8 // domain and an unrolling factor of at least 6 + 9 +10 int X; // input +11 int Y; // output +12 int S; // last output +13 int D; // maximum slope; +14 +15 Y = 0; +16 while (rand(0,1)==1) { +17 X = rand(-128,128); +18 D = rand(0,16); +19 S = Y; +20 int R = X - S; // current slope +21 Y = X; +22 if (R <= -D) Y = S - D; // slope too small +23 else if (R >= D) Y = S + D; // slope too large +24 } +25 +26 assert(Y >= -128 && Y <= 128); + +sources/0602_rate_limiter.c:26.0-30: ERROR: assertion failure +Output: [|-Y+128>=0; Y+128>=0|] + +------------------------------------- + +sources/0603_rate_limiter2.c + + 1 // This version is similar to the previous one, but the assertion is checked + 2 // inside the loop + 3 // No unrolling is necessary in this version! + 4 + 5 int X; // input + 6 int Y; // output + 7 int S; // last output + 8 int D; // maximum slope; + 9 +10 Y = 0; +11 while (rand(0,1)==1) { +12 X = rand(-128,128); +13 D = rand(0,16); +14 S = Y; +15 int R = X - S; // current slope +16 Y = X; +17 if (R <= -D) Y = S - D; // slope too small +18 else if (R >= D) Y = S + D; // slope too large +19 +20 assert(Y >= -128 && Y <= 128); +21 } + +Output: [|-Y+128>=0; Y+128>=0|] + +------------------------------------- + diff --git a/tests/sources/0000_noinit_var.c b/tests/sources/0000_noinit_var.c new file mode 100644 index 0000000..6d1a0d4 --- /dev/null +++ b/tests/sources/0000_noinit_var.c @@ -0,0 +1 @@ +int x; diff --git a/tests/sources/0001_noinit_2var.c b/tests/sources/0001_noinit_2var.c new file mode 100644 index 0000000..2b9d16b --- /dev/null +++ b/tests/sources/0001_noinit_2var.c @@ -0,0 +1,2 @@ +int x; +int y; diff --git a/tests/sources/0002_init_var.c b/tests/sources/0002_init_var.c new file mode 100644 index 0000000..15bfa8f --- /dev/null +++ b/tests/sources/0002_init_var.c @@ -0,0 +1 @@ +int x = 0; diff --git a/tests/sources/0003_init_2var.c b/tests/sources/0003_init_2var.c new file mode 100644 index 0000000..83aefaf --- /dev/null +++ b/tests/sources/0003_init_2var.c @@ -0,0 +1,2 @@ +int x = 0; +int y = 1; diff --git a/tests/sources/0004_init_2var2.c b/tests/sources/0004_init_2var2.c new file mode 100644 index 0000000..f81c09c --- /dev/null +++ b/tests/sources/0004_init_2var2.c @@ -0,0 +1 @@ +int x = 9, y = 12; diff --git a/tests/sources/0100_print_var.c b/tests/sources/0100_print_var.c new file mode 100644 index 0000000..e2f9464 --- /dev/null +++ b/tests/sources/0100_print_var.c @@ -0,0 +1,2 @@ +int x = 2; +print(x); diff --git a/tests/sources/0101_print_2var.c b/tests/sources/0101_print_2var.c new file mode 100644 index 0000000..92aa4a9 --- /dev/null +++ b/tests/sources/0101_print_2var.c @@ -0,0 +1,3 @@ +int x = 3; +int y = 15; +print(y); diff --git a/tests/sources/0102_print_3var.c b/tests/sources/0102_print_3var.c new file mode 100644 index 0000000..81fe534 --- /dev/null +++ b/tests/sources/0102_print_3var.c @@ -0,0 +1,4 @@ +int x = 3; +int y = 15; +int z = 99; +print(z,x); diff --git a/tests/sources/0103_local.c b/tests/sources/0103_local.c new file mode 100644 index 0000000..c6683be --- /dev/null +++ b/tests/sources/0103_local.c @@ -0,0 +1,5 @@ +int x = 12; +{ + int y = 9; + print(x,y); +} diff --git a/tests/sources/0200_assign_cst.c b/tests/sources/0200_assign_cst.c new file mode 100644 index 0000000..8340469 --- /dev/null +++ b/tests/sources/0200_assign_cst.c @@ -0,0 +1,6 @@ +int x; +print(x); +x = 12; +print(x); +x = 15; +print(x); diff --git a/tests/sources/0201_assign_cst2.c b/tests/sources/0201_assign_cst2.c new file mode 100644 index 0000000..6f28061 --- /dev/null +++ b/tests/sources/0201_assign_cst2.c @@ -0,0 +1,7 @@ +int x, y; +print(x,y); +x = 12; +print(x,y); +y = 15; +x = 99; +print(x,y); diff --git a/tests/sources/0202_assign_expr.c b/tests/sources/0202_assign_expr.c new file mode 100644 index 0000000..7d16636 --- /dev/null +++ b/tests/sources/0202_assign_expr.c @@ -0,0 +1,2 @@ +int x; +x = 2 + 2; diff --git a/tests/sources/0203_assign_expr2.c b/tests/sources/0203_assign_expr2.c new file mode 100644 index 0000000..7583362 --- /dev/null +++ b/tests/sources/0203_assign_expr2.c @@ -0,0 +1,5 @@ +int x,y; +x = 12; +y = 16; +x = x + y + 2; +print(x); diff --git a/tests/sources/0204_assign_rand.c b/tests/sources/0204_assign_rand.c new file mode 100644 index 0000000..8bb9347 --- /dev/null +++ b/tests/sources/0204_assign_rand.c @@ -0,0 +1,3 @@ +int x; +x = rand(1,99); +print(x); diff --git a/tests/sources/0205_assign_rand2.c b/tests/sources/0205_assign_rand2.c new file mode 100644 index 0000000..a5aade7 --- /dev/null +++ b/tests/sources/0205_assign_rand2.c @@ -0,0 +1,3 @@ +int x; +x = rand(10,-5); +print(x); diff --git a/tests/sources/0206_assign_add.c b/tests/sources/0206_assign_add.c new file mode 100644 index 0000000..6c8dffe --- /dev/null +++ b/tests/sources/0206_assign_add.c @@ -0,0 +1,2 @@ +int x; +x = 2 + 5; diff --git a/tests/sources/0207_assign_add2.c b/tests/sources/0207_assign_add2.c new file mode 100644 index 0000000..1f8ec56 --- /dev/null +++ b/tests/sources/0207_assign_add2.c @@ -0,0 +1,2 @@ +int x; +x = rand(1,5) + rand (10,10); diff --git a/tests/sources/0208_assign_add3.c b/tests/sources/0208_assign_add3.c new file mode 100644 index 0000000..2f6357f --- /dev/null +++ b/tests/sources/0208_assign_add3.c @@ -0,0 +1,2 @@ +int x; +x = x + 2; diff --git a/tests/sources/0209_assign_neg.c b/tests/sources/0209_assign_neg.c new file mode 100644 index 0000000..f52fa2b --- /dev/null +++ b/tests/sources/0209_assign_neg.c @@ -0,0 +1,2 @@ +int x; +x = -9; diff --git a/tests/sources/0210_assign_neg2.c b/tests/sources/0210_assign_neg2.c new file mode 100644 index 0000000..d297b2c --- /dev/null +++ b/tests/sources/0210_assign_neg2.c @@ -0,0 +1,3 @@ +int x; +x = -rand(-1,10); + diff --git a/tests/sources/0211_assign_sub.c b/tests/sources/0211_assign_sub.c new file mode 100644 index 0000000..8f7b962 --- /dev/null +++ b/tests/sources/0211_assign_sub.c @@ -0,0 +1,2 @@ +int x; +x = 999 - 1; diff --git a/tests/sources/0212_assign_sub2.c b/tests/sources/0212_assign_sub2.c new file mode 100644 index 0000000..0b4f96f --- /dev/null +++ b/tests/sources/0212_assign_sub2.c @@ -0,0 +1,2 @@ +int x; +x = rand(1,10) - rand(2,3); diff --git a/tests/sources/0213_assign_mul.c b/tests/sources/0213_assign_mul.c new file mode 100644 index 0000000..6ba6b71 --- /dev/null +++ b/tests/sources/0213_assign_mul.c @@ -0,0 +1,2 @@ +int x; +x = 5 * 8; diff --git a/tests/sources/0214_assign_mul2.c b/tests/sources/0214_assign_mul2.c new file mode 100644 index 0000000..a5cdeef --- /dev/null +++ b/tests/sources/0214_assign_mul2.c @@ -0,0 +1,2 @@ +int x; +x = rand(1,3) * rand(2,9); diff --git a/tests/sources/0215_assign_mul3.c b/tests/sources/0215_assign_mul3.c new file mode 100644 index 0000000..b4affcf --- /dev/null +++ b/tests/sources/0215_assign_mul3.c @@ -0,0 +1,2 @@ +int x; +x = rand(-5,3) * rand(-1,10); diff --git a/tests/sources/0216_assign_mul4.c b/tests/sources/0216_assign_mul4.c new file mode 100644 index 0000000..7a10bb1 --- /dev/null +++ b/tests/sources/0216_assign_mul4.c @@ -0,0 +1,2 @@ +int x; +x = x * 0; diff --git a/tests/sources/0217_assign_copy.c b/tests/sources/0217_assign_copy.c new file mode 100644 index 0000000..bdff7a4 --- /dev/null +++ b/tests/sources/0217_assign_copy.c @@ -0,0 +1,5 @@ +int x; +int y; +x = 12; +y = x; +print(y); diff --git a/tests/sources/0218_assign_rel.c b/tests/sources/0218_assign_rel.c new file mode 100644 index 0000000..921d6ec --- /dev/null +++ b/tests/sources/0218_assign_rel.c @@ -0,0 +1,5 @@ +int x; +int y; +x = 15; +y = x + 2; +print(y); diff --git a/tests/sources/0219_assign_rel2.c b/tests/sources/0219_assign_rel2.c new file mode 100644 index 0000000..b19564d --- /dev/null +++ b/tests/sources/0219_assign_rel2.c @@ -0,0 +1,3 @@ +int x = rand(1,5); +int y = rand(2,10); +int z = x + 2*y; diff --git a/tests/sources/0300_if_true.c b/tests/sources/0300_if_true.c new file mode 100644 index 0000000..c824dbc --- /dev/null +++ b/tests/sources/0300_if_true.c @@ -0,0 +1,2 @@ +int x = 1; +if (1 <= 2) x = 9; diff --git a/tests/sources/0301_if_false.c b/tests/sources/0301_if_false.c new file mode 100644 index 0000000..6ce93de --- /dev/null +++ b/tests/sources/0301_if_false.c @@ -0,0 +1,2 @@ +int x = 1; +if (1 >= 2) x = 9; diff --git a/tests/sources/0302_if_both.c b/tests/sources/0302_if_both.c new file mode 100644 index 0000000..5afc2f8 --- /dev/null +++ b/tests/sources/0302_if_both.c @@ -0,0 +1,2 @@ +int x = 1; +if (rand(0,1) == 0) x = 9; diff --git a/tests/sources/0303_if_else_true.c b/tests/sources/0303_if_else_true.c new file mode 100644 index 0000000..8fa783f --- /dev/null +++ b/tests/sources/0303_if_else_true.c @@ -0,0 +1,2 @@ +int x = 1; +if (1 <= 2) x = 5; else x = 10; diff --git a/tests/sources/0304_if_else_false.c b/tests/sources/0304_if_else_false.c new file mode 100644 index 0000000..dab7fd2 --- /dev/null +++ b/tests/sources/0304_if_else_false.c @@ -0,0 +1,2 @@ +int x = 1; +if (1 >= 2) x = 5; else x = 10; diff --git a/tests/sources/0305_if_else_both.c b/tests/sources/0305_if_else_both.c new file mode 100644 index 0000000..ddf0eb2 --- /dev/null +++ b/tests/sources/0305_if_else_both.c @@ -0,0 +1,2 @@ +int x = 1; +if (rand(0,1) == 0) x = 5; else x = 10; diff --git a/tests/sources/0306_if_rel.c b/tests/sources/0306_if_rel.c new file mode 100644 index 0000000..66ddcc1 --- /dev/null +++ b/tests/sources/0306_if_rel.c @@ -0,0 +1,3 @@ +int x,y; +if (rand(0,1) == 0) { x = 1; y = 3; } +else { x = 2; y = 1; } diff --git a/tests/sources/0307_if_var.c b/tests/sources/0307_if_var.c new file mode 100644 index 0000000..a18b71b --- /dev/null +++ b/tests/sources/0307_if_var.c @@ -0,0 +1,3 @@ +int x = rand(-10,20); +if (x >= 0) { print(x); } +else { print(x); } diff --git a/tests/sources/0308_if_var2.c b/tests/sources/0308_if_var2.c new file mode 100644 index 0000000..cf3aa0f --- /dev/null +++ b/tests/sources/0308_if_var2.c @@ -0,0 +1,2 @@ +int x = rand(-20,10); +if (x < 2) x = -x; diff --git a/tests/sources/0309_if_var_rel.c b/tests/sources/0309_if_var_rel.c new file mode 100644 index 0000000..1788f99 --- /dev/null +++ b/tests/sources/0309_if_var_rel.c @@ -0,0 +1,3 @@ +int x = rand(-10,25); +int y = rand(-15,20); +if (x >= y) x = y; diff --git a/tests/sources/0310_cmp_le.c b/tests/sources/0310_cmp_le.c new file mode 100644 index 0000000..5340ed4 --- /dev/null +++ b/tests/sources/0310_cmp_le.c @@ -0,0 +1,3 @@ +int x = rand(10,20); +int y = rand(15,30); +if (x <= y) print(x,y); diff --git a/tests/sources/0311_cmp_le2.c b/tests/sources/0311_cmp_le2.c new file mode 100644 index 0000000..d88fb3b --- /dev/null +++ b/tests/sources/0311_cmp_le2.c @@ -0,0 +1,3 @@ +int x = rand(10,20); +int y = rand(8,17); +if (x <= y) print(x,y); diff --git a/tests/sources/0312_cmp_le3.c b/tests/sources/0312_cmp_le3.c new file mode 100644 index 0000000..00c4b32 --- /dev/null +++ b/tests/sources/0312_cmp_le3.c @@ -0,0 +1,3 @@ +int y = rand(10,20); +int x = rand(30,55); +if (x <= y) print(x); diff --git a/tests/sources/0313_cmp_lt.c b/tests/sources/0313_cmp_lt.c new file mode 100644 index 0000000..794fdd8 --- /dev/null +++ b/tests/sources/0313_cmp_lt.c @@ -0,0 +1,3 @@ +int x = rand(10,20); +int y = rand(5,15); +if (x < y) print(x,y); diff --git a/tests/sources/0314_cmp_ge.c b/tests/sources/0314_cmp_ge.c new file mode 100644 index 0000000..11ccae5 --- /dev/null +++ b/tests/sources/0314_cmp_ge.c @@ -0,0 +1,3 @@ +int x = rand(10,20); +int y = rand(15,30); +if (x >= y) print(x,y); diff --git a/tests/sources/0315_cmp_gt.c b/tests/sources/0315_cmp_gt.c new file mode 100644 index 0000000..2ab9e11 --- /dev/null +++ b/tests/sources/0315_cmp_gt.c @@ -0,0 +1,3 @@ +int x = rand(10,20); +int y = rand(15,30); +if (x > y) print(x,y); diff --git a/tests/sources/0316_cmp_eq.c b/tests/sources/0316_cmp_eq.c new file mode 100644 index 0000000..3fe7b2e --- /dev/null +++ b/tests/sources/0316_cmp_eq.c @@ -0,0 +1,3 @@ +int x = rand(15,30); +int y = rand(10,20); +if (x == y) print(x,y); diff --git a/tests/sources/0317_cmp_eq2.c b/tests/sources/0317_cmp_eq2.c new file mode 100644 index 0000000..5d3b677 --- /dev/null +++ b/tests/sources/0317_cmp_eq2.c @@ -0,0 +1,3 @@ +int x = rand(15,20); +int y = rand(25,30); +if (x == y) print(x,y); diff --git a/tests/sources/0318_cmp_ne.c b/tests/sources/0318_cmp_ne.c new file mode 100644 index 0000000..8e7bf10 --- /dev/null +++ b/tests/sources/0318_cmp_ne.c @@ -0,0 +1,3 @@ +int x = rand(10,15); +int y = rand(10,15); +if (x != y) print(x,y); diff --git a/tests/sources/0319_cmp_ne.c b/tests/sources/0319_cmp_ne.c new file mode 100644 index 0000000..3dbe18b --- /dev/null +++ b/tests/sources/0319_cmp_ne.c @@ -0,0 +1,3 @@ +int x = rand(10,15); +int y = 10; +if (x != y) print(x,y); diff --git a/tests/sources/0320_cmp_eq_ne.c b/tests/sources/0320_cmp_eq_ne.c new file mode 100644 index 0000000..6f4244c --- /dev/null +++ b/tests/sources/0320_cmp_eq_ne.c @@ -0,0 +1,5 @@ +int x = rand(10,15); +int y = 10; +if (x == y) print(x,y); +else print(x,y); + diff --git a/tests/sources/0321_cmp_rel.c b/tests/sources/0321_cmp_rel.c new file mode 100644 index 0000000..d9c973c --- /dev/null +++ b/tests/sources/0321_cmp_rel.c @@ -0,0 +1,3 @@ +int x = rand(10,20); +int y = x; +if (x >= 15) { print(y); } diff --git a/tests/sources/0322_if_and.c b/tests/sources/0322_if_and.c new file mode 100644 index 0000000..cd10203 --- /dev/null +++ b/tests/sources/0322_if_and.c @@ -0,0 +1,4 @@ +int x = rand(10,20); +int y = rand(30,40); +if (x>=15 && y>=35) { print(x,y); } +else { print(x,y); } diff --git a/tests/sources/0323_if_or.c b/tests/sources/0323_if_or.c new file mode 100644 index 0000000..145983e --- /dev/null +++ b/tests/sources/0323_if_or.c @@ -0,0 +1,4 @@ +int x = rand(10,20); +int y = rand(30,40); +if (x>=15 || y>=35) { print(x,y); } +else { print(x,y); } diff --git a/tests/sources/0324_if_not.c b/tests/sources/0324_if_not.c new file mode 100644 index 0000000..8a6abb7 --- /dev/null +++ b/tests/sources/0324_if_not.c @@ -0,0 +1,4 @@ +int x = rand(10,20); +int y = rand(30,40); +if (!(x>=15) || y>=35) { print(x,y); } +else { print(x,y); } diff --git a/tests/sources/0325_if_bool.c b/tests/sources/0325_if_bool.c new file mode 100644 index 0000000..614d5d7 --- /dev/null +++ b/tests/sources/0325_if_bool.c @@ -0,0 +1,4 @@ +int x = rand(10,20); +int y = rand(10,20); +if (x<=15 && y>=15 || x>=15 && y<=15) { print(x,y); } +else { print(x,y); } diff --git a/tests/sources/0400_assert_true.c b/tests/sources/0400_assert_true.c new file mode 100644 index 0000000..6516bac --- /dev/null +++ b/tests/sources/0400_assert_true.c @@ -0,0 +1,2 @@ +int x = 2; +assert(x>=1); diff --git a/tests/sources/0401_assert_false.c b/tests/sources/0401_assert_false.c new file mode 100644 index 0000000..b2bc702 --- /dev/null +++ b/tests/sources/0401_assert_false.c @@ -0,0 +1,2 @@ +int x = 9; +assert (x < 5); diff --git a/tests/sources/0402_assert_both.c b/tests/sources/0402_assert_both.c new file mode 100644 index 0000000..f9afd61 --- /dev/null +++ b/tests/sources/0402_assert_both.c @@ -0,0 +1,3 @@ +int x = rand (-5,10); +assert(x >= 0); +assert(x > 0); diff --git a/tests/sources/0403_assert_both2.c b/tests/sources/0403_assert_both2.c new file mode 100644 index 0000000..1a35775 --- /dev/null +++ b/tests/sources/0403_assert_both2.c @@ -0,0 +1,3 @@ +int x = rand (-5,10); +assert(x > 0); +assert(x >= 0); diff --git a/tests/sources/0404_assert_rel.c b/tests/sources/0404_assert_rel.c new file mode 100644 index 0000000..933d005 --- /dev/null +++ b/tests/sources/0404_assert_rel.c @@ -0,0 +1,4 @@ +int x,y; +if (rand(0,1)==0) { x = 1; y = 1; } +else { x = 3 ; y = 3; } +assert(x==y); diff --git a/tests/sources/0500_loop_count.c b/tests/sources/0500_loop_count.c new file mode 100644 index 0000000..ace98cf --- /dev/null +++ b/tests/sources/0500_loop_count.c @@ -0,0 +1,5 @@ +int x = 0; +while (x < 100) { + print(x); + x = x + 1; +} diff --git a/tests/sources/0501_loop_infinite.c b/tests/sources/0501_loop_infinite.c new file mode 100644 index 0000000..2676685 --- /dev/null +++ b/tests/sources/0501_loop_infinite.c @@ -0,0 +1,4 @@ +int x = 0; +while (x < 10) { + print(x); +} diff --git a/tests/sources/0502_loop_infinite2.c b/tests/sources/0502_loop_infinite2.c new file mode 100644 index 0000000..ef899a4 --- /dev/null +++ b/tests/sources/0502_loop_infinite2.c @@ -0,0 +1,5 @@ +int x = 0; +while (x < 100) { + print(x); + x = x - 1; +} diff --git a/tests/sources/0503_loop_nondet.c b/tests/sources/0503_loop_nondet.c new file mode 100644 index 0000000..ab17b7b --- /dev/null +++ b/tests/sources/0503_loop_nondet.c @@ -0,0 +1,5 @@ +int x = 0; +while (rand(0,1) == 0) { + print(x); + x = x + 1; +} diff --git a/tests/sources/0504_loop_rel.c b/tests/sources/0504_loop_rel.c new file mode 100644 index 0000000..05804af --- /dev/null +++ b/tests/sources/0504_loop_rel.c @@ -0,0 +1,7 @@ +int N = rand(0,1000); +int x = 0; +while (x < N) { + print(x,N); + x = x + 1; +} +assert(x==N); diff --git a/tests/sources/0505_loop_rel2.c b/tests/sources/0505_loop_rel2.c new file mode 100644 index 0000000..e335932 --- /dev/null +++ b/tests/sources/0505_loop_rel2.c @@ -0,0 +1,7 @@ +int N = rand(0,1000); +int x = 0; +while (x < N) { + print(x,N); + x = x + rand(0,3); +} +assert(x>=N && x= 0); +} diff --git a/tests/sources/0509_loop_nested.c b/tests/sources/0509_loop_nested.c new file mode 100644 index 0000000..54d5be6 --- /dev/null +++ b/tests/sources/0509_loop_nested.c @@ -0,0 +1,9 @@ +int i=0, j=0; + +while (i < 1000) { + j = 0; + while (j < i) { + j = j + 1; + } + i = i + 1; +} diff --git a/tests/sources/0510_loop_nested2.c b/tests/sources/0510_loop_nested2.c new file mode 100644 index 0000000..90c52ec --- /dev/null +++ b/tests/sources/0510_loop_nested2.c @@ -0,0 +1,10 @@ +int i,j; + +i = 0; +while (i < 1000) { + j = 0; + while (j < i) { + j = j + 1; + } + i = i + 1; +} diff --git a/tests/sources/0600_bubble_sort.c b/tests/sources/0600_bubble_sort.c new file mode 100644 index 0000000..5cad03d --- /dev/null +++ b/tests/sources/0600_bubble_sort.c @@ -0,0 +1,32 @@ +// Example from Cousot Habwachs POPL 1978 + +// Bubble sort, where array operations are abstracted away +// to get a non-deterministic scalar program + +// expected results: +// - with polyhedra, no assertion failure (proof of absence of array overflow) +// - with intervals, assertion failure + +int B,J,T; +int N = rand(0,100000); // array size + +B = N; +while (B >= 1) { + J = 1; + T = 0; + while (J <= B-1) { + + // array bound-check + assert(1 <= J && J <= N); + assert(1 <= (J+1) && (J+1) <= N); + + // the non-deterministic test models comparing TAB[J] and TAB[J+1] + if (rand(0,1)==0) { + // where, we would exchange TAB[J] and TAB[J+1]; + T = J; + } + + J = J + 1; + } + B = T; +} diff --git a/tests/sources/0601_heap_sort.c b/tests/sources/0601_heap_sort.c new file mode 100644 index 0000000..dd12e1a --- /dev/null +++ b/tests/sources/0601_heap_sort.c @@ -0,0 +1,66 @@ +// Example from Cousot Habwachs POPL 1978 + +// Heap sort, where array operations are abstracted away +// to get a non-deterministic scalar program + +// expected results: with polyhedra, no assertion failure + +int L,R,I,J; +int N = rand(1,100000); // array size + +L = N/2 + 1; +R = N; + +if (L >= 2) { + L = L - 1; + // model the assignment "K = TAB[L]" + assert(1 <= L && L <= N); +} +else { + // model the assignments "K = TAB[R]; TAB[R] = TAB[1]" + assert(1 <= R && R <= N); + assert(1 <= 1 && 1 <= N); + R = R - 1; +} + +while (R >= 2) { + I = L; + J = 2*I; + + while (J <= R && rand(0,1)==0) { + if (J <= R-1) { + // model the comparison "TAB[J] < TAB[J+1]" + assert(1 <= J && J <= N); + assert(1 <= (J+1) && (J+1) <= N); + if (rand(0,1)==0) { J = J + 1; } + } + + // model the comparison "K < TAB[J]" + assert(1 <= J && J <= N); + if (rand(0,1)==0) { + // model the assignment "TAB[I] = TAB[J]" + assert(1 <= I && I <= N); + assert(1 <= J && J <= N); + I = J; + J = 2*J; + } + } + + // model the assignment "TAB[I] = K" + assert(1 <= I && I <= N); + + if (L >= 2) { + L = L - 1; + // model the assignment "K = TAB[L]" + assert(1 <= L && L <= N); + } + else { + // model the assignments "K = TAB[R]; TAB[R] = TAB[1]" + assert(1 <= R && R <= N); + assert(1 <= 1 && 1 <= N); + R = R - 1; + } + + // model the assignment "TAB[1] = K" + assert(1 <= 1 && 1 <= N); +} diff --git a/tests/sources/0602_rate_limiter.c b/tests/sources/0602_rate_limiter.c new file mode 100644 index 0000000..a36da77 --- /dev/null +++ b/tests/sources/0602_rate_limiter.c @@ -0,0 +1,26 @@ +// Example from Miné HOSC 2006 + +// Rate limiter: at each loop iteration, a new input is fetched (X) and +// a new output (Y) is computed; Y tries to follow X but is limited to +// change no more that a given slope (D) in absolute value + +// To prove that the assertion holds, this version needs the polyhedra +// domain and an unrolling factor of at least 6 + +int X; // input +int Y; // output +int S; // last output +int D; // maximum slope; + +Y = 0; +while (rand(0,1)==1) { + X = rand(-128,128); + D = rand(0,16); + S = Y; + int R = X - S; // current slope + Y = X; + if (R <= -D) Y = S - D; // slope too small + else if (R >= D) Y = S + D; // slope too large +} + +assert(Y >= -128 && Y <= 128); diff --git a/tests/sources/0603_rate_limiter2.c b/tests/sources/0603_rate_limiter2.c new file mode 100644 index 0000000..32a7a17 --- /dev/null +++ b/tests/sources/0603_rate_limiter2.c @@ -0,0 +1,21 @@ +// This version is similar to the previous one, but the assertion is checked +// inside the loop +// No unrolling is necessary in this version! + +int X; // input +int Y; // output +int S; // last output +int D; // maximum slope; + +Y = 0; +while (rand(0,1)==1) { + X = rand(-128,128); + D = rand(0,16); + S = Y; + int R = X - S; // current slope + Y = X; + if (R <= -D) Y = S - D; // slope too small + else if (R >= D) Y = S + D; // slope too large + + assert(Y >= -128 && Y <= 128); +} -- cgit v1.2.3