├── .gitattributes ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── Vagrantfile ├── _tags ├── build.sh ├── comp_bin ├── hoice_macos ├── r_type_macos ├── r_type_ubuntu └── test_case_format.ml ├── drift.opam ├── dune ├── dune-project ├── generate_table1 ├── generate_table2 ├── result ├── 1-sensitive-trace │ └── unv │ │ └── res1tr-polka_st-standard.csv ├── 1-sensitive │ ├── call │ │ ├── res1-oct-dwid-300.csv │ │ ├── res1-oct-standard.csv │ │ ├── res1-oct-wid+nar.csv │ │ ├── res1-polka-dwid-300.csv │ │ ├── res1-polka-standard.csv │ │ ├── res1-polka-wid+nar.csv │ │ ├── res1-polka_ls-dwid-300.csv │ │ ├── res1-polka_ls-standard.csv │ │ └── res1-polka_ls-wid+nar.csv │ └── unv │ │ ├── res1-oct-standard.csv │ │ ├── res1-oct-thowid.csv │ │ ├── res1-polka_ls-standard.csv │ │ ├── res1-polka_ls-thowid.csv │ │ ├── res1-polka_st-standard.csv │ │ └── res1-polka_st-thowid.csv ├── 2-sensitive-trace │ └── unv │ │ ├── res2tr-oct-standard.csv │ │ └── res2tr-polka_st-standard.csv ├── 2-sensitive │ └── unv │ │ ├── res2-oct-standard.csv │ │ └── res2-polka_st-standard.csv ├── 3-sensitive-trace │ └── unv │ │ └── res3tr-oct-standard.csv ├── 3-sensitive │ └── unv │ │ └── res3-oct-standard.csv ├── 4-sensitive │ └── unv │ │ └── res4-oct-standard.csv ├── comp_tools │ ├── call │ │ ├── res1-polka-standard.csv │ │ ├── res_dorder.csv │ │ ├── res_dsolve.csv │ │ ├── res_mochi.csv │ │ └── res_rtype.csv │ └── unv │ │ ├── res-dsolve.csv │ │ ├── res-mochi-hoice.csv │ │ ├── res-mochi-z3.csv │ │ ├── res-rtype-hoice.csv │ │ ├── res-rtype-z3.csv │ │ └── res1-polka_ls-thowid.csv ├── non-sensitive │ ├── call │ │ ├── res-oct-dwid-300.csv │ │ ├── res-oct-standard.csv │ │ ├── res-oct-wid+nar.csv │ │ ├── res-polka-dwid-300.csv │ │ ├── res-polka-standard.csv │ │ ├── res-polka-wid+nar.csv │ │ ├── res-polka_ls-dwid-300.csv │ │ ├── res-polka_ls-standard.csv │ │ └── res-polka_ls-wid+nar.csv │ └── unv │ │ ├── res-1-standard.csv │ │ ├── res-oct-standard.csv │ │ ├── res-oct-thowid.csv │ │ ├── res-polka_ls-standard.csv │ │ ├── res-polka_ls-thowid.csv │ │ ├── res-polka_st-standard.csv │ │ └── res-polka_st-thowid.csv ├── table.py ├── table1.out └── table2.out ├── runall_unsafe ├── scripts ├── 0-baseline.csv ├── 1-baseline.csv ├── benchexec-drifttoolinfo │ ├── drifttoolinfo │ │ ├── __init__.py │ │ ├── coarmochi.py │ │ ├── drift.py │ │ └── mochi.py │ └── setup.py ├── benchs_popl21.sh ├── compare_results.py ├── dsolve_runit.sh ├── dsolve_table.py ├── effects │ ├── Makefile │ ├── README.md │ ├── benchexec.cfg │ ├── benchmark-coarmochi.xml │ ├── benchmark-drift-autogenerated.xml │ ├── benchmark-drift-tos.xml │ ├── benchmark-drift.xml │ ├── benchmark-mochi.xml │ ├── benchmark.dtd │ ├── coarmochi.py │ ├── cps_translate.py │ ├── csvToTex.pl │ ├── latest-results.csv │ ├── latest-results.diff.html │ ├── latest-results.html │ ├── latest-results.table.html │ ├── latest-results.table.tex │ ├── makeLatex.pl │ ├── makeRunDefinitions.pl │ ├── makeYamls.pl │ ├── ml_tuple_translate.py │ ├── results.tex │ ├── results │ │ ├── benchmark-coarmochi.2024-11-14_16-19-31.results.default.mochibenchmarks.csv │ │ ├── benchmark-mochi.2024-11-13_15-18-46.results.default.realmochibenchmarks.csv │ │ ├── results.2023-10-10_11-56-18.table.statistics.tex │ │ ├── results.2024-07-02_16-55-09.table.csv │ │ ├── results.2024-11-14_11-47-05.table.csv │ │ └── results.2024-11-14_16-06-29.table.csv │ ├── runNewMochi.sh │ ├── table.tex │ └── unreach-call.prp ├── mochi_runit.sh ├── mochi_table.py ├── r_type_runit.sh ├── r_type_table.py ├── runit.sh ├── smoke_runit.sh └── table.py ├── src ├── algo │ ├── abstractEv.ml │ └── abstractTransformer.ml ├── domain │ ├── abstractDomain.ml │ ├── semanticDomain.ml │ ├── sensitiveDomain.ml │ └── tracePartDomain.ml ├── effects │ ├── cpsConversion.ml │ ├── dune │ ├── effectAutomataGrammar.mly │ ├── effectAutomataLexer.mll │ ├── effectAutomataSyntax.ml │ ├── translation.ml │ └── tupleOCamlTranslation.ml ├── frontends │ ├── dune │ ├── grammar.mly │ ├── lexer.mll │ ├── parser.ml │ └── syntax.ml ├── main │ ├── config.ml │ └── drift.ml └── utils │ ├── printer.ml │ └── util.ml └── tests ├── apply_twice.ml ├── benchmarks ├── DOrder │ ├── first │ │ ├── 01_ic3.ml │ │ ├── gcd.ml │ │ ├── gulwani_cegar1.ml │ │ ├── pldi082_unbounded1.ml │ │ ├── pldi082_unbounded2.ml │ │ ├── prog2.ml │ │ ├── recHanoi03.ml │ │ ├── seq-len.ml │ │ ├── seq-len1.ml │ │ ├── substring1.ml │ │ ├── substring2.ml │ │ ├── svd.ml │ │ ├── up2.ml │ │ ├── xy0.ml │ │ ├── xy10.ml │ │ ├── xy4.ml │ │ ├── xyz.ml │ │ └── xyz2.ml │ ├── high │ │ ├── app-lin-ord2.ml │ │ ├── app-lin-ord3.ml │ │ ├── app-nonrec.ml │ │ ├── app-succ.ml │ │ ├── intro-ord2.ml │ │ ├── intro-ord3.ml │ │ └── repeat_order.ml │ └── list │ │ ├── fold_div.ml │ │ ├── fold_fun_list.ml │ │ ├── fold_left.ml │ │ ├── fold_right.ml │ │ ├── forall_leq.ml │ │ ├── introlist.ml │ │ ├── isnil.ml │ │ ├── iter.ml │ │ ├── length.ml │ │ ├── list.ml │ │ ├── list_rec.ml │ │ ├── mapfilter.ml │ │ ├── mem.ml │ │ ├── nth.ml │ │ ├── reverse.ml │ │ ├── risers.ml │ │ ├── sieve.ml │ │ ├── simple.ml │ │ ├── zip.ml │ │ └── zipunzip.ml ├── DRIFT │ ├── array │ │ ├── a-append.ml │ │ ├── a-copy-print.ml │ │ ├── a-dotprod.ml │ │ ├── a-dropn.ml │ │ ├── a-init1.ml │ │ ├── a-init2.ml │ │ ├── a-iter.ml │ │ ├── a-map.ml │ │ ├── a-mapi.ml │ │ ├── a-reverse.ml │ │ ├── a-split.ml │ │ ├── a-sub.ml │ │ └── bcopy.ml │ ├── first │ │ ├── addition.ml │ │ ├── eq.ml │ │ ├── for_bounded_loop1.ml │ │ ├── half.ml │ │ ├── hanoi.ml │ │ ├── inductive1-2.ml │ │ ├── inductive1-3.ml │ │ ├── inductive3-3.ml │ │ ├── inductive4-1.ml │ │ ├── inductive5-2.ml │ │ ├── inductivea.ml │ │ ├── is_prime.ml │ │ ├── mult_twice.ml │ │ ├── nested_loop.ml │ │ ├── odd_even.ml │ │ ├── sum6.ml │ │ └── up_down_stair.ml │ ├── high │ │ ├── apply-cr.ml │ │ ├── apply_twice.ml │ │ ├── call_back.ml │ │ ├── flip_twice_1.ml │ │ ├── flip_twice_2.ml │ │ ├── foldl.ml │ │ ├── foldr.ml │ │ ├── map_2.ml │ │ ├── mixed_id.ml │ │ ├── multi_compose.ml │ │ └── power.ml │ └── negative │ │ ├── 01_ic3.ml │ │ ├── ack01false.ml │ │ ├── binomial00.ml │ │ ├── compose.ml │ │ ├── ex23.ml │ │ ├── indirectHO01.ml │ │ ├── inductive1-1.ml │ │ ├── repeat.ml │ │ ├── up_down01.ml │ │ ├── xy10.ml │ │ ├── xy4.ml │ │ ├── xyz.ml │ │ ├── xyz2.ml │ │ ├── zip00.ml │ │ └── zip_unzip.ml ├── effects │ ├── 3states-aut.ml │ ├── 3states.ml │ ├── Makefile │ ├── foo-nondet.ml │ ├── foo-safe.ml │ ├── foo-unsafe.ml │ └── runall └── r_type │ ├── array │ ├── a-append.ml │ ├── a-copy-print.ml │ ├── a-dotprod.ml │ ├── a-dropn.ml │ ├── a-init1.ml │ ├── a-init2.ml │ ├── a-iter.ml │ ├── a-map.ml │ ├── a-mapi.ml │ ├── a-reverse.ml │ ├── a-split.ml │ ├── a-sub.ml │ └── bcopy.ml │ ├── first │ ├── ack.ml │ ├── copy_intro.ml │ ├── enc-rev_accum.ml │ ├── enc-rev_append.ml │ ├── enc-zip.ml │ ├── enc-zip3.ml │ ├── enc-zip4.ml │ ├── enc-zip_map.ml │ ├── enc-zip_map2.ml │ ├── enc-zipmap.ml │ ├── fib.ml │ ├── file.ml │ ├── flow.ml │ ├── fxx.ml │ ├── gib.ml │ ├── gib2.ml │ ├── inductive.ml │ ├── inductive2.ml │ ├── inductive3-2.ml │ ├── inductive3.ml │ ├── inductive4.ml │ ├── inductive5.ml │ ├── inductive6-2.ml │ ├── inductive6-3.ml │ ├── inductive6.ml │ ├── lock.ml │ ├── map.ml │ ├── map_map.ml │ ├── mc91.ml │ ├── mc91_95.ml │ ├── mc91_98.ml │ ├── mc91_99.ml │ ├── mult.ml │ ├── sum.ml │ ├── sum2.ml │ ├── sum3.ml │ ├── sum4.ml │ └── sum_intro.ml │ ├── high │ ├── a-copy-print.ml │ ├── a-dotprod.ml │ ├── a-init.ml │ ├── a-max.ml │ ├── apply.ml │ ├── array_init.ml │ ├── bcopy.ml │ ├── bcopy2.ml │ ├── bcopy3.ml │ ├── bcopy4.ml │ ├── bcopy5.ml │ ├── bsearch.ml │ ├── dotprod.ml │ ├── dotprod2.ml │ ├── dotprod3.ml │ ├── dotprod4.ml │ ├── dotprod5.ml │ ├── dotprod_lin.ml │ ├── enc-zip_unzip.ml │ ├── exc-fact.ml │ ├── exc-simple.ml │ ├── exception.ml │ ├── fact_exn.ml │ ├── hors.ml │ ├── hrec.ml │ ├── inc.ml │ ├── inc3.ml │ ├── inc4.ml │ ├── intro1.ml │ ├── intro2.ml │ ├── intro3.ml │ ├── kmp.ml │ ├── max.ml │ ├── mc91_cps.ml │ ├── neg1.ml │ ├── neg2.ml │ ├── queen.ml │ ├── recursive.ml │ ├── repeat.ml │ ├── repeat4.ml │ ├── repeat_mochi.ml │ ├── sigma_sum.ml │ ├── sum_cps.ml │ └── twice.ml │ ├── negative │ ├── CE-Jones_Bohr04.ml │ └── x_plus_2_pow_n01.ml │ └── termination │ ├── Ackermann00.ml │ ├── Ackermann01.ml │ ├── Ackermann02.ml │ ├── Ackermann03.ml │ ├── Ackermann04.ml │ ├── Ackermann05.ml │ ├── Ackermann06.ml │ ├── CE-0CFA00.ml │ ├── CE-0CFA01.ml │ ├── CE-0CFA02.ml │ ├── CE-0CFA03.ml │ ├── CE-0CFA04.ml │ ├── CE-0CFA05.ml │ ├── CE-1CFA00.ml │ ├── CE-1CFA01.ml │ ├── CE-1CFA02.ml │ ├── CE-1CFA03.ml │ ├── CE-1CFA04.ml │ ├── CE-1CFA05.ml │ ├── CE-1CFA06.ml │ ├── CE-1CFA07.ml │ ├── CE-1CFA08.ml │ ├── CE-1CFA09.ml │ ├── CE-Jones_Bohr00.ml │ ├── CE-Jones_Bohr01.ml │ ├── CE-Jones_Bohr02.ml │ ├── CE-Jones_Bohr03.ml │ ├── Fibonacci00.ml │ ├── Fibonacci01.ml │ ├── Fibonacci02.ml │ ├── Fibonacci03.ml │ ├── McCarthy9100.ml │ ├── McCarthy9101.ml │ ├── McCarthy9102.ml │ ├── McCarthy9103.ml │ ├── alias_partial00.ml │ ├── alias_partial01.ml │ ├── alias_partial02.ml │ ├── alias_partial03.ml │ ├── append00.ml │ ├── append01.ml │ ├── append02.ml │ ├── binomial00.ml │ ├── binomial01.ml │ ├── binomial02.ml │ ├── binomial03.ml │ ├── binomial04.ml │ ├── binomial05.ml │ ├── churchNum01.ml │ ├── churchNum02.ml │ ├── churchNum03.ml │ ├── indirect00.ml │ ├── indirect01.ml │ ├── indirect02.ml │ ├── indirect03.ml │ ├── indirectHO00.ml │ ├── indirectHO01.ml │ ├── indirectHO02.ml │ ├── indirectHO03.ml │ ├── toChurch00.ml │ ├── toChurch01.ml │ ├── toChurch02.ml │ ├── toChurch03.ml │ ├── toChurch04.ml │ ├── toChurch05.ml │ ├── up_down00.ml │ ├── up_down01.ml │ ├── up_down02.ml │ ├── up_down03.ml │ ├── up_down04.ml │ ├── up_down05.ml │ ├── up_down06.ml │ ├── up_down07.ml │ ├── x_plus_2_pow_n00.ml │ ├── x_plus_2_pow_n02.ml │ ├── x_plus_2_pow_n03.ml │ ├── x_plus_2_pow_n04.ml │ ├── zip00.ml │ ├── zip01.ml │ └── zip02.ml ├── benchmarks_call ├── DOrder │ ├── first │ │ ├── 01_ic3.ml │ │ ├── gcd.ml │ │ ├── gulwani_cegar1.ml │ │ ├── pldi082_unbounded1.ml │ │ ├── pldi082_unbounded2.ml │ │ ├── prog2.ml │ │ ├── recHanoi03.ml │ │ ├── seq-len.ml │ │ ├── seq-len1.ml │ │ ├── substring1.ml │ │ ├── substring2.ml │ │ ├── svd.ml │ │ ├── up2.ml │ │ ├── xy0.ml │ │ ├── xy10.ml │ │ ├── xy4.ml │ │ ├── xyz.ml │ │ └── xyz2.ml │ ├── high │ │ ├── app-lin-ord2.ml │ │ ├── app-lin-ord3.ml │ │ ├── app-nonrec.ml │ │ ├── app-succ.ml │ │ ├── intro-ord2.ml │ │ ├── intro-ord3.ml │ │ └── repeat_order.ml │ └── list │ │ ├── fold_div.ml │ │ ├── fold_fun_list.ml │ │ ├── fold_left.ml │ │ ├── fold_right.ml │ │ ├── forall_leq.ml │ │ ├── introlist.ml │ │ ├── isnil.ml │ │ ├── iter.ml │ │ ├── length.ml │ │ ├── list.ml │ │ ├── mapfilter.ml │ │ ├── mem.ml │ │ ├── nth.ml │ │ ├── reverse.ml │ │ ├── risers.ml │ │ ├── sieve.ml │ │ ├── simple.ml │ │ ├── zip.ml │ │ └── zipunzip.ml ├── DRIFT │ ├── array │ │ ├── a-append.ml │ │ ├── a-copy-print.ml │ │ ├── a-dotprod.ml │ │ ├── a-dropn.ml │ │ ├── a-init1.ml │ │ ├── a-init2.ml │ │ ├── a-iter.ml │ │ ├── a-map.ml │ │ ├── a-mapi.ml │ │ ├── a-reverse.ml │ │ ├── a-split.ml │ │ ├── a-sub.ml │ │ └── bcopy.ml │ ├── first │ │ ├── addition.ml │ │ ├── eq.ml │ │ ├── for_bounded_loop1.ml │ │ ├── half.ml │ │ ├── hanoi.ml │ │ ├── inductivea.ml │ │ ├── is_prime.ml │ │ ├── mult_twice.ml │ │ ├── nested_loop.ml │ │ ├── odd_even.ml │ │ ├── sum6.ml │ │ └── up_down_stair.ml │ ├── high │ │ ├── apply_twice.ml │ │ ├── call_back.ml │ │ ├── flip_twice_1.ml │ │ ├── flip_twice_2.ml │ │ ├── foldl.ml │ │ ├── foldr.ml │ │ ├── map_2.ml │ │ ├── mixed_id.ml │ │ ├── multi_compose.ml │ │ └── power.ml │ └── negative │ │ ├── 01_ic3.ml │ │ ├── ack01false.ml │ │ ├── binomial00.ml │ │ ├── compose.ml │ │ ├── ex23.ml │ │ ├── indirectHO01.ml │ │ ├── inductive1-1.ml │ │ ├── repeat.ml │ │ ├── up_down01.ml │ │ ├── xy10.ml │ │ ├── xy4.ml │ │ ├── xyz.ml │ │ ├── xyz2.ml │ │ ├── zip00.ml │ │ └── zip_unzip.ml └── r_type │ ├── array │ ├── a-append.ml │ ├── a-copy-print.ml │ ├── a-dotprod.ml │ ├── a-dropn.ml │ ├── a-init1.ml │ ├── a-init2.ml │ ├── a-iter.ml │ ├── a-map.ml │ ├── a-mapi.ml │ ├── a-reverse.ml │ ├── a-split.ml │ ├── a-sub.ml │ └── bcopy.ml │ ├── first │ ├── ack.ml │ ├── copy_intro.ml │ ├── enc-rev_accum.ml │ ├── enc-rev_append-1.ml │ ├── enc-rev_append-2.ml │ ├── enc-zip.ml │ ├── enc-zip3.ml │ ├── enc-zip4.ml │ ├── enc-zip_map.ml │ ├── enc-zip_map2.ml │ ├── enc-zipmap.ml │ ├── fib.ml │ ├── file.ml │ ├── flow.ml │ ├── fxx.ml │ ├── gib.ml │ ├── gib2.ml │ ├── inductive1-1.ml │ ├── inductive1-2.ml │ ├── inductive1-3.ml │ ├── inductive2.ml │ ├── inductive3-2.ml │ ├── inductive3.ml │ ├── inductive4.ml │ ├── inductive5.ml │ ├── inductive6-2.ml │ ├── inductive6.ml │ ├── lock.ml │ ├── map.ml │ ├── map_map.ml │ ├── mc91.ml │ ├── mc91_95.ml │ ├── mc91_98.ml │ ├── mc91_99.ml │ ├── mult.ml │ ├── sum.ml │ ├── sum2.ml │ ├── sum3.ml │ ├── sum4.ml │ └── sum_intro.ml │ └── high │ ├── apply.ml │ ├── exc-fact.ml │ ├── exc-simple.ml │ ├── exception.ml │ ├── fact_exn.ml │ ├── hors.ml │ ├── hrec.ml │ ├── inc.ml │ ├── intro1.ml │ ├── intro2.ml │ ├── intro3.ml │ ├── max.ml │ ├── mc91_cps.ml │ ├── neg1.ml │ ├── neg2.ml │ ├── recursive.ml │ ├── repeat.ml │ ├── repeat4.ml │ ├── sigma_sum.ml │ ├── sum_cps.ml │ └── twice.ml ├── effects ├── all-ev-pos.ml ├── all-ev-pos.yml.prp ├── alt-inev.ml ├── alt-inev.yml.prp ├── auction.ml ├── auction.yml.prp ├── binomial_heap.ml ├── binomial_heap.yml.prp ├── concurrent_sum.ml ├── concurrent_sum.yml.prp ├── depend.ml ├── depend.yml.prp ├── disj-gte.ml ├── disj-gte.yml.prp ├── disj-nondet.ml ├── disj-nondet.yml.prp ├── disj.ml ├── disj.yml.prp ├── higher-order.ml ├── higher-order.yml.prp ├── last-ev-even.ml ├── last-ev-even.yml.prp ├── lics18-amortized.ml ├── lics18-amortized.yml.prp ├── lics18-hoshrink.ml ├── lics18-hoshrink.yml.prp ├── lics18-web.ml ├── lics18-web.yml.prp ├── market.ml ├── market.yml.prp ├── max-min.ml ├── max-min.yml.prp ├── mochi-sum.ml ├── mochi-test.ml ├── mochi_old │ ├── cps_acc-pos-net0-negated.ml │ ├── cps_acc-pos-net0-similar-negated.ml │ ├── cps_acc-pos-net0-similar.ml │ ├── cps_acc-pos-net0.ml │ ├── cps_all-ev-even-sink.ml │ ├── cps_amortized.ml │ ├── cps_assert-true.ml │ ├── cps_depend.ml │ ├── cps_disj.ml │ ├── cps_higher-order1.ml │ ├── cps_higher-order2.ml │ ├── cps_higher-order3.ml │ ├── cps_last-ev-even.ml │ ├── cps_lics18-hoshrink.ml │ ├── cps_lics18-web.ml │ ├── cps_market.ml │ ├── cps_max-min.ml │ ├── cps_monotonic.ml │ ├── cps_order-irrel.ml │ ├── cps_overview1.ml │ ├── cps_rec_simple.ml │ ├── cps_resource-analysis.ml │ ├── cps_sum-appendix.ml │ ├── cps_sum-of-ev-even.ml │ ├── cps_traffic_light_fo_simple.ml │ └── cps_webserver.ml ├── monotonic.ml ├── monotonic.yml.prp ├── nondet_max.ml ├── nondet_max.yml.prp ├── num_evens.ml ├── num_evens.yml.prp ├── old │ ├── 3states-aut.ml │ └── 3states.ml ├── order-irrel-nondet.ml ├── order-irrel-nondet.yml.prp ├── order-irrel.ml ├── order-irrel.yml.prp ├── overview1.ml ├── overview1.yml.prp ├── reentr.ml ├── reentr.yml.prp ├── resource-analysis.ml ├── resource-analysis.yml.prp ├── sum-appendix.ml ├── sum-appendix.yml.prp ├── sum-of-ev-even.ml ├── sum-of-ev-even.yml.prp ├── temperature.ml ├── temperature.yml.prp ├── tr_cps_mochi │ ├── cps_all-ev-pos.ml │ ├── cps_auction.ml │ ├── cps_binomial_heap.ml │ ├── cps_depend.ml │ ├── cps_disj-gte.ml │ ├── cps_disj.ml │ ├── cps_higher-order-disj.ml │ ├── cps_higher-order.ml │ ├── cps_last-ev-even.ml │ ├── cps_lics18-amortized.ml │ ├── cps_lics18-hoshrink.ml │ ├── cps_lics18-web.ml │ ├── cps_market.ml │ ├── cps_max-min.ml │ ├── cps_monotonic.ml │ ├── cps_order-irrel.ml │ ├── cps_overview1.ml │ ├── cps_reentr.ml │ ├── cps_resource-analysis.ml │ ├── cps_sum-appendix.ml │ ├── cps_sum-of-ev-even.ml │ ├── cps_temperature.ml │ └── cps_traffic_light.ml ├── tr_tuple │ ├── all-ev-pos.ml │ ├── auction.ml │ ├── binomial_heap.ml │ ├── concurrent_sum.ml │ ├── depend.ml │ ├── disj-gte.ml │ ├── disj-nondet.ml │ ├── disj.ml │ ├── higher-order-disj.ml │ ├── higher-order.ml │ ├── last-ev-even.ml │ ├── lics18-amortized.ml │ ├── lics18-hoshrink.ml │ ├── lics18-web.ml │ ├── market.ml │ ├── max-min.ml │ ├── monotonic.ml │ ├── nondet_max.ml │ ├── nums_evens.ml │ ├── order-irrel-nondet.ml │ ├── order-irrel.ml │ ├── overview1.0.bin │ ├── overview1.ml │ ├── reentr.ml │ ├── resource-analysis.ml │ ├── sum-appendix.ml │ ├── sum-of-ev-even.ml │ └── temperature.ml ├── tr_tuple_mochi │ ├── all-ev-pos.ml │ ├── alt-inev.ml │ ├── auction.ml │ ├── binomial_heap.ml │ ├── concurrent_sum.ml │ ├── depend.ml │ ├── disj-gte.ml │ ├── disj-nondet.ml │ ├── disj.ml │ ├── higher-order.ml │ ├── last-ev-even.ml │ ├── lics18-amortized.ml │ ├── lics18-hoshrink.ml │ ├── lics18-web.ml │ ├── market.ml │ ├── max-min.ml │ ├── monotonic.ml │ ├── nondet_max.ml │ ├── num_evens.ml │ ├── order-irrel-nondet.ml │ ├── order-irrel.ml │ ├── overview1.ml │ ├── reentr.ml │ ├── resource-analysis.ml │ ├── sum-appendix.ml │ ├── sum-of-ev-even.ml │ └── temperature.ml ├── tr_tuple_rcaml │ ├── all-ev-pos.ml │ ├── alt-inev.ml │ ├── auction.ml │ ├── binomial_heap.ml │ ├── concurrent_sum.ml │ ├── depend.ml │ ├── disj-gte.ml │ ├── disj-nondet.ml │ ├── disj.ml │ ├── higher-order.ml │ ├── last-ev-even.ml │ ├── lics18-amortized.ml │ ├── lics18-hoshrink.ml │ ├── lics18-web.ml │ ├── market.ml │ ├── max-min.ml │ ├── monotonic.ml │ ├── nondet_max.ml │ ├── num_evens.ml │ ├── order-irrel-nondet.ml │ ├── order-irrel.ml │ ├── overview1.ml │ ├── reentr.ml │ ├── resource-analysis.ml │ ├── sum-appendix.ml │ ├── sum-of-ev-even.ml │ └── temperature.ml ├── traffic_light.ml ├── traffic_light.yml.prp └── unsafe │ ├── all-ev-pos.ml │ ├── all-ev-pos.yml.prp │ ├── auction.ml │ ├── auction.yml.prp │ ├── binomial_heap.ml │ ├── binomial_heap.yml.prp │ ├── depend.ml │ ├── depend.yml.prp │ ├── disj-gte.ml │ ├── disj-gte.yml.prp │ ├── disj.ml │ ├── disj.yml.prp │ ├── higher-order.ml │ ├── higher-order.yml.prp │ ├── last-ev-even.ml │ ├── last-ev-even.yml.prp │ ├── lics18-amortized.ml │ ├── lics18-amortized.yml.prp │ ├── lics18-hoshrink.ml │ ├── lics18-hoshrink.yml.prp │ ├── lics18-web.ml │ ├── lics18-web.yml.prp │ ├── market.ml │ ├── market.yml.prp │ ├── max-min.ml │ ├── max-min.yml.prp │ ├── monotonic.ml │ ├── monotonic.yml.prp │ ├── order-irrel.ml │ ├── order-irrel.yml.prp │ ├── overview1.ml │ ├── overview1.yml.prp │ ├── reentr.ml │ ├── reentr.yml.prp │ ├── resource-analysis.ml │ ├── resource-analysis.yml.prp │ ├── sum-appendix.ml │ ├── sum-appendix.yml.prp │ ├── sum-of-ev-even.ml │ ├── sum-of-ev-even.yml.prp │ ├── temperature.ml │ └── temperature.yml.prp ├── list.ml ├── relation.ml ├── test1 └── untyped.ml /.gitattributes: -------------------------------------------------------------------------------- 1 | perf.txt filter=lfs diff=lfs merge=lfs -text 2 | *.txt filter=lfs diff=lfs merge=lfs -text 3 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | dune build 3 | 4 | clean: 5 | dune clean 6 | -------------------------------------------------------------------------------- /_tags: -------------------------------------------------------------------------------- 1 | : annot, bin_annot 2 | : package(apron), package(apron.boxD), package(apron.boxMPFR), package(apron.boxMPQ), package(apron.octD) 3 | : package(apron.octMPQ),package(apron.polkaMPQ),package(apron.polkaRll), package(apron.ppl), package(apron.polkaGrid) 4 | : package(apron.ppl), package(apron.t1pD), package(apron.t1pMPFR), package(apron.t1pMPR) 5 | true: use_menhir 6 | true : optimize(classic), unbox_closures, inline_max_depth(20), optimization_rounds(20) -------------------------------------------------------------------------------- /comp_bin/hoice_macos: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nyu-acsys/drift/8e24ffeac993d5f6fd37125e212a82f3df33fb78/comp_bin/hoice_macos -------------------------------------------------------------------------------- /comp_bin/r_type_macos: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nyu-acsys/drift/8e24ffeac993d5f6fd37125e212a82f3df33fb78/comp_bin/r_type_macos -------------------------------------------------------------------------------- /comp_bin/r_type_ubuntu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nyu-acsys/drift/8e24ffeac993d5f6fd37125e212a82f3df33fb78/comp_bin/r_type_ubuntu -------------------------------------------------------------------------------- /comp_bin/test_case_format.ml: -------------------------------------------------------------------------------- 1 | let … = 2 | 3 | 4 | let … 5 | 6 | let main = 7 | 8 | // Make all assertion in here 9 | 10 | let _ = main … // if we make a call inside our test cases -------------------------------------------------------------------------------- /drift.opam: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nyu-acsys/drift/8e24ffeac993d5f6fd37125e212a82f3df33fb78/drift.opam -------------------------------------------------------------------------------- /dune: -------------------------------------------------------------------------------- 1 | (dirs src) 2 | (include_subdirs unqualified) 3 | 4 | (executable 5 | (name drift) 6 | (public_name drift) 7 | (libraries gmp apron apron.boxD apron.boxMPFR apron.boxMPQ 8 | apron.octD apron.octMPQ apron.polkaRll 9 | apron.ppl apron.t1pD apron.t1pMPFR apron.t1pMPQ apron.polkaGrid 10 | unix str) 11 | (promote (until-clean))) 12 | 13 | (env 14 | (dev 15 | (flags (:standard -g -warn-error -A -w -27-33 )) 16 | ;(flags (:standard -rectypes -g)) 17 | )) 18 | 19 | -------------------------------------------------------------------------------- /dune-project: -------------------------------------------------------------------------------- 1 | (lang dune 3.4) 2 | (using menhir 2.1) 3 | -------------------------------------------------------------------------------- /scripts/benchexec-drifttoolinfo/drifttoolinfo/__init__.py: -------------------------------------------------------------------------------- 1 | from drifttoolinfo.drift import Tool 2 | from drifttoolinfo.coarmochi import Tool -------------------------------------------------------------------------------- /scripts/benchexec-drifttoolinfo/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | 3 | setup( 4 | name='drifttoolinfo', 5 | version='0.1', 6 | packages=find_packages(), 7 | ) -------------------------------------------------------------------------------- /scripts/effects/Makefile: -------------------------------------------------------------------------------- 1 | 2 | all: 3 | perl makeYamls.pl 4 | rm -Rf benchmark-drift.2023*/* 5 | rm -Rf results/benchmark-* 6 | benchexec benchmark-drift.xml --full-access-dir / --overlay-dir /home 7 | table-generator results/benchmark-drift.*.results.drift-new.effects.xml.bz2 8 | cp results/benchmark-drift.*.results.drift-new.effects.html ./latest-results.html 9 | rm -Rf benchmark-drift*.logfiles 10 | unzip -f results/benchmark-drift*.zip 11 | 12 | remakemochi: 13 | rm -Rf benchmark-coarmochi.2023* 14 | mv -f results/benchmark-* /tmp 15 | sudo benchexec benchmark-coarmochi.xml --full-access-dir / 16 | unzip results/benchmark-*.zip 17 | -------------------------------------------------------------------------------- /scripts/effects/benchexec.cfg: -------------------------------------------------------------------------------- 1 | --read-only-dir 2 | / 3 | --limitCores 4 | 1 5 | --timelimit 6 | 900s 7 | --numOfThreads 8 | 64 -------------------------------------------------------------------------------- /scripts/effects/runNewMochi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for f in `ls ../../../drift/tests/effects/ml_tuple/*.ml`; do 4 | time /tools/home/eric/mochi-clone-mihai/MoCHi/src/mochi.exe $f >> /tmp/newMochi 5 | done 6 | -------------------------------------------------------------------------------- /scripts/effects/unreach-call.prp: -------------------------------------------------------------------------------- 1 | CHECK( init(main()), LTL(G ! call(reach_error())) ) 2 | 3 | -------------------------------------------------------------------------------- /src/effects/dune: -------------------------------------------------------------------------------- 1 | (ocamllex effectAutomataLexer) 2 | (menhir 3 | (modules effectAutomataGrammar) 4 | (flags --explain --dump)) 5 | -------------------------------------------------------------------------------- /src/frontends/dune: -------------------------------------------------------------------------------- 1 | (ocamllex lexer) 2 | (menhir 3 | (modules grammar) 4 | (flags --explain --dump)) 5 | -------------------------------------------------------------------------------- /tests/apply_twice.ml: -------------------------------------------------------------------------------- 1 | 2 | let apply af ax = af ax 3 | 4 | let twice tx = 2 * tx 5 | 6 | let neg_twice nx = 0 - (2 * nx) 7 | 8 | let main (n(*-:{v:Int | true}*)) = 9 | let res = 10 | (if n >= 0 then 11 | apply twice 12 | else 13 | apply neg_twice) n 14 | in 15 | assert(res >= 0) -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/first/01_ic3.ml: -------------------------------------------------------------------------------- 1 | 2 | (* 3 | * IC3 motivating example 4 | *) 5 | 6 | 7 | let rec loop lx ly = 8 | if (ly < 45) then 9 | let t1 = lx in 10 | let t2 = ly in 11 | loop (t1 + t2) (t1 + t2) 12 | else assert (ly >= 1) 13 | 14 | let main (mm:unit(*-:{v:Unit | unit}*)) = 15 | let x = 1 in 16 | let y = 1 in 17 | loop x y -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/first/gcd.ml: -------------------------------------------------------------------------------- 1 | 2 | (* 3 | * Recursive implementation of the greatest common denominator 4 | * using Euclid's algorithm 5 | * 6 | * Author: Jan Leike 7 | * Date: 2013-07-17 8 | * 9 | *) 10 | 11 | 12 | (* Compute the greatest common denominator using Euclid's algorithm *) 13 | 14 | let rec gcd y1 y2 = 15 | if (y1 <= 0 || y2 <= 0) then 0 16 | else if (y1 = y2) then y1 17 | else if (y1 > y2) then 18 | gcd (y1 - y2) y2 19 | else gcd y1 (y2 - y1) 20 | 21 | let main (m:int(*-:{v:Int | true}*)) (n:int(*-:{v:Int | true}*)) = 22 | if m > 0 && n > 0 then 23 | let res = gcd m n in 24 | assert(res <= m && res <= n) 25 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/first/gulwani_cegar1.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec loop lx ly ln = 3 | if (ln < 10) then 4 | loop (lx + 2) (ly + 2) (ln + 1) 5 | else lx <> 4 || ly <> 0 6 | 7 | let main (x:int(*-:{v:Int | true}*)) (y:int(*-:{v:Int | true}*)) (n:int(*-:{v:Int | true}*)) = 8 | if (0 <= x && x <= 2 && 0 <= y && y <= 2 && 0 <= n) then 9 | assert(loop x y n = true) 10 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/first/pldi082_unbounded1.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec loop (lx:int) (ly:int) (ln:int) = 3 | let ny = 4 | if (lx <= ln) then ly + 1 5 | else if (lx >= ln + 1) then ly - 1 6 | else (-4) 7 | in 8 | if (ny < 0) then 9 | if ln >= 0 then 10 | if ny = (-1) then (lx < 2 * ln + 3) 11 | else true 12 | else true 13 | else loop (lx+1) ny ln 14 | 15 | let main (n:int(*-:{v:Int | true}*)) = 16 | let x = 0 in 17 | let y = 0 in 18 | if (n >= 0) then assert(loop x y n = true) 19 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/first/pldi082_unbounded2.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec loop (lx:int) (ly:int) (ln:int) = 3 | let ny = 4 | if (lx <= ln) then ly + 1 5 | else if (lx >= ln+1) then ly - 1 6 | else (-4) in 7 | if (ny < 0) then 8 | if ln >= 0 then 9 | if ny = (-1) then (lx < 2 * ln + 3) 10 | else false 11 | else false 12 | else loop (lx+1) ny ln 13 | 14 | let main (n:int(*-:{v:Int | true}*)) = 15 | let x:int = 0 in 16 | let y:int = 0 in 17 | if(n < 0) then 18 | assert(loop x y n = false) 19 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/first/prog2.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loop lx ly = 4 | if lx <= 9 then 5 | loop (lx + 1) (ly+1) 6 | else 7 | assert (ly >= 0) 8 | 9 | let main (m:unit(*-:{v:Unit | unit}*)) = 10 | let x = 0 in 11 | let y = 0 in 12 | loop x y -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/first/recHanoi03.ml: -------------------------------------------------------------------------------- 1 | 2 | (* 3 | * recHanoi.c 4 | * 5 | * Created on: 17.07.2013 6 | * Author: Stefan Wissert 7 | *) 8 | 9 | 10 | (* 11 | * This function returns the optimal amount of steps, 12 | * needed to solve the problem for n-disks 13 | *) 14 | 15 | 16 | let rec hanoi n = 17 | if (n <= 1) then 1 18 | else 2 * (hanoi (n - 1)) + 1 19 | 20 | 21 | let main (k:unit(*-:{v:Unit | unit}*)) = 22 | let n = 13 in 23 | let result = hanoi n in 24 | assert (result >= n) -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/first/substring1.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec loop lk li lj = 3 | if (lj < li) then 4 | loop lk (li) (lj+1) 5 | else lj < 31 6 | 7 | let main (k:int(*-:{v:Int | true}*)) (toi:int(*-:{v:Int | true}*)) = 8 | if (k >= 0 && k <= 30 && toi >= 0 && toi <= k) then 9 | (let i = toi in 10 | let j = 0 in 11 | assert (loop k i j = true)) 12 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/first/substring2.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loop lk li lj = 4 | if (li < lk) then 5 | loop lk (li+1) (lj+1) 6 | else lj < 31 7 | 8 | let main (k:int(*-:{v:Int | true}*)) (from:int(*-:{v:Int | true}*)) = 9 | if (k >= 0 && k <= 30 && from >= 0 && from <= k) then 10 | (let i = from in 11 | let j = 0 in 12 | assert (loop k i j = true)) 13 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/first/up2.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loopa ai ak an = 4 | if ai < an then 5 | loopa (ai + 1) (ak + 1) an 6 | else ak 7 | 8 | let rec loopb bj bk bn = 9 | if bj < bn then 10 | if bk > 0 then 11 | loopb (bj + 2) (bk - 1) bn 12 | else -1 13 | else bk 14 | 15 | let main (n:int(*-:{v:Int | true}*)) = 16 | if n > 0 then 17 | let i = 0 in 18 | let k = 0 in 19 | let ans = loopa i k n in 20 | let j = 0 in 21 | assert(loopb j ans n <= n) 22 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/first/xy0.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loopa lx ly = 4 | if (ly < 10) then 5 | loopa (lx + 1) (ly + 1) 6 | else lx 7 | 8 | let rec loopb bx by = 9 | if (bx > 0) then 10 | loopb (bx - 1) (bx - 1) 11 | else assert (by > (-1)) 12 | 13 | let main (mm:unit(*-:{v:Unit | unit}*)) = 14 | let x = 0 in 15 | let y = 0 in 16 | 17 | loopa x y -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/first/xy10.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loopa ax ay az = 4 | if (ay < 20) then 5 | loopa (ax+10) (ay+1) az 6 | else 7 | ax > az || ay < az + 1 8 | 9 | let main (z:int(*-:{v:Int | true}*)) = 10 | let x = 0 in 11 | let y = 0 in 12 | assert (loopa x y z = true) -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/first/xy4.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loopa ax ay = 4 | if ay < 4 then 5 | loopa (ax + 4) (ay + 1) 6 | else ax 7 | 8 | let rec loopb bx by = 9 | if bx > 0 then 10 | loopb (bx - 4) (by - 1) 11 | else by > (-1) 12 | 13 | let main (mm:unit(*-:{v:Unit | unit}*)) = 14 | let x = 0 in 15 | let y = 0 in 16 | 17 | let rx = loopa x y in 18 | assert (loopb rx 4 = true) 19 | -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/first/xyz.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loopa ax ay az = 4 | if (ax < 10) then 5 | loopa (ax + 1) (ay + 1) (az - 2) 6 | else az 7 | 8 | let rec loopb bx by bz = 9 | if (bx > 0) then 10 | (let rz = bz + 2 in 11 | let rx = bx - 1 in 12 | let ry = by - 1 in 13 | loopb rx ry rz) 14 | else bz > (-1) 15 | 16 | let main (mm:unit(*-:{v:Unit | unit}*)) = 17 | let x = 0 in 18 | let y = 0 in 19 | let z = 0 in 20 | 21 | let rsz = loopa x y z in 22 | let rsx = 10 in 23 | assert (loopb rsx rsx rsz = true) -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/first/xyz2.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loopa ax ay az = 4 | if (ax < 10) then 5 | loopa (ax + 1) (ay + 1) (az - 2) 6 | else az 7 | 8 | let rec loopb bx by bz = 9 | if (bx >= 1) then 10 | let rz = bz + 2 in 11 | let rx = bx - 1 in 12 | let ry = by - 1 in 13 | loopb rx ry rz 14 | else 15 | bz < 1 16 | 17 | let main (mm:unit(*-:{v:Unit | unit}*)) = 18 | let x = 0 in 19 | let y = 0 in 20 | let z = 0 in 21 | 22 | let rsz = loopa x y z in 23 | let rsx = 10 in 24 | assert (loopb rsx rsx rsz = true) -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/high/app-lin-ord2.ml: -------------------------------------------------------------------------------- 1 | 2 | let app (ab:int) (af:int->unit) ax = af ax 3 | 4 | let check (cx:int) (cy:int) = assert (cx = cy) 5 | 6 | let main (a:int(*-:{v:Int | true}*)) (b:int(*-:{v:Int | true}*)) = 7 | app (4 * a + 2 * b) (check (4 * a + 2 * b)) (4 * a + 2 * b) -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/high/app-lin-ord3.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let app (ab:int) (af:int->(int->unit)->unit) aa (ag:int->unit) = af aa ag 4 | 5 | let f (fx:int) (fa:int) (fk:int->unit) = fk fx 6 | 7 | let check (x:int) (y:int) = assert (x = y) 8 | 9 | let main (a:int(*-:{v:Int | true}*)) (b:int(*-:{v:Int | true}*)) = 10 | app (4 * a + 2 * b) (f (4 * a + 2 * b)) (4 * a + 2 * b) (check (4 * a + 2 * b)) 11 | -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/high/app-nonrec.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let apply (ab:int) (af: int->unit) ax = af ax 4 | 5 | let check (cx:int) (cy:int) = assert (cx = cy) 6 | 7 | let main (n:int(*-:{v:Int | true}*)) = 8 | apply n (check n) n 9 | -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/high/app-succ.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let succ (sb:int) (sf:int->unit) sx = sf (sx + 1) 4 | 5 | let rec app (b:int) (f:int->unit) x (k:int) = 6 | if k > 0 then app (b - 1) (succ (b - 1) f) (x - 1) (k - 1) else f x 7 | 8 | let check (cx:int) (cy:int) = assert (cx <= cy) 9 | 10 | let main (n:int(*-:{v:Int | true}*)) (m:int(*-:{v:Int | true}*)) = app n (check n) n m 11 | -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/high/intro-ord2.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec app (a:int) (f:int->unit) (x:int) (k:int) = 3 | if k > 0 then 4 | app a f (x + 1) (k - 1) 5 | else f x 6 | 7 | let check (cx:int) (cy:int) = assert (cx <= cy) 8 | 9 | let main (i:int(*-:{v:Int | true}*)) (j:int(*-:{v:Int | true}*)) = app i (check i) i j 10 | -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/high/intro-ord3.ml: -------------------------------------------------------------------------------- 1 | 2 | let succ (sb:int) (sf:int->unit) sx = sf (sx + 1) 3 | 4 | let rec app3 (b:int) (f:int->unit) (a:int) (g:int->(int->unit)->unit) (k:int) = 5 | if k > 0 then app3 b (succ b f) b g (k - 1) else g b f 6 | 7 | let app ax (ab:int) (af:int->unit) = af ax 8 | 9 | let check (cx:int) (cy:int) = assert (cx <= cy) 10 | 11 | let main (i:int(*-:{v:Int | true}*)) (j:int(*-:{v:Int | true}*)) = app3 i (check i) i (app i) j 12 | -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/high/repeat_order.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec repeat (f:int->int) n s = 3 | if n = 0 then 4 | s 5 | else 6 | f (repeat f (n - 1) s) 7 | 8 | let succ x = x + 1 9 | 10 | let main (mn:int(*-:{v:Int | true}*)) = 11 | assert(repeat succ mn 0 >= mn) 12 | -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/list/fold_div.ml: -------------------------------------------------------------------------------- 1 | let rec fold_left f (acc:int) (xs:int list) = 2 | match xs with 3 | [] -> acc 4 | | x::xs' -> fold_left f (f acc x) xs' 5 | 6 | let rec make_list n = 7 | if n <= 0 then [] 8 | else n :: make_list (n - 1) 9 | 10 | let div x y = (assert (y <> 0); x / y) 11 | 12 | let main (n:int(*-:{v:Int | true}*)) (m:int(*-:{v:Int | true}*)) = 13 | if n > 0 && m > 0 then 14 | let xs = make_list n in 15 | assert(fold_left div m xs >= 0) 16 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/list/fold_fun_list.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec make_list n = 4 | if n <= 0 5 | then [] 6 | else (fun m -> n + m) :: make_list (n - 1) 7 | 8 | let rec fold_right (f:(int->int)->(int->int)->int->int) (xs:(int->int) list) (init:int->int) = 9 | match xs with 10 | [] -> init 11 | | x::xs' -> f x (fold_right f xs' init) 12 | 13 | let compose (f:int->int) (g:int->int) (d:int) = f (g d) 14 | 15 | let id (c:int) = c 16 | 17 | let main (n:int(*-:{v:Int | true}*)) = 18 | if n > 0 then 19 | let xs = make_list n in 20 | let f = fold_right compose xs id in 21 | assert (f 0 >= 0) 22 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/list/fold_left.ml: -------------------------------------------------------------------------------- 1 | let rec fold_left (f:int->int->int) acc xs = 2 | match xs with 3 | [] -> acc 4 | | x::xs' -> fold_left f (f acc x) xs' 5 | 6 | let rec make_list n = 7 | if n < 0 then [] 8 | else n :: make_list (n - 1) 9 | 10 | let add x y = x + y 11 | 12 | let main (n:int(*-:{v:Int | true}*)) (m:int(*-:{v:Int | true}*)) = 13 | if n > 0 then 14 | let xs = make_list n in 15 | assert (fold_left add m xs >= m) 16 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/list/fold_right.ml: -------------------------------------------------------------------------------- 1 | let rec fold_right (f:int->int->int) xs acc = 2 | match xs with 3 | [] -> acc 4 | | x::xs' -> f x (fold_right f xs' acc) 5 | 6 | let rec make_list n = 7 | if n < 0 8 | then [] 9 | else n :: make_list (n - 1) 10 | 11 | let add x y = x + y 12 | 13 | let main (n:int(*-:{v:Int | true}*)) (m:int(*-:{v:Int | true}*)) = 14 | if n > 0 && m > 0 then 15 | let xs = make_list n in 16 | assert (fold_right add xs m >= m) 17 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/list/forall_leq.ml: -------------------------------------------------------------------------------- 1 | let rec for_all f (xs:int list) = 2 | match xs with 3 | [] -> 1 4 | | x::xs' -> 5 | if (f x > 0) && (for_all f xs' > 0) then 1 6 | else 0 7 | 8 | let check x = 9 | if (x >= 0) then 1 10 | else 0 11 | 12 | let rec make_list n = 13 | if n < 0 14 | then [] 15 | else n :: make_list (n - 1) 16 | 17 | let main (n:int(*-:{v:Int | true}*)) = 18 | if n > 0 then 19 | assert (for_all check (make_list n) > 0) 20 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/list/introlist.ml: -------------------------------------------------------------------------------- 1 | let rec make_list m = 2 | if m <= 0 then [] 3 | else m :: make_list (m - 1) 4 | 5 | let f xs = match xs with 6 | | [] -> () 7 | | x :: xs -> assert (x > 0) 8 | 9 | let main (n:int(*-:{v:Int | true}*)) = 10 | let xs = make_list n in 11 | f xs -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/list/isnil.ml: -------------------------------------------------------------------------------- 1 | let is_nil (xs:int list) = 2 | match xs with 3 | [] -> 1 4 | | _ -> 0 5 | 6 | let rec make_list n = 7 | if n = 0 8 | then [] 9 | else n :: make_list (n - 1) 10 | 11 | let main (n:int(*-:{v:Int | true}*)) = 12 | if n > 0 13 | then 14 | let xs = make_list n in 15 | assert((is_nil xs) <> 1) 16 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/list/iter.ml: -------------------------------------------------------------------------------- 1 | let rec iter (f:int -> unit) xs = 2 | match xs with 3 | [] -> () 4 | | x::xs' -> f x; iter f xs' 5 | 6 | let rec make_list n = 7 | if n < 0 8 | then [] 9 | else n :: make_list (n - 1) 10 | 11 | let check x = assert (x >= 0) 12 | 13 | let main (n:int(*-:{v:Int | true}*)) = 14 | if n > 0 then 15 | let xs = make_list n in 16 | iter check xs 17 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/list/length.ml: -------------------------------------------------------------------------------- 1 | let rec length (xs:int list) = 2 | match xs with 3 | [] -> 0 (*l=0 v=0*) 4 | | x::xs' -> 1 + length xs' (*n>=l>=1 v=1*) 5 | 6 | let rec make_list n = 7 | if n = 0 8 | then [] (* 'a list *) 9 | else n :: make_list (n - 1) 10 | 11 | let main (n:int(*-:{v:Int | true }*)) = 12 | if n > 0 then 13 | let xs = make_list n in 14 | assert (length xs = n) 15 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/list/list.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec make_list n = 3 | if n <= 0 4 | then [] 5 | else n :: make_list (n - 1) 6 | 7 | let rec length (xs:int list) = 8 | match xs with 9 | [] -> 0 10 | | x::xs' -> 1 + length xs' 11 | 12 | let main (n:unit(*-:{v:Unit | unit}*)) = 13 | let xs = [0; 1; 2] in 14 | let ys = make_list 3 in 15 | assert(length xs = length ys) -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/list/mem.ml: -------------------------------------------------------------------------------- 1 | let rec mem (x:int) (xs:int list) = 2 | match xs with 3 | [] -> 0 4 | | x'::xs' -> 5 | if x = x' then 1 6 | else if (mem x xs' > 0) then 1 7 | else 0 8 | 9 | let rec make_list n (x:int) = 10 | if n < 0 11 | then [] 12 | else x :: make_list (n - 1) x 13 | 14 | let main (n:int(*-:{v:Int | true}*)) (m:int(*-:{v:Int | true}*)) = 15 | if n > 0 then 16 | let xs = make_list n m in 17 | match xs with 18 | | [] -> () 19 | | x::xs' -> assert (mem m xs > 0) 20 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/list/nth.ml: -------------------------------------------------------------------------------- 1 | let rec nth n (xs:int list) = 2 | match xs with 3 | | [] -> -1 4 | | x::xs' -> if n = 0 then x else nth (n - 1) xs' 5 | 6 | let rec make_list n = 7 | if n < 0 8 | then [] 9 | else n :: make_list (n - 1) 10 | 11 | let main (n:int(*-:{v:Int | true}*)) = 12 | if n > 0 then 13 | let xs = make_list n in 14 | assert(nth (n - 1) xs >= 0) 15 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/list/reverse.ml: -------------------------------------------------------------------------------- 1 | 2 | (*rename error*) 3 | let rec reverseinner (xs:int list) (acc:int list) = 4 | match xs with 5 | [] -> acc 6 | | x :: xs' -> reverseinner xs' (x :: acc) 7 | 8 | let reverse (xs:int list) = reverseinner xs [] 9 | 10 | let rec make_list n = 11 | if n = 0 12 | then [] 13 | else n :: make_list (n - 1) 14 | 15 | let hd (xs:int list) = 16 | match xs with 17 | [] -> -1 18 | | x::xs' -> x 19 | 20 | let main (n:int(*-:{v:Int | true}*)) = 21 | if n > 0 then 22 | let xs = make_list n in 23 | assert(hd (reverse xs) > 0) 24 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DOrder/list/zip.ml: -------------------------------------------------------------------------------- 1 | let rec zip (xs:int list) (ys:int list) = 2 | match xs with 3 | [] -> ( 4 | match ys with 5 | [] -> [] 6 | | y::ys' -> assert(false) ; [] 7 | ) 8 | | x::xs' -> 9 | (match ys with 10 | [] -> assert(false) ; [] 11 | | y::ys' -> (x, y)::(zip xs' ys')) 12 | 13 | let rec make_list n = 14 | if n < 0 15 | then [] 16 | else n :: make_list (n - 1) 17 | 18 | let main (n:int(*-:{v:Int | true}*)) = 19 | if n > 0 then 20 | let xs = make_list n in 21 | let ys = zip xs xs in 22 | assert(List.length ys = List.length xs) 23 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/array/a-dotprod.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as a-prod 3 | *) 4 | 5 | let rec dotprod dn (vd1: int array) (vd2: int array) di sum = 6 | if di >= dn then 7 | sum 8 | else 9 | dotprod dn vd1 vd2 (di + 1) (sum + (Array.get vd1 di) * (Array.get vd2 di)) 10 | 11 | let main (z(*-:{v:Int | true}*)) (n(*-:{v:Int | true}*)) = 12 | if z = 0 && n > 0 then 13 | let v1 = Array.make n 1 in 14 | let v2 = Array.make n 1 in 15 | dotprod n v1 v2 z z; () 16 | else () 17 | -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/array/a-init1.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as a-init 3 | *) 4 | 5 | 6 | let rec init idx tn (ia: int array) = 7 | if idx < 0 then init 0 tn ia 8 | else if idx >= tn then () 9 | else (Array.set ia idx 1; init (idx + 1) tn ia) 10 | 11 | let main (k(*-:{v:Int | true}*)) (n(*-:{v:Int | true}*)) (i(*-:{v:Int | true}*)) = 12 | if i >= k && i >= 0 && i < n then 13 | (let a = Array.make n 0 in 14 | init k n a; 15 | let item = Array.get a i in 16 | assert(item >= 1)) 17 | else () 18 | 19 | -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/array/a-init2.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec init idx tn (ta: int array) = 4 | if idx >= tn then () 5 | else (Array.set ta idx 1; init (idx + 1) tn ta) 6 | 7 | let main (n(*-:{v:Int | true}*)) (i(*-:{v:Int | true}*)) = 8 | if i >= 0 && i < n then 9 | let a = Array.make n 0 in 10 | init i n a; 11 | let item = Array.get a i in 12 | assert(item >= 1) (* check that the array has been revised *) 13 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/array/a-iter.ml: -------------------------------------------------------------------------------- 1 | 2 | let succ si = si + 1 3 | 4 | let rec iter_helper (hf: int -> int) hi hn (ha: int array) = 5 | if (hi < hn) then 6 | let _ = hf (Array.get ha hi) in 7 | iter_helper hf (hi + 1) hn ha 8 | else () 9 | 10 | let rec iter (mf: int -> int) (ma: int array) = 11 | let mn = Array.length ma in 12 | iter_helper mf 0 mn ma 13 | 14 | let main (n(*-:{v:Int | true}*)) = 15 | if n > 0 then 16 | let a = Array.make n 0 in 17 | iter succ a 18 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/array/a-map.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec map_helper (hf: int -> int) hi hn (ha: int array) (hb: int array) = 3 | if (hi < hn) then 4 | let _ = Array.set hb hi (hf (Array.get ha hi)) in 5 | map_helper hf (hi + 1) hn ha hb 6 | else hb 7 | 8 | let rec map (mf: int -> int) (ma: int array) = 9 | let mn = Array.length ma in 10 | let mb = Array.make mn 0 in 11 | map_helper mf 0 mn ma mb 12 | 13 | let succ si = si + 1 14 | 15 | let main (n:int(*-:{v:Int | true}*)) = 16 | if n > 0 then 17 | let a = Array.make n 0 in 18 | assert(Array.length (map succ a) = Array.length a) 19 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/array/a-mapi.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec mapi_helper (hf: int -> int -> int) hi hn (ha: int array) (hb: int array) = 3 | if (hi < hn) then 4 | let _ = Array.set hb hi (hf hi (Array.get ha hi)) in 5 | mapi_helper hf (hi + 1) hn ha hb 6 | else hb 7 | 8 | let rec mapi (mf: int -> int -> int) (ma: int array) = 9 | let mn = Array.length ma in 10 | let mb = Array.make mn 0 in 11 | mapi_helper mf 0 mn ma mb 12 | 13 | let add_idx sidx si = sidx + si 14 | 15 | let main (n:int(*-:{v:Int | true}*)) = 16 | if n > 0 then 17 | let a = Array.make n 0 in 18 | assert(Array.length (mapi add_idx a) = Array.length a) 19 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/array/a-reverse.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec reverse ri rn (ra: int array) (rb: int array) = 4 | if (ri < rn) then 5 | let _ = Array.set rb (rn - ri - 1) (Array.get ra ri) in 6 | reverse (ri + 1) rn ra rb 7 | else () 8 | 9 | let main (n(*-:{v:Int | true}*)) = 10 | if n > 0 then 11 | let a = Array.make n 0 in 12 | let b = Array.make n 0 in 13 | reverse 0 n a b 14 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/array/bcopy.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec bcopy_aux (src: int array) (des: int array) i m = 3 | if i >= m then true 4 | else 5 | ( 6 | Array.set des i (Array.get src i); 7 | 0 <= i && i < (Array.length src) && bcopy_aux src des (i+1) m 8 | ) 9 | 10 | let bcopy (src: int array) (des: int array) = bcopy_aux src des 0 (Array.length src) 11 | 12 | let main (mn(*-:{v:Int | true}*)) (mm(*-:{v:Int | true}*)) = 13 | if mn > 0 && mn <= mm then 14 | let array1 = Array.make mn 0 in 15 | let array2 = Array.make mm 0 in 16 | assert(bcopy array1 array2 = true) 17 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/first/addition.ml: -------------------------------------------------------------------------------- 1 | (* 2 | From: jayhorn/benchmarks SatAddition01_true.java 3 | *) 4 | 5 | let rec addition (lm:int) (ln:int) = 6 | if ln = 0 then lm 7 | else if ln > 0 then 8 | addition (lm + 1) (ln - 1) 9 | else addition (lm - 1) (ln + 1) 10 | 11 | let main (m:int(*-:{v:Int | true}*)) (n:int(*-:{v:Int | true}*)) = 12 | if n > 0 && m > 0 then 13 | assert(addition m n = m + n) 14 | else () 15 | 16 | (* let _ = 17 | for i = 1 to 1000000 do 18 | main (Random.int 1000) (Random.int 1000) 19 | done *) -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/first/for_bounded_loop1.ml: -------------------------------------------------------------------------------- 1 | (* 2 | From: SV-COMP 2020 for_bounded_loop1.c 3 | *) 4 | 5 | let rec loop (i:int) (n:int) (x:int) (y:int) = 6 | if i >= n then x - y 7 | else 8 | let xp = x - y in 9 | assert(xp = 0); 10 | let yp = y + i in 11 | loop (i + 1) n (xp + yp) (yp) 12 | 13 | let main (n:int(*-:{v:Int | true}*)) = 14 | if n <= 0 then () 15 | else assert(loop 0 n 0 0 = 0) 16 | 17 | (* let _ = 18 | for i = 1 to 10000 do 19 | main (Random.int 1000) 20 | done *) -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/first/half.ml: -------------------------------------------------------------------------------- 1 | (* 2 | From: SV-COMP 2020 half.c 3 | https://github.com/sosy-lab/sv-benchmarks/blob/master/c/loop-new/half.c 4 | *) 5 | 6 | let rec half i k n = 7 | if i >= 2 * k then assert(n = k) 8 | else 9 | if i mod 2 = 0 then 10 | half (i + 1) k (n + 1) 11 | else half (i + 1) k n 12 | 13 | let main (mn:int(*-:{v:Int | true}*)) = 14 | if mn < 0 then () 15 | else half 0 mn 0 16 | 17 | (* let _ = 18 | for i = 1 to 10000 do 19 | main (Random.int 10000) 20 | done *) -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/first/hanoi.ml: -------------------------------------------------------------------------------- 1 | (* 2 | From: jayhorn/benchmarks SatHanoi01_true.java 3 | *) 4 | 5 | let rec hanoi (hn:int) = 6 | if hn = 1 then 1 7 | else 2 * (hanoi (hn - 1)) + 1 8 | 9 | let rec apply_hanoi (an:int) (from:int) (too:int) (via:int) = 10 | if an = 0 then 0 11 | else apply_hanoi (an - 1) from via too 12 | + apply_hanoi (an - 1) via too from + 1 13 | 14 | let main (n:int(*-:{v:Int | true}*)) = 15 | if n < 1 || n > 31 then () 16 | else 17 | let res1 = apply_hanoi n 1 3 2 in 18 | let res2 = hanoi n in 19 | assert(res1 = res2) 20 | 21 | (* let _ = 22 | for i = 1 to 10 do 23 | main (Random.int 31) 24 | done *) -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/first/inductive1-2.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loop x i = 4 | if i < 0 then 5 | x 6 | else if x < 1 then 7 | loop (x - 1) (i - 1) 8 | else if x > 2 then 9 | loop x (i - 1) 10 | else 11 | loop (3 - x) (i - 1) 12 | 13 | let main (n:int(*-:{v:Int | true}*)) = 14 | assert (loop (-3) n <= (-3)) -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/first/inductive1-3.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec loop x i = 3 | if i < 0 then 4 | x 5 | else if x < 1 then 6 | loop (x - 1) (i - 1) 7 | else if x > 2 then 8 | loop x (i - 1) 9 | else 10 | loop (3 - x) (i - 1) 11 | 12 | let main (n:int(*-:{v:Int | true}*)) = 13 | assert (loop (-3) n <= (-3)) -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/first/inductive3-3.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec f x = 4 | if x < -1 then 5 | f (-2) 6 | else if x <= 1 then 7 | 2 * x - 1 8 | else 9 | x 10 | 11 | let main (n:int(*-:{v:Int | true}*)) = 12 | if n >= 2 then assert(f n >= 0) 13 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/first/inductive4-1.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec f g x = 4 | if x < (-3) then (* x<=-4 *) 5 | f g (-4) 6 | else if x <= 1 then (* -3<=x<=1 *) 7 | g x 8 | else (* x>1 *) 9 | f (f g) (x - 2) 10 | 11 | let incr y = y + 1 12 | 13 | let main (n:int(*-:{v:Int | true}*)) = 14 | assert(f incr n >= -3) 15 | -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/first/inductive5-2.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec f x = 3 | if x < -2 then 4 | f (-3) 5 | else if x < 2 then 6 | 2 * x - 1 7 | else if x <= 2 then 8 | f (2 * x - 1) 9 | else 10 | x 11 | 12 | let main (n:int(*-:{v:Int | true}*)) = 13 | if n > -2 then assert(f n >= (-3)) 14 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/first/inductivea.ml: -------------------------------------------------------------------------------- 1 | (* 2 | From: jayhorn/benchmarks TestLoop2_true.java and TestLoop3_true.java 3 | *) 4 | 5 | let rec loop (lx:int) (ly:int) = 6 | if lx = 0 then ly 7 | else loop (lx - 1) (ly - 1) 8 | 9 | let rec loopb (bx:int) (by:int) = 10 | if bx < by then loopb (bx + by) by 11 | else assert(bx >= by) 12 | 13 | let main (i:int(*-:{v:Int | true}*)) (j:int(*-:{v:Int | true}*)) = 14 | if i < 0 && j < 0 then () 15 | else 16 | let x = i in 17 | let y = j in 18 | assert(loop x y + i <= j); 19 | loopb i j 20 | 21 | (* let _ = 22 | for i = 1 to 10000 do 23 | main (Random.int 1000) (Random.int 1000) 24 | done *) -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/first/mult_twice.ml: -------------------------------------------------------------------------------- 1 | (* 2 | From: jayhorn/benchmarks MultCommutative01_true.java 3 | *) 4 | 5 | let rec mult (mn:int) (mm:int) = 6 | if mn <= 0 || mm <= 0 then 7 | 0 8 | else 9 | mn + mult mn (mm - 1) 10 | 11 | let main (n:int(*-:{v:Int | true}*)) (m:int(*-:{v:Int | true}*)) = 12 | if m < 0 && n < 0 then () 13 | else 14 | let res1 = mult m n in 15 | let res2 = mult n m in 16 | assert(res1 = res2) 17 | 18 | (* let _ = 19 | for i = 1 to 10000 do 20 | main (Random.int 1000) (Random.int 1000) 21 | done *) -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/first/odd_even.ml: -------------------------------------------------------------------------------- 1 | (* 2 | Revised From: jayhorn/benchmarks SatHanoi01_true.java 3 | *) 4 | 5 | let rec is_odd on = 6 | if on = 0 then false 7 | else if on = 1 then true 8 | else is_odd (on - 2) 9 | 10 | let rec is_even en = 11 | if en = 0 then true 12 | else if en = 1 then false 13 | else is_even (en - 2) 14 | 15 | let main (n:int(*-:{v:Int | true}*)) = 16 | if n > 0 then 17 | if n mod 2 = 0 then 18 | assert(is_even n) 19 | else if n mod 2 = 1 then 20 | assert(is_odd n) 21 | else () 22 | else () 23 | 24 | (* let _ = 25 | for i = 1 to 10000 do 26 | main (Random.int 1000) 27 | done *) -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/first/sum6.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec sum n = 4 | if n <= 0 5 | then 0 6 | else n + sum (n - 1) 7 | 8 | let main (mn:int(*-:{v:Int | true}*)) = 9 | assert (6 * mn - 15 <= sum mn) 10 | 11 | (* let _ = 12 | for i = 1 to 1000 do 13 | main (Random.int 1000) 14 | done *) -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/first/up_down_stair.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec up_stair (ui:int) (un:int) = 4 | if ui = un then ui 5 | else up_stair (ui + 1) un 6 | 7 | 8 | let rec down_stair (di:int) (dn:int) = 9 | if di = 0 then di 10 | else down_stair (di - 1) dn 11 | 12 | 13 | let rec loop (lk:int) (ln:int) (res:int) = 14 | if lk = 0 then ln = res 15 | else 16 | (let up = up_stair 0 ln in (* up = ln*) 17 | let down = down_stair up ln in (* down = 0*) 18 | loop (lk - 1) ln (down + ln)) 19 | 20 | let main (k:int(*-:{v:Int | true}*)) (n:int(*-:{v:Int | true}*)) = 21 | if k > 0 && n > 0 then 22 | assert(loop k n n = true) 23 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/high/apply-cr.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as apply 3 | *) 4 | 5 | 6 | let apply f x = f x 7 | let g (y:int) (z:int) = assert(y = z) 8 | let rec k i n = if i >= n then () else (apply (g n) n; k (i+1) n) 9 | 10 | let main (n:int(*-:{v:Int | true}*)) = 11 | k 0 n -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/high/apply_twice.ml: -------------------------------------------------------------------------------- 1 | 2 | let apply (af:int -> int) (ax:int) = af ax 3 | 4 | let twice (tx:int) = 2 * tx 5 | 6 | let neg_twice (nx:int) = 0 - (2 * nx) 7 | 8 | let main (n:int(*-:{v:Int | true}*)) = 9 | let res = 10 | if n >= 0 then 11 | apply twice n 12 | else 13 | apply neg_twice n 14 | in 15 | assert(res >= 0) -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/high/call_back.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let mk_adder (x:int) = 4 | let adder (i:int) = i + x in 5 | adder 6 | 7 | let main (mx:int(*-:{v:Int | true}*)) (mi:int(*-:{v:Int | true}*)) = 8 | let addr = mk_adder mx in 9 | assert (addr mi = mi + mx) 10 | -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/high/flip_twice_1.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let twice tf (tx:int) (ty:int) = tf (tf tx ty) ty 4 | 5 | let flip (f: int -> int -> int) (x:int) (y:int) = f y x 6 | 7 | let square_diff sx sy = (sx + sy) * (sx - sy) 8 | 9 | let main (mx:int(*-:{v:Int | true}*)) (my:int(*-:{v:Int | true}*)) = 10 | if mx >= 0 && my >= 0 && mx > my then 11 | assert(flip (twice square_diff) my mx >= my) 12 | else if mx >= 0 && my >= 0 && mx < my then assert(flip (twice square_diff) mx my >= mx) 13 | else assert(true) 14 | 15 | (* Proof, for a > b >= 0 16 | a^2 - b^2 = (a + b)(a - b) >= (a + b) > b 17 | (a^2 - b^2)^2 - b^2 = (a^2 - b^2 + b)(a^2 - b^2 - b) > (a^2 - b^2 + b) > 2b > b 18 | *) -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/high/flip_twice_2.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | let twice tf (tx:int) (ty:int) = tf (tf tx ty) ty 5 | 6 | let flip (f: int -> int -> int) (x:int) (y:int) = f y x 7 | 8 | let square_diff sx sy = (sx + sy) * (sx - sy) 9 | 10 | let main (mx:int(*-:{v:Int | true}*)) = 11 | let res = flip (twice square_diff) mx mx 12 | in 13 | assert(res = mx * (0 - mx)) 14 | 15 | (* 16 | mx : { v: int | v = mx} 17 | (0 - mx) : {v: int | v = -mx} 18 | mx * (0 - mx): {v:int | top} 19 | *) -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/high/foldl.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec accumulate (af:int -> int -> int) (an:int) (au:int) = (* foldl *) 3 | if an = 0 then au 4 | else accumulate af (an - 1) (af an au) 5 | 6 | let rec accumulate_neg (nf:int -> bool -> bool) (nn:int) (nu:bool) = (* foldl *) 7 | if nn = 0 then nu 8 | else accumulate_neg nf (nn - 1) (nf nn nu) 9 | 10 | let gt_100 (gk:int) (gt:int) = if gk > 100 then 100 else gt 11 | 12 | let and_not_0 (ak:int) (at:bool) = at && ak <> 0 13 | 14 | let main (n:int(*-:{v:Int | true}*)) = 15 | if n > 0 then 16 | assert(accumulate gt_100 n 100 = 100) 17 | else 18 | let m = 0 - n in 19 | assert(accumulate_neg and_not_0 m true = true) 20 | 21 | -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/high/map_2.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec map1 (f1: int -> int) x1 = 4 | if x1 <= 0 5 | then x1 6 | else x1 + (f1 (map1 f1 (x1 - 1))) 7 | 8 | let rec map2 (f2: int -> int) x2 = 9 | if x2 <= 0 10 | then x2 11 | else x2 + (f2 (map2 f2 (x2 - 1))) 12 | 13 | let id ix = ix 14 | 15 | let succ sx = sx + 1 16 | 17 | let main (n(*-:{v:Int | true}*)) = 18 | if n > 0 then 19 | assert(map1 id n >= n) 20 | else 21 | let m = 0 - n in 22 | assert(map2 succ m >= 2 * m) 23 | -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/high/mixed_id.ml: -------------------------------------------------------------------------------- 1 | 2 | let id_int (x_idi:int) = x_idi 3 | 4 | let id_f (x_idf:int -> int) = x_idf 5 | 6 | let mid_y (yk:int) = id_int yk 7 | 8 | let z x = id_f x 9 | 10 | let main (k:int(*-:{v:Int | true}*)) = 11 | assert(z mid_y k = k) -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/high/multi_compose.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let mf (fx:int) = fx + 5 4 | 5 | let mg (gx:int) = 2 * gx 6 | 7 | let mh (hx:int) = hx - 5 8 | 9 | let compose_1 (f1:int -> int) (g1:int -> int) (x1:int) = f1 (g1 x1) 10 | 11 | let compose_2 (f2:int -> int) (g2:int -> int) (x2:int) = g2 (f2 x2) 12 | 13 | let main (mx:int(*-:{v:Int | true}*)) = 14 | let ans1 = mh (compose_1 mf mg mx) = 2 * mx in 15 | let ans2 = mf (compose_2 mg mh mx) = 2 * mx in 16 | assert(ans1 && ans2 = true) 17 | -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/high/power.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let comp (cf:int -> int) (cg:int -> int) cx = cf (cg cx) 4 | 5 | let id (dx:int) = dx 6 | 7 | let rec power (f: int -> int) i = 8 | if i = 0 then id 9 | else comp f (power f (i - 1)) 10 | 11 | let succ (sx:int) = sx + 1 12 | 13 | let main (m(*-:{v:Int | true}*)) (n(*-:{v:Int | true}*)) = 14 | if m > 0 then 15 | assert(power succ m n >= n) 16 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/negative/01_ic3.ml: -------------------------------------------------------------------------------- 1 | 2 | (* 3 | * Input data error 4 | *) 5 | 6 | 7 | let rec loop (lx:int) (ly:int) = 8 | if (lx > 20) then 9 | let t1 = lx in 10 | let t2 = ly in 11 | loop (t1 + t2) (t1 + t2) 12 | else assert (ly >= 1) 13 | 14 | let main (mm:unit(*-:{v:Unit | unit}*)) = 15 | let x = 30 in 16 | let y = -1000 in 17 | loop x y (* Should assert failure *) -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/negative/ack01false.ml: -------------------------------------------------------------------------------- 1 | (* 2 | Assertion error 3 | *) 4 | 5 | let rec ack m n = 6 | if m = 0 then n + 1 7 | else if n = 0 then ack (m - 1) 1 8 | else ack (m - 1) (ack m (n - 1)) 9 | 10 | let main (mm:int(*-:{v:Int | true}*)) (mn:int(*-:{v:Int | true}*)) = 11 | if (mm >= 0 && mn >= 0) 12 | then assert(ack mm mn < mn) 13 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/negative/compose.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * Input data error 3 | *) 4 | 5 | 6 | let compose x g h = g (h x) 7 | 8 | let id (ix:int) = ix 9 | 10 | let add (ay:int) = ay + 1 11 | 12 | let main (n:int(*-:{v:Int | true}*)) = 13 | if n <= 0 then assert(compose n add id > 1) 14 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/negative/ex23.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loop (ly:int) (lz:int) (lc:int) = 4 | if lc < 36 then 5 | if lz >= 0 && lz < 4608 then 6 | loop ly (lz+1) (lc+1) 7 | else -1 8 | else lz 9 | 10 | let main (y(*-:{v:Int | true}*)) = 11 | if y < 0 then 12 | (let c = 0 in 13 | let z = y * 36 in 14 | let ans = loop y z c in 15 | assert(ans >= 0 && ans <= 4608)) 16 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/negative/inductive1-1.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * Assertion error 3 | *) 4 | 5 | let rec loop (x:int) (i:int) = 6 | if i < 0 then 7 | x 8 | else if x < 1 then (* x <= 0*) 9 | loop (x - 1) (i - 1) 10 | else if x > 2 then (* x >= 3*) 11 | loop x (i - 1) 12 | else (* 1 2 *) 13 | loop (3 - x) (i - 1) 14 | 15 | let main (n:int(*-:{v:Int | true}*)) = 16 | assert (loop (-3) n >= 3) -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/negative/repeat.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * Implementation error 3 | *) 4 | 5 | let rec repeat (f: int -> int) n s = 6 | if n = 0 then 7 | s 8 | else 9 | repeat f (n - 1) s 10 | 11 | let succ (x:int) = x + 1 12 | 13 | let main (n:int(*-:{v:Int | true}*)) = 14 | if n > 0 then assert(repeat succ n 0 >= n) 15 | else () -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/negative/xy10.ml: -------------------------------------------------------------------------------- 1 | (* 2 | Implementation error 3 | Polka_st gets expected 4 | *) 5 | 6 | 7 | let rec loopa ax ay (az:int) = 8 | if (ay < 20) then 9 | loopa (ax+10) (ay+1) az 10 | else 11 | assert (ax <= az && ay >= az + 1) 12 | 13 | let main (z:int(*-:{v:Int | true}*)) = 14 | let x = 0 in 15 | let y = 0 in 16 | loopa x y z -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/negative/xy4.ml: -------------------------------------------------------------------------------- 1 | (* 2 | Input data error 3 | *) 4 | 5 | 6 | let rec loopa ax ay = 7 | if ay < 4 then 8 | loopa (ax + 4) (ay + 1) 9 | else ax 10 | 11 | let rec loopb bx by = 12 | if bx > 0 then 13 | loopb (bx - 4) (by - 1) 14 | else assert (by > (-1)) 15 | 16 | let main (mm:unit(*-:{v:Unit | unit}*)) = 17 | let x = 0 in 18 | let y = 0 in 19 | 20 | let rx = loopa x y in 21 | loopb rx (-1) -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/negative/xyz.ml: -------------------------------------------------------------------------------- 1 | (* 2 | Implementation error 3 | Polka_st gets expected 4 | *) 5 | 6 | 7 | let rec loopa ax ay az = 8 | if (ax < 10) then 9 | loopa (ax + 1) (ay + 1) (az - 7) 10 | else az 11 | 12 | let rec loopb bx by bz = 13 | if (bx > 0) then 14 | (let rz = bz + 2 in 15 | let rx = bx - 1 in 16 | let ry = by - 1 in 17 | loopb rx ry rz) 18 | else assert (bz > (-1)) 19 | 20 | let main (mm:unit(*-:{v:Unit | unit}*)) = 21 | let x = 0 in 22 | let y = 0 in 23 | let z = 0 in 24 | 25 | let rsz = loopa x y z in 26 | let rsx = 10 in 27 | loopb rsx rsx rsz -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/negative/xyz2.ml: -------------------------------------------------------------------------------- 1 | (* 2 | Assertion error 3 | *) 4 | 5 | let rec loopa ax ay az = 6 | if (ax < 10) then 7 | loopa (ax + 1) (ay + 1) (az - 2) 8 | else az 9 | 10 | let rec loopb bx by bz = 11 | if (bx >= 1) then 12 | (let rz = bz + 2 in 13 | let rx = bx - 1 in 14 | let ry = by - 1 in 15 | loopb rx ry rz) 16 | else assert (bz < 1 = false) 17 | 18 | let main (mm:unit(*-:{v:Unit | unit}*)) = 19 | let x = 0 in 20 | let y = 0 in 21 | let z = 0 in 22 | 23 | let rsz = loopa x y z in 24 | let rsx = 10 in 25 | loopb rsx rsx rsz -------------------------------------------------------------------------------- /tests/benchmarks/DRIFT/negative/zip_unzip.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * Implementation error 3 | *) 4 | 5 | let helper hg hx hy = hg (hx - 1) (hy + 1) 6 | 7 | let rec unzip ux uk = 8 | if ux = 0 then 9 | uk 0 0 10 | else 11 | unzip (ux - 1) (helper uk) 12 | 13 | let rec zip zx zy = 14 | if zx = 0 then (assert (zy = 0); 0) 15 | else (assert (zy <> 0); 1 + zip (zx - 1) (zy - 1)) 16 | 17 | let main (n:int(*-:{v:Int | true}*)) = 18 | if n > 0 then assert(unzip n zip = n) 19 | else () -------------------------------------------------------------------------------- /tests/benchmarks/effects/3states-aut.ml: -------------------------------------------------------------------------------- 1 | type q = Q0 | Q1 | Q2 | Q3 2 | type tup = Tup of q * int 3 | 4 | let rec ev d acc = 5 | match acc with 6 | | Tup(Q0,_) -> Tup(Q1,1) 7 | | Tup(Q1,_) -> Tup(Q2,1) 8 | | _ -> Tup(Q3,1) 9 | 10 | (* at least 3 events happen, then only "v" events *) 11 | let rec aut n _s0 = 12 | if n > 0 then begin 13 | let _s1 = ev n _s0 in 14 | aut (n-1) _s1 15 | end else _s0 16 | 17 | let main (n:int(*-:{v:Int | true}*)) = 18 | let _s00 = Tup(Q0,0) in 19 | if n > 5 then begin 20 | let _s01 = aut n _s00 in 21 | match _s01 with 22 | | Tup(Q0,_) -> assert(false) 23 | | Tup(Q1,_) -> assert(false) 24 | | Tup(Q2,_) -> assert(false) 25 | | _ -> () 26 | end -------------------------------------------------------------------------------- /tests/benchmarks/effects/3states.ml: -------------------------------------------------------------------------------- 1 | (* simple 3-state automaton, the final state accepting. *) 2 | let ev d _s = 3 | if _s = 0 then 1 4 | else if _s = 1 then 2 5 | else if _s = 2 then 3 6 | else -1 7 | 8 | let nondet (i:int) = (i * i * i * 500) mod 199 9 | 10 | (* at least 3 events happen, then only "v" events *) 11 | let rec aut n _s0 = 12 | if n > 0 then begin 13 | let _s1 = ev n _s0 in 14 | aut (n-1) _s1 15 | end else _s0 16 | 17 | let main (n:int(*-:{v:Int | true}*)) = 18 | let _s00 = 0 in 19 | if n > 5 then begin 20 | let _s01 = aut n _s00 in 21 | assert (_s01 < 0) 22 | end -------------------------------------------------------------------------------- /tests/benchmarks/effects/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | ./runall -------------------------------------------------------------------------------- /tests/benchmarks/effects/foo-nondet.ml: -------------------------------------------------------------------------------- 1 | type q = Qerr | Q0 2 | type tup = Tup of q * int 3 | let rec ev d acc = 4 | match acc with 5 | | Tup(Qerr,_) -> acc 6 | | Tup(Q0,_) -> (if d < 0 then (Tup(Qerr,d)) else (Tup(Q0,d))) 7 | 8 | let rec foo x acc = 9 | let acc' = ev x acc in 10 | if x = 0 then acc' else ( foo (x-1) acc' ) 11 | 12 | let main (x:int) = 13 | if x > 0 then begin 14 | let acc' = foo x (Tup(Q0,0)) in 15 | match acc' with 16 | | Tup(Qerr,_) -> assert(false) 17 | | _ -> () 18 | end 19 | -------------------------------------------------------------------------------- /tests/benchmarks/effects/foo-safe.ml: -------------------------------------------------------------------------------- 1 | type q = Qerr | Q0 2 | type tup = Tup of q * int 3 | let rec ev d acc = 4 | match acc with 5 | | Tup(Qerr,_) -> acc 6 | | Tup(Q0,_) -> (if d < 0 then (Tup(Qerr,d)) else (Tup(Q0,d))) 7 | 8 | let rec foo x acc = 9 | let acc' = ev x acc in 10 | if x = 0 then acc' else ( foo (x-1) acc' ) 11 | 12 | let main () = 13 | let acc' = foo 10 (Tup(Q0,0)) in 14 | match acc' with 15 | | Tup(Qerr,_) -> assert(false) 16 | | _ -> () 17 | -------------------------------------------------------------------------------- /tests/benchmarks/effects/foo-unsafe.ml: -------------------------------------------------------------------------------- 1 | type q = Qerr | Q0 2 | type tup = Tup of q * int 3 | let rec ev d acc = 4 | match acc with 5 | | Tup(Qerr,_) -> acc 6 | | Tup(Q0,_) -> (if d > 0 then (Tup(Qerr,d)) else (Tup(Q0,d))) 7 | 8 | let rec foo x acc = 9 | let acc' = ev x acc in 10 | if x = 0 then acc' else ( foo (x-1) acc' ) 11 | 12 | let main () = 13 | let acc' = foo 10 (Tup(Q0,0)) in 14 | match acc' with 15 | | Tup(Qerr,_) -> assert(false) 16 | | _ -> () 17 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/array/a-dotprod.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as a-prod 3 | *) 4 | 5 | let make_array n i = assert (0 <= i && i < n); 0 6 | let rec dotprod n v1 v2 i sum = 7 | if i >= n then 8 | sum 9 | else 10 | dotprod n v1 v2 (i + 1) (sum + v1 i * v2 i) 11 | let main z n = 12 | let v1 = make_array n in 13 | let v2 = make_array n in 14 | if z=0 then (dotprod n v1 v2 z z; ()) else () 15 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/array/a-init1.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as a-init 3 | *) 4 | 5 | let make_array n i = assert (0 <= i && i < n); 0 6 | let update i a x j :int= if j > i - 1 && j <= i then x else a (j) 7 | let rec init i n a = 8 | if i < 0 then init 0 n a 9 | else if i >= n then a else init (i + 1) n (update i a 1) 10 | let main k n i = 11 | if i >= k && i >= 0 && i < n then 12 | let x = init k n (make_array n) in 13 | if 0 <= i && i < n then 14 | assert (x i >= 1) 15 | else () 16 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/array/a-init2.ml: -------------------------------------------------------------------------------- 1 | let mk_array n i = if 0<=i && i=n then a 5 | else init (i+1) n (update i a 1) 6 | 7 | let main n i = 8 | let x = init 0 n (mk_array n) in 9 | if 0<=i && i=1) (* check that the array has been initialized *) 11 | else () 12 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/array/a-iter.ml: -------------------------------------------------------------------------------- 1 | 2 | let make_array (n:int) (i:int) = assert (0 <= i && i < n); 0 3 | 4 | let rec iter_helper (hf: int -> int) hi hn (ha: int -> int) : unit = 5 | if (hi < hn) then 6 | let _ = hf (ha(hi)) in 7 | iter_helper hf (hi + 1) hn ha 8 | else () 9 | 10 | let iter (mf: int -> int) ma mn : unit = 11 | iter_helper mf 0 mn ma 12 | 13 | let succ (si:int) = si + 1 14 | 15 | let main (n:int) = 16 | if n > 0 then 17 | let a = make_array n in 18 | iter succ a n 19 | else () -------------------------------------------------------------------------------- /tests/benchmarks/r_type/array/a-reverse.ml: -------------------------------------------------------------------------------- 1 | 2 | let make_array n i = assert (0 <= i && i < n); 0 3 | let update i (n:int) a x j = assert (0 <= i && i < n); if j = i then x else a(j) 4 | 5 | let rec reverse ri rn ra rb = 6 | if (ri < rn) then 7 | let rb2 = update (rn - ri - 1) rn rb (ra(ri)) in 8 | reverse (ri + 1) rn ra rb2 9 | else () 10 | 11 | let main (n:int) = 12 | let a = make_array n in 13 | let b = make_array n in 14 | reverse 0 n a b -------------------------------------------------------------------------------- /tests/benchmarks/r_type/array/bcopy.ml: -------------------------------------------------------------------------------- 1 | 2 | let make_array n = n 3 | let arraysize src = src 4 | let update des i x = assert (0 <= i && i < des) 5 | let sub src i = assert (0 <= i && i < src); 0 6 | 7 | let rec bcopy_aux src des i m = 8 | if i >= m 9 | then () 10 | else 11 | begin 12 | update des i (sub src i); 13 | bcopy_aux src des (i+1) m 14 | end 15 | 16 | let bcopy src des = bcopy_aux src des 0 (arraysize src) 17 | 18 | let main n m = 19 | let array1 = make_array n in 20 | let array2 = make_array m in 21 | if n<=m then bcopy array1 array2 else () 22 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/ack.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as ack 3 | USED: PEPM2013 as ack 4 | *) 5 | 6 | let rec ack m n = 7 | if m=0 then n+1 8 | else if n=0 then ack (m-1) 1 9 | else ack (m-1) (ack m (n-1)) 10 | 11 | let main (m:int(*-:{v:Int | true}*)) (n:int(*-:{v:Int | true}*)) = 12 | if (m>=0 && n>=0) 13 | then assert (ack m n >= n) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/copy_intro.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PEPM2013 as copy_intro 3 | *) 4 | 5 | let rec copy (x:int) = 6 | if x = 0 then 0 7 | else 1 + copy (x - 1) 8 | 9 | let main (n:int(*-:{v:Int | true}*)) = 10 | assert (copy (copy n) = n) 11 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/enc-rev_accum.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec rev n m = 4 | if n = 0 5 | then m 6 | else rev (n - 1) (m + 1) 7 | 8 | let main (n:int(*-:{v:Int | true}*)) = 9 | assert (rev n 0 >= n) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/enc-rev_append.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec append x y = 3 | if x = 0 then 4 | y 5 | else 6 | 1 + append (x - 1) y 7 | 8 | let rec rev n = 9 | if n = 0 10 | then 0 11 | else append (rev (n - 1)) 1 12 | 13 | let main (n:int(*-:{v:Int | true}*)) (m:int(*-:{v:Int | true}*)) = 14 | assert (rev n = n); 15 | assert (append n m = n + m) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/enc-zip.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec zip x y = 3 | if x = 0 4 | then 5 | if y = 0 6 | then 0 7 | else assert false 8 | else 9 | if y = 0 10 | then assert false 11 | else 1 + zip (x - 1) (y - 1) 12 | 13 | let main (n:int(*-:{v:Int | true}*)) = 14 | assert (zip n n = n) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/enc-zip3.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loop (x:unit) = loop () 4 | 5 | let rec zip x y = 6 | if x = 0 7 | then 8 | if y = 0 9 | then 0 10 | else loop () 11 | else 12 | if y = 0 13 | then loop () 14 | else 1 + zip (x - 1) (y - 1) 15 | 16 | let main (n:int(*-:{v:Int | true}*)) = 17 | assert (zip n n = n) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/enc-zip4.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec zip x y = 4 | if x = 0 5 | then if y = 0 then 0 else assert(false) 6 | else if y = 0 then assert(false) 7 | else 1 + zip (x - 1) (y - 1) 8 | 9 | let main (n:int(*-:{v:Int | true}*)) = 10 | let m = zip n n in 11 | assert (m >= n && m <= n) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/enc-zip_map.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loop (x:unit) = loop x 4 | let rec zip (x:int) (y:int) = 5 | if x = 0 then 6 | if y = 0 then 0 7 | else loop () (* Dead END! *) 8 | else if y = 0 then loop () (* Dead END! *) 9 | else 1 + zip (x - 1) (y - 1) 10 | 11 | let rec map (mx:int) = 12 | if mx = 0 then 0 else 1 + map (mx - 1) 13 | 14 | let main (n:int(*-:{v:Int | true}*)) = 15 | assert(map (zip n n) >= n) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/enc-zip_map2.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loop (x:int) = loop x 4 | 5 | let rec zip (x:int) (y:int) = 6 | if x = 0 then 7 | if y = 0 then x 8 | else assert false 9 | else if y = 0 then assert false 10 | else 1 + zip (x-1) (y-1) 11 | 12 | let rec map (x:int) = 13 | if x = 0 then x else 1 + map (x - 1) 14 | 15 | let main (n:int(*-:{v:Int | true}*)) = 16 | assert(map (zip n n) = n) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/enc-zipmap.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as l-zipmap 3 | USED: PEPM2013 as l-zipmap 4 | *) 5 | 6 | let rec zip x y = 7 | if x = 0 then 8 | if y = 0 then 9 | x 10 | else 11 | assert(false) 12 | else 13 | if y = 0 then 14 | assert(false) 15 | else 16 | 1 + zip (x - 1) (y - 1) 17 | 18 | let rec map x = 19 | if x = 0 then x else 1 + map (x - 1) 20 | 21 | let main (n:int(*-:{v:Int | true}*)) = 22 | assert (map (zip n n) = n) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/fib.ml: -------------------------------------------------------------------------------- 1 | let rec fib n = 2 | if n<2 then 1 else 3 | fib (n-1) + fib (n-2) 4 | 5 | let main (n (*-:{v:Int | true}*)) = 6 | assert (n <= fib n) 7 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/flow.ml: -------------------------------------------------------------------------------- 1 | 2 | let lamp (x:unit) = x 3 | 4 | let f = 5 | let id (x:int -> unit) = x in 6 | let unused = id (fun _ -> assert false) in 7 | lamp 8 | 9 | let main (i:unit(*-:{v:Unit | unit}*))= 10 | f () 11 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/fxx.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let f x y = assert (x <= 0 || y > 0) 4 | 5 | let main (mx:int(*-:{v:Int | true}*)) = 6 | f mx mx -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/gib.ml: -------------------------------------------------------------------------------- 1 | (* 2 | let rec gib a b n = 3 | if n=0 then a 4 | else if n=1 then b 5 | else gib a b (n-1) + gib a b (n-2) 6 | 7 | let main n = 8 | assert (gib 0 1 n >= 0) 9 | *) 10 | 11 | let rec gib a b n = 12 | if n=0 then a 13 | else if n=1 then b 14 | else gib a b (n-1) + gib a b (n-2) 15 | 16 | let main (n:int(*-:{v:Int | true}*)) (a:int(*-:{v:Int | true}*)) (b:int(*-:{v:Int | true}*)) = 17 | if a >= 0 && b >= 0 && n >= 0 then 18 | assert(gib 0 1 n >= 0) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/gib2.ml: -------------------------------------------------------------------------------- 1 | (* 2 | let rec gib a b n = 3 | if n=0 then a 4 | else if n=1 then b 5 | else gib a b (n-1) + gib a b (n-2) 6 | 7 | let main n = 8 | assert (gib 0 1 n >= 0) 9 | *) 10 | 11 | let rec gib a b n = 12 | if n=0 then a 13 | else if n=1 then b 14 | else gib a b (n-1) + gib a b (n-2) 15 | 16 | let main (n:int(*-:{v:Int | true}*)) (a:int(*-:{v:Int | true}*)) (b:int(*-:{v:Int | true}*)) = 17 | if a >= 0 && b >= 0 then 18 | assert (gib a b n >= 0) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/inductive.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loop x i = 4 | if i < 0 then 5 | x 6 | else if x < 1 then (* x <= 0*) 7 | loop (x - 1) (i - 1) 8 | else if x > 2 then (* x >= 3*) 9 | loop x (i - 1) 10 | else (* 1 2 *) 11 | loop (3 - x) (i - 1) 12 | 13 | let main (n:int(*-:{v:Int | true}*)) = 14 | assert (loop 3 n >= 3); 15 | assert (loop 1 n >= 0) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/inductive2.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec f x = 4 | if x < -1 then 5 | f (-2) 6 | else if x <= 0 then 7 | -1 8 | else if x <= 2 then 9 | 3 - x 10 | else 11 | x 12 | 13 | let main (n:unit(*-:{v:Unit | unit}*)) = 14 | assert (f 3 >= 0) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/inductive3-2.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec f x = 4 | if x < -1 then 5 | f (-2) 6 | else if x <= 1 then 7 | 2 * x - 1 8 | else 9 | x 10 | 11 | let main (n:int(*-:{v:Int | true}*)) = 12 | let v = f 0 in 13 | if n >= 2 then assert(f n >= 0) else () -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/inductive3.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec f x = 4 | if x < -1 then 5 | f (-2) 6 | else if x <= 1 then 7 | 2 * x - 1 8 | else 9 | x 10 | 11 | let main (n:int(*-:{v:Int | true}*)) = 12 | assert(f 3 >= 0) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/inductive4.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec f g x = 4 | if x < (-3) then (* x<=-4 *) 5 | f g (-4) 6 | else if x <= 1 then (* -3<=x<=1 *) 7 | g x 8 | else (* x>1 *) 9 | f (f g) (x - 2) 10 | 11 | let incr y = y + 1 12 | 13 | let main (n:int(*-:{v:Int | true}*)) = 14 | assert(f incr 3 >= -3) 15 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/inductive5.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec f x = 3 | if x < -2 then 4 | f (-3) 5 | else if x < 2 then 6 | 2 * x - 1 7 | else if x <= 2 then 8 | f (2 * x - 1) 9 | else 10 | x 11 | 12 | let main (n:int(*-:{v:Int | true}*)) = 13 | assert(f 3 >= 0) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/inductive6-2.ml: -------------------------------------------------------------------------------- 1 | 2 | let f g x = 3 | if x > 0 then 4 | g x 5 | else 6 | 1 7 | 8 | let decr x = x - 1 9 | 10 | let main (n:int(*-:{v:Int | true}*)) = 11 | if n >= 3 then assert(f decr n > 0) 12 | else () -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/inductive6-3.ml: -------------------------------------------------------------------------------- 1 | let f g x = 2 | if x > 0 then 3 | g x 4 | else 5 | 1 6 | let decr x = x - 1 7 | 8 | let main (n:int(*-:{v:Int | true}*)) = 9 | if n >= 3 || n <= 0 then assert(f decr n > 0) else () 10 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/inductive6.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let f g x = 4 | if x > 0 then 5 | g x 6 | else 7 | 1 8 | 9 | let decr x = x - 1 10 | 11 | let main (n:unit(*-:{v:Unit | unit}*)) = 12 | assert(f decr 3 > 0) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/lock.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as r-lock 3 | USED: PEPM2013 as r-lock 4 | *) 5 | 6 | let lock st = assert (st = 0); 1 7 | let unlock st = assert (st = 1); 0 8 | let f n st = if n > 0 then lock (st) else st 9 | let g n st = if n > 0 then unlock (st) else st 10 | 11 | let main (n:int(*-:{v:Int | true}*)) = 12 | assert ((g n (f n 0)) = 0) 13 | 14 | (* let _ = 15 | for i = 1 to 1000000 do 16 | main (Random.int 1000) 17 | done *) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/map.ml: -------------------------------------------------------------------------------- 1 | let rec map x = 2 | if x = 0 3 | then 0 4 | else 1 + map (x-1) 5 | 6 | let main (n:int(*-:{v:Int | true}*)) = 7 | assert (map n = n) 8 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/map_map.ml: -------------------------------------------------------------------------------- 1 | let rec map x = 2 | if x=0 then x else 1 + map (x-1) 3 | 4 | let main (n:int(*-:{v:Int | true}*)) = 5 | assert(map (map n) = n) 6 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/mc91.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as mc91 3 | USED: PEPM2013 as mc91 4 | 5 | Res: OCaml -> 91 6 | imprecision: Oct: 91 <= v <= 101 7 | Liquid Haskell: false by property {-@ mc91 :: x:Int -> {b:Int | (b == 91)} @-} 8 | *) 9 | 10 | let rec mc91 x = 11 | if x > 100 12 | then x - 10 13 | else mc91 (mc91 (x + 11)) 14 | 15 | let main (n:int(*-:{v:Int | true}*)) = 16 | if n <= 101 17 | then assert (mc91 n = 91) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/mc91_95.ml: -------------------------------------------------------------------------------- 1 | 2 | (* 3 | Res: OCaml -> 91 4 | imprecision: Oct: 91 <= v <= 101 5 | Liquid Haskell: false by property {-@ m :: x:Int -> {b:Int | (b == 91)} @-} 6 | *) 7 | 8 | let rec m x = 9 | if x > 100 10 | then x - 10 11 | else m (m (x + 11)) 12 | 13 | let main (n:int(*-:{v:Int | true}*)) = 14 | if n <= 95 15 | then assert (m n = 91) 16 | else () -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/mc91_98.ml: -------------------------------------------------------------------------------- 1 | 2 | (* 3 | Res: OCaml -> 91 4 | imprecision: Oct: 91 <= v <= 101 5 | Liquid Haskell: false by property {-@ m :: x:Int -> {b:Int | (b == 91)} @-} 6 | *) 7 | 8 | let rec m x = 9 | if x > 100 10 | then x - 10 11 | else m (m (x + 11)) 12 | 13 | let main (n:int(*-:{v:Int | true}*)) = 14 | if n <= 98 15 | then assert (m n = 91) 16 | else () -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/mc91_99.ml: -------------------------------------------------------------------------------- 1 | 2 | (* 3 | Res: OCaml -> 91 4 | imprecision: Oct: 91 <= v <= 101 5 | Liquid Haskell: false by property {-@ m :: x:Int -> {b:Int | (b == 91)} @-} 6 | *) 7 | 8 | let rec m x = 9 | if x > 100 10 | then x - 10 11 | else m (m (x + 11)) 12 | 13 | let main (n:int(*-:{v:Int | true}*)) = 14 | if n <= 99 15 | then assert (m n = 91) 16 | else () -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/mult.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as mult 3 | USED: PEPM2013 as mult 4 | *) 5 | 6 | let rec mult n m = 7 | if n <= 0 || m <= 0 then 8 | 0 9 | else 10 | n + mult n (m - 1) 11 | 12 | let main (n:int(*-:{v:Int | true}*)) = 13 | assert (n <= mult n n) 14 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/sum.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as sum 3 | USED: PEPM2013 as sum 4 | *) 5 | 6 | let rec sum n = 7 | if n <= 0 8 | then 0 9 | else n + sum (n - 1) 10 | 11 | let main (n:int(*-:{v:Int | true}*)) = 12 | assert (n <= sum n) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/sum2.ml: -------------------------------------------------------------------------------- 1 | 2 | (* 3 | Res: OCaml -> 10453878 4 | imprecision: Oct: 4752 <= v 5 | Liquid Haskell: TODO: need to TEST! 6 | *) 7 | 8 | let rec sum n = 9 | if n <= 0 then 10 | 0 11 | else 12 | n + sum (n - 1) 13 | 14 | let main (n:int(*-:{v:Int | true}*)) = 15 | assert (2 * n - 1 <= sum n) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/sum3.ml: -------------------------------------------------------------------------------- 1 | (* 2 | Res: OCaml -> 42813631 3 | imprecision: Oct: 9253 <= v 4 | Liquid Haskell: TODO: need to TEST! 5 | *) 6 | 7 | let rec sum n = 8 | if n <= 0 then 9 | 0 10 | else 11 | n + sum (n - 1) 12 | 13 | let main (n:int(*-:{v:Int | true}*)) = 14 | assert (3 * n - 3 <= sum n) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/sum4.ml: -------------------------------------------------------------------------------- 1 | (* 2 | Res: OCaml -> 284635 3 | imprecision: Oct: 754 <= v 4 | Liquid Haskell: TODO: need to TEST! 5 | *) 6 | 7 | let rec sum n = 8 | if n <= 0 then 9 | 0 10 | else 11 | n + sum (n - 1) 12 | 13 | let main (n:int(*-:{v:Int | true}*)) = 14 | assert (4 * n - 6 <= sum n) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/first/sum_intro.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PEPM2013 as sum_intro 3 | *) 4 | 5 | let add x y = x + y 6 | 7 | let rec sum n = 8 | if n <= 0 then 9 | 0 10 | else 11 | add n (sum (n-1)) 12 | 13 | let main (n:int(*-:{v:Int | true}*)) = 14 | assert (n <= sum n) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/a-dotprod.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as a-prod 3 | *) 4 | 5 | let make_array n i = assert (0 <= i && i < n); 0 6 | let rec dotprod n v1 v2 i sum = 7 | if i >= n then 8 | sum 9 | else 10 | dotprod n v1 v2 (i + 1) (sum + v1 i * v2 i) 11 | let main (z:int(*-:{v:Int|true}*)) (n:int(*-:{v:Int|true}*)) = 12 | let v1 = make_array n in 13 | let v2 = make_array n in 14 | if z=0 then (dotprod n v1 v2 z z; ()) 15 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/a-init.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as a-init 3 | *) 4 | 5 | let make_array n i = assert (0 <= i && i < n); 0 6 | let update i a x j :int= if j > i-1 && j <= i then x else a (j) 7 | let rec init i n a = 8 | if i >= n then a else init (i + 1) n (update i a 1) 9 | let main (k(*-:{v:Int|true}*)) (n(*-:{v:Int|true}*)) (i(*-:{v:Int|true}*)) = 10 | if k >= 0 && k <= 0 then 11 | let x = init k n (make_array n) in 12 | if 0 <= i && i < n then 13 | assert (x i >= 1) 14 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/a-max.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as a-max 3 | *) 4 | 5 | let make_array n i = n - i 6 | let rec array_max (n:int) i (a:int->int) m = 7 | if i >= n then 8 | m 9 | else 10 | let x = a i in 11 | let z = if x>m then x else m in 12 | array_max n (i+1) a z 13 | let main (n(*-:{v:Int|true}*)) (i(*-:{v:Int|true}*)) = 14 | if n>0 && i>=0 && i<=0 then 15 | let m = array_max n i (make_array n) (-1) in 16 | assert (m >= n) 17 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/apply.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as apply 3 | *) 4 | 5 | 6 | let apply f x = f x 7 | let g y z = assert (y=z) 8 | let rec k n = apply (g n) n; k(n+1) 9 | 10 | let main (n:int(*-:{v:Int | true}*)) = 11 | k 0 -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/array_init.ml: -------------------------------------------------------------------------------- 1 | let mk_array n i = if 0<=i && i=n then a 5 | else init (i+1) n (update i a 1) 6 | 7 | let main (n(*-:{v:Int|true}*)) (i(*-:{v:Int|true}*)) = 8 | let x = init 0 n (mk_array n) in 9 | if 0<=i && i=1) (* check that the array has been initialized *) 11 | else () 12 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/bcopy.ml: -------------------------------------------------------------------------------- 1 | 2 | let make_array n = n 3 | let arraysize src = src 4 | let update des i x = assert (0 <= i && i < des) 5 | let sub src i = assert (0 <= i && i < src); 0 6 | 7 | let rec bcopy_aux src des i m = 8 | if i >= m 9 | then () 10 | else 11 | begin 12 | update des i (sub src i); 13 | bcopy_aux src des (i+1) m 14 | end 15 | 16 | let bcopy src des = bcopy_aux src des 0 (arraysize src) 17 | 18 | let main (n(*-:{v:Int|true}*)) (m(*-:{v:Int|true}*)) = 19 | let array1 = make_array n in 20 | let array2 = make_array m in 21 | if n<=m then bcopy array1 array2 else () 22 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/bcopy2.ml: -------------------------------------------------------------------------------- 1 | let make_array n i = assert (0 <= i && i < n); 0 2 | let update i n des x = let _ = des i in () 3 | 4 | let rec bcopy_aux m src des i = 5 | if i >= m 6 | then () 7 | else 8 | begin 9 | update i m des (src i); 10 | bcopy_aux m src des (i+1) 11 | end 12 | 13 | let main (n(*-:{v:Int|true}*)) (m(*-:{v:Int|true}*)) = 14 | let array1 = make_array n in 15 | let array2 = make_array m in 16 | if n<=m && n>0 then bcopy_aux n array1 array2 0 else () 17 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/bcopy3.ml: -------------------------------------------------------------------------------- 1 | let make_array n i = assert (0 <= i && i < n); 0 2 | let update des i x j = if i=j then x else des i 3 | 4 | let rec bcopy_aux m src des i = 5 | if i >= m 6 | then () 7 | else 8 | begin 9 | update des i (src i); 10 | bcopy_aux m src des (i+1) 11 | end 12 | 13 | let main (n(*-:{v:Int|true}*)) (m(*-:{v:Int|true}*)) = 14 | let array1 = make_array n in 15 | let array2 = make_array m in 16 | if n<=m then bcopy_aux n array1 array2 0 else () 17 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/bcopy4.ml: -------------------------------------------------------------------------------- 1 | 2 | let array1 i = 0 3 | let array2 i = 0 4 | let update a i x j = if j=i then x else a j 5 | 6 | let rec bcopy_aux m src des i = 7 | if i >= m 8 | then () 9 | else 10 | begin 11 | assert (0<=i && i<=m); 12 | let des = update des i (src i) in 13 | bcopy_aux m src des (i+1) 14 | end 15 | 16 | 17 | let main (n(*-:{v:Int|true}*)) = 18 | let bcopy src des = bcopy_aux n src des 0 in 19 | bcopy array1 array2 20 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/bcopy5.ml: -------------------------------------------------------------------------------- 1 | let make_array n i = assert (0 <= i && i < n); 0 2 | let update i n a x = a i; let a j = if i=j then x else a j in a 3 | 4 | let rec bcopy_aux m src des i = 5 | if i >= m 6 | then () 7 | else bcopy_aux m src (update i m des (src i)) (i+1) 8 | 9 | let main (i(*-:{v:Int|true}*)) (n(*-:{v:Int|true}*)) (m(*-:{v:Int|true}*)) = 10 | let array1 = make_array n in 11 | let array2 = make_array m in 12 | if i=0 && n<=m then bcopy_aux n array1 array2 i else () 13 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/bsearch.ml: -------------------------------------------------------------------------------- 1 | 2 | let make_array n = n 3 | let arraysize src = src 4 | let update des i x = assert (0 <= i && i < des) 5 | let sub src i = assert (0 <= i && i < src); 0 6 | 7 | let rec bs_aux key vec l u = 8 | if u < l 9 | then -1 10 | else 11 | let m = l + (u-l) / 2 in 12 | let x = sub vec m in 13 | if x < key then bs_aux key vec (m+1) u 14 | else if x > key then bs_aux key vec l (m - 1) 15 | else m 16 | 17 | let bsearch key vec = bs_aux key vec 0 (arraysize vec - 1) 18 | 19 | let main (n(*-:{v:Int|true}*)) (m(*-:{v:Int|true}*)) = 20 | let v1 = make_array n in 21 | let v2 = make_array m in 22 | if 0<=n && n=m then (bsearch v1 v2; ()) else () 23 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/dotprod.ml: -------------------------------------------------------------------------------- 1 | 2 | let make_array n = n 3 | let arraysize src = src 4 | let update des i x = assert (0 <= i && i < des) 5 | let sub src i = assert (0 <= i && i < src); 0 6 | 7 | let rec dotprod_aux n v1 v2 i sum = 8 | if i = n 9 | then sum 10 | else dotprod_aux n v1 v2 (i+1) (sum + (sub v1 i) * (sub v2 i)) 11 | 12 | let dotprod v1 v2 = dotprod_aux (arraysize v1) v1 v2 0 0 13 | 14 | let main (n(*-:{v:Int|true}*)) (m(*-:{v:Int|true}*)) = 15 | let v1 = make_array n in 16 | let v2 = make_array m in 17 | if 0<=n && n=m then (dotprod v1 v2; ()) else () 18 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/dotprod2.ml: -------------------------------------------------------------------------------- 1 | 2 | let update a i x j = if j=i then x else a j 3 | 4 | let rec dotprod v1 v2 n i sum = 5 | if i > n 6 | then sum 7 | else 8 | begin 9 | assert (0<=i && i<=n); 10 | dotprod v1 v2 n (i+1) (sum + v1 i * v2 i) 11 | end 12 | 13 | 14 | let main (i(*-:{v:Int|true}*)) (n(*-:{v:Int|true}*)) = 15 | let v1 i = 0 in 16 | let v2 i = 0 in 17 | dotprod v1 v2 n 0 0; () 18 | 19 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/dotprod3.ml: -------------------------------------------------------------------------------- 1 | 2 | let make_array n i = assert (0 <= i && i < n); 0 3 | let update des i x j = if i=j then x else des i 4 | 5 | let rec dotprod n v1 v2 i sum = 6 | if i >= n 7 | then sum 8 | else dotprod n v1 v2 (i+1) (sum + v1 i * v2 i) 9 | 10 | let main (n(*-:{v:Int|true}*)) = 11 | let v1 = make_array n in 12 | let v2 = make_array n in 13 | dotprod n v1 v2 0 0; () 14 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/dotprod4.ml: -------------------------------------------------------------------------------- 1 | let make_array n i = assert (0 <= i && i < n); 0 2 | let rec dotprod n v1 v2 i sum = 3 | if i >= n 4 | then sum 5 | else dotprod n v1 v2 (i+1) (sum + v1 i * v2 i) 6 | 7 | let main (n(*-:{v:Int|true}*)) (z(*-:{v:Int|true}*)) = 8 | let v1 = make_array n in 9 | let v2 = make_array n in 10 | if z=0 then (dotprod n v1 v2 z z; ()) else () 11 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/dotprod5.ml: -------------------------------------------------------------------------------- 1 | let make_array n i = assert (0 <= i && i < n); 0 2 | let update i n a x = a i; let a j = if i=j then x else a j in a 3 | let rec bcopy_aux m src des i = 4 | if i >= m 5 | then () 6 | else bcopy_aux m src (update i m des (src i)) (i+1) 7 | 8 | let main (n(*-:{v:Int|true}*)) (m(*-:{v:Int|true}*)) (i(*-:{v:Int|true}*)) = 9 | let array1 = make_array n in 10 | let array2 = make_array m in 11 | if i=0 && n<=m then bcopy_aux n array1 array2 i else () 12 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/dotprod_lin.ml: -------------------------------------------------------------------------------- 1 | let make_array n i = assert (0 <= i && i < n); 0 2 | let rec dotprod n v1 v2 i sum = 3 | if i >= n 4 | then sum 5 | else (dotprod n v1 v2 (i+1) (sum + v1 i + v2 i); 6 | dotprod n v1 v2 (i+1) (sum + v1 i + v2 i)) 7 | 8 | let main (n(*-:{v:Int|true}*)) (m(*-:{v:Int|true}*)) (z(*-:{v:Int|true}*)) = 9 | let v1 = make_array n in 10 | let v2 = make_array n in 11 | if z=0 then (dotprod n v1 v2 z z; ()) else () 12 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/enc-zip_unzip.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as l-zipunzip 3 | USED: PEPM2013 as l-zipunzip 4 | *) 5 | 6 | let f g x y = g (x+1) (y+1) 7 | let rec unzip x k = 8 | if x=0 then k 0 0 9 | else 10 | unzip (x- 1) (f k) 11 | 12 | let rec zip x y = 13 | if x=0 then 14 | if y=0 then 0 15 | else assert false 16 | else if y=0 then assert false 17 | else 1 + zip (x-1) (y-1) 18 | 19 | let main (n (*-:{v:Int|true}*)) = 20 | let x = unzip n zip in () 21 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/exc-fact.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as e-fact 3 | USED: PEPM2013 as e-fact 4 | *) 5 | 6 | let rec fact n exn = 7 | if n <= 0 then 8 | exn 0 9 | else 10 | let exn n = if n = 0 then 1 else exn n in 11 | n * fact (n - 1) exn 12 | let exn n = assert false 13 | let main (n (*-:{v:Int | true}*)) = if n > 0 then (fact n exn; ()) 14 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/exc-simple.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as e-simpl 3 | USED: PEPM2013 as e-simpl 4 | FROM: Leroy & Pessaux, "Type-Based Analysis of Uncaught Exceptionis, " TOPLAS, 2000 5 | 6 | let ff n = if n >= 0 then () else raise (Failer 0) 7 | let main n = try ff n with Failer 0 -> () 8 | *) 9 | 10 | let f n k = if n >= 0 then () else k 0 11 | let g n = assert (n = 0) 12 | 13 | let main (n:int(*-:{v:Int | true}*)) = 14 | f n g 15 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/exception.ml: -------------------------------------------------------------------------------- 1 | (* 2 | Leroy & Pessaux, "Type-Based Analysis of Uncaught Exceptionis, " TOPLAS, 2000 3 | 4 | let ff n = if n >= 0 then () else raise 0 in 5 | try ff ?n? with Failer 0 -> () 6 | *) 7 | 8 | 9 | let f n k = if n >= 0 then () else k 0 10 | let g n = assert (n = 0) 11 | 12 | let main (n:int(*-:{v:Int | true}*)) = 13 | f n g -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/fact_exn.ml: -------------------------------------------------------------------------------- 1 | (* 2 | Sukyoung Ryu, Exception Analysis for Languages with Exceptions, Ph.D. thesis 3 | 4 | let rec fact n = 5 | if n <= 0 6 | then raise ZERO 7 | else 8 | try 9 | n * fact (n-1) 10 | with ZERO -> 1 11 | *) 12 | 13 | 14 | let rec fact n exn = 15 | if n <= 0 16 | then exn 0 17 | else 18 | let exn_n n = if n = 0 then 1 else exn n in 19 | n * fact (n-1) exn_n 20 | 21 | let exni n = assert false; 1 22 | 23 | let main (n:int(*-:{v:Int | true}*)) = 24 | if n > 0 25 | then (fact n exni; ()) 26 | else () -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/hors.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as hors 3 | USED: PEPM2013 as hors 4 | *) 5 | 6 | 7 | let c q = () 8 | (* c q -> . for any q *) 9 | let b x q = x 1 10 | (* b q -> q1 for any q *) 11 | let a x y q = if q=0 then (x 0; y 0) else assert false 12 | (* a q0 -> q0 q0 *) 13 | 14 | let rec f n x q = if n <= 0 then x q else a x (f (n-1) (b x)) q 15 | (* F n x = if n<=0 then x else a x (f (n-1) (b x)) *) 16 | let s n q = f n c q 17 | (* S -> F n c *) 18 | 19 | let main (n:int(*-:{v:Int | true}*)) = 20 | s n 0 21 | (* check whether S: q0 *) 22 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/hrec.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as hrec 3 | *) 4 | 5 | 6 | let rec f g x = if x>=0 then g x else f (f g) (g x) 7 | let succ x = x+1 8 | 9 | let main (n:int(*-:{v:Int | true}*)) = 10 | assert (f succ n >= 0) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/inc.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec ar i = 0 3 | let update a i x j = if j=i then x else a j 4 | let rec g e a j = 5 | if j=m 5 | then () 6 | else 7 | begin 8 | update i m src ((src i)+1); 9 | inc3 m src (i+1) 10 | end 11 | let main (n(*-:{v:Int|true}*)) = 12 | if n>0 then inc3 n (make_array n) 0 else () 13 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/inc4.ml: -------------------------------------------------------------------------------- 1 | let make_array n i = assert(0<=i && i=m 5 | then () 6 | else 7 | let a = update i m a ((a i)+1) in 8 | inc3 m a (i+1) 9 | let main (n(*-:{v:Int|true}*)) (i(*-:{v:Int|true}*)) = 10 | if i=0 && n>0 then inc3 n (make_array n) i else () 11 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/intro1.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as intro1 3 | *) 4 | 5 | let f x g : unit= g(x+1) 6 | 7 | let h (y:int) = assert (y>0) 8 | 9 | let main (n:int(*-:{v:Int | true}*)) = 10 | if n > 0 then f n h 11 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/intro2.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as intro2 3 | *) 4 | 5 | 6 | let f x g : unit = g (x + 1) 7 | 8 | let h (y:int) = assert (y>0) 9 | 10 | let main (n:int(*-:{v:Int | true}*)) = 11 | if n >= 0 then f n h -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/intro3.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as intro3 3 | *) 4 | 5 | 6 | let f (x:int) g: unit = g (x + 1) 7 | 8 | let h (z:int) (y:int) = assert(y > z) 9 | 10 | let main (n:int(*-:{v:Int | true}*)) = 11 | if n >= 0 then f n (h n) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/max.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as max 3 | USED: PEPM2013 as max 4 | *) 5 | 6 | 7 | let max (max2: int -> int -> int) (mx:int) (my:int) (mz:int) = max2 (max2 mx my) mz 8 | let f (fx:int) (fy:int) = if fx >= fy then fx else fy 9 | 10 | let main (x:int(*-:{v:Int | true}*)) (y:int(*-:{v:Int | true}*)) (z:int(*-:{v:Int | true}*)) = 11 | let m = max f x y z in 12 | assert (f x m = m) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/mc91_cps.ml: -------------------------------------------------------------------------------- 1 | 2 | (* 3 | Res: OCaml -> 91 4 | imprecision: Oct: 91 <= v 5 | Liquid Haskell: TODO: need to TEST! 6 | *) 7 | 8 | 9 | let rec m x (k:int -> unit): unit = 10 | if x > 100 11 | then k (x-10) 12 | else 13 | let f r = m r k in 14 | m (x+11) f 15 | 16 | let main (n:int(*-:{v:Int | true}*)) = 17 | let k r = if n <= 101 then assert (r = 91) in 18 | m n k 19 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/neg1.ml: -------------------------------------------------------------------------------- 1 | 2 | (* 3 | Res: OCaml -> 6 4 | imprecision: Oct: -6 <= v <= 6 5 | Liquid Haskell: TODO: need to TEST! 6 | *) 7 | 8 | let g (gx:int) (gy:unit) = 2 * gx 9 | 10 | let twice f (tx:unit->int) (ty:unit) = f (f tx) ty 11 | 12 | let neg nx (ny:unit) = - nx () 13 | 14 | let main (n:int(*-:{v:Int | true}*)) = 15 | if n>=0 then 16 | let z = twice neg (g n) () in 17 | assert (z>=0) 18 | 19 | (* 20 | Reason: strenthen in here is table not relation, so the call-site could not be specified for f 21 | *) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/neg2.ml: -------------------------------------------------------------------------------- 1 | 2 | let g (gx: int) = 2 * gx 3 | 4 | let twice (tx: int) (tf: int -> int) = tf (tf tx) 5 | 6 | let neg (nx: int) = (0 - nx) 7 | 8 | let main (n:int(*-:{v:Int | true}*)) = 9 | let z = twice (g n) neg in 10 | if (n > 0) then assert (z >= 0) 11 | else assert (z <= 0) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/recursive.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec f (g: int -> int) x = if x >= 0 then g x else f (f g) (g x) 3 | let succ sx = sx + 1 4 | 5 | let main (n:int(*-:{v:Int | true}*)) = 6 | assert (f succ n >= 0) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/repeat.ml: -------------------------------------------------------------------------------- 1 | let rec succ x = x + 1 2 | let rec repeat f n s = 3 | if n = 0 then 4 | s 5 | else 6 | f (repeat f (n - 1) s) 7 | 8 | let main (n:int(*-:{v:Int | true}*)) = 9 | assert (repeat succ n 0 >= n) 10 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/repeat4.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let succ sx = sx + 1 4 | 5 | let rec repeat (rf: int -> int) rn = 6 | if rn = 0 7 | then 0 8 | else rf (repeat rf (rn - 1)) 9 | 10 | let main (n:int(*-:{v:Int | true}*)) = 11 | assert (repeat succ n = n) 12 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/repeat_mochi.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as repeat 3 | *) 4 | 5 | 6 | let succ sx = sx + 1 7 | 8 | let rec repeat (rf: int -> int) rn rs = 9 | if rn = 0 then 10 | rs 11 | else 12 | rf (repeat rf (rn - 1) rs) 13 | 14 | let main (n:int(*-:{v:Int | true}*)) = 15 | assert (repeat succ n 0 = n) 16 | -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/sigma_sum.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec sum n = 4 | if n <= 0 5 | then 0 6 | else n + sum (n - 1) 7 | 8 | let rec sigma (f: int -> int) n = 9 | if n <= 0 10 | then 0 11 | else f n + sigma f (n - 1) 12 | 13 | let main (mn:int(*-:{v:Int | true}*)) = 14 | assert (sigma sum mn >= mn) -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/sum_cps.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec cps_sum (cn: int) (ck: int -> unit) = 4 | if cn <= 0 then 5 | ck 0 6 | else 7 | let f (fx: int) = ck (fx + cn) in 8 | cps_sum (cn - 1) f 9 | 10 | let main (n:int(*-:{v:Int | true}*)) = 11 | let u (ux: int) = assert (ux >= n) in 12 | cps_sum n u -------------------------------------------------------------------------------- /tests/benchmarks/r_type/high/twice.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let twice (tf: int -> int) tx = tf (tf tx) 4 | let f fx = 2 * fx 5 | 6 | let main (n:int(*-:{v:Int | true}*)) = 7 | if n > 0 8 | then assert (twice f n > n) -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/first/01_ic3.ml: -------------------------------------------------------------------------------- 1 | 2 | (* 3 | * IC3 motivating example 4 | *) 5 | 6 | 7 | let rec loop lx ly = 8 | if (ly < 45) then 9 | let t1 = lx in 10 | let t2 = ly in 11 | loop (t1 + t2) (t1 + t2) 12 | else assert (ly >= 1) 13 | 14 | let main (mm:unit) = 15 | let x = 1 in 16 | let y = 1 in 17 | loop x y 18 | 19 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/first/prog2.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loop lx ly = 4 | if lx <= 9 then 5 | loop (lx + 1) (ly+1) 6 | else 7 | assert (ly >= 0) 8 | 9 | let main (m:unit) = 10 | let x = 0 in 11 | let y = 0 in 12 | loop x y 13 | 14 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/first/recHanoi03.ml: -------------------------------------------------------------------------------- 1 | 2 | (* 3 | * recHanoi.c 4 | * 5 | * Created on: 17.07.2013 6 | * Author: Stefan Wissert 7 | *) 8 | 9 | 10 | (* 11 | * This function returns the optimal amount of steps, 12 | * needed to solve the problem for n-disks 13 | *) 14 | 15 | 16 | let rec hanoi n = 17 | if (n <= 1) then 1 18 | else 2 * (hanoi (n - 1)) + 1 19 | 20 | 21 | let main (k:unit) = 22 | let n = 13 in 23 | let result = hanoi n in 24 | assert (result >= n) 25 | 26 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/first/xy0.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loopa lx ly = 4 | if (ly < 10) then 5 | loopa (lx + 1) (ly + 1) 6 | else lx 7 | 8 | let rec loopb bx by = 9 | if (bx > 0) then 10 | loopb (bx - 1) (bx - 1) 11 | else assert (by > (-1)) 12 | 13 | let main (mm:unit) = 14 | let x = 0 in 15 | let y = 0 in 16 | 17 | loopa x y 18 | 19 | let _ = main() -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/first/xy10.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loopa ax ay az = 4 | if (ay < 20) then 5 | loopa (ax+10) (ay+1) az 6 | else 7 | ax > az || ay < az + 1 8 | 9 | let main_p (z:int) = 10 | let x = 0 in 11 | let y = 0 in 12 | assert (loopa x y z = true) 13 | 14 | let main (w:unit) = 15 | let _ = main_p 5 in 16 | let _ = main_p (-4) in 17 | (* let _ = 18 | for i = 1 to 1000000 do 19 | main (Random.int 1000) 20 | done *) 21 | () 22 | 23 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/first/xy4.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loopa ax ay = 4 | if ay < 4 then 5 | loopa (ax + 4) (ay + 1) 6 | else ax 7 | 8 | let rec loopb bx by = 9 | if bx > 0 then 10 | loopb (bx - 4) (by - 1) 11 | else by > (-1) 12 | 13 | let main (mm:unit) = 14 | let x = 0 in 15 | let y = 0 in 16 | 17 | let rx = loopa x y in 18 | assert (loopb rx 4 = true) 19 | 20 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/first/xyz.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loopa ax ay az = 4 | if (ax < 10) then 5 | loopa (ax + 1) (ay + 1) (az - 2) 6 | else az 7 | 8 | let rec loopb bx by bz = 9 | if (bx > 0) then 10 | (let rz = bz + 2 in 11 | let rx = bx - 1 in 12 | let ry = by - 1 in 13 | loopb rx ry rz) 14 | else bz > (-1) 15 | 16 | let main (mm:unit) = 17 | let x = 0 in 18 | let y = 0 in 19 | let z = 0 in 20 | 21 | let rsz = loopa x y z in 22 | let rsx = 10 in 23 | assert (loopb rsx rsx rsz = true) 24 | 25 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/first/xyz2.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loopa ax ay az = 4 | if (ax < 10) then 5 | loopa (ax + 1) (ay + 1) (az - 2) 6 | else az 7 | 8 | let rec loopb bx by bz = 9 | if (bx >= 1) then 10 | let rz = bz + 2 in 11 | let rx = bx - 1 in 12 | let ry = by - 1 in 13 | loopb rx ry rz 14 | else 15 | bz < 1 16 | 17 | let main (mm:unit) = 18 | let x = 0 in 19 | let y = 0 in 20 | let z = 0 in 21 | 22 | let rsz = loopa x y z in 23 | let rsx = 10 in 24 | assert (loopb rsx rsx rsz = true) 25 | 26 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/high/app-lin-ord2.ml: -------------------------------------------------------------------------------- 1 | 2 | let app (ab:int) (af:int->unit) ax = af ax 3 | 4 | let check (cx:int) (cy:int) = assert (cx = cy) 5 | 6 | let main_p (a:int) (b:int) = 7 | app (4 * a + 2 * b) (check (4 * a + 2 * b)) (4 * a + 2 * b) 8 | 9 | let main (w:unit) = 10 | let _ = main_p 1 1 in 11 | (* let _ = 12 | for i = 1 to 1000000 do 13 | main (Random.int 1000) (Random.int 1000) 14 | done *) 15 | () 16 | 17 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/high/app-lin-ord3.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let app (ab:int) (af:int->(int->unit)->unit) aa (ag:int->unit) = af aa ag 4 | 5 | let f (fx:int) (fa:int) (fk:int->unit) = fk fx 6 | 7 | let check (x:int) (y:int) = assert (x = y) 8 | 9 | let main_p (a:int) (b:int) = 10 | app (4 * a + 2 * b) (f (4 * a + 2 * b)) (4 * a + 2 * b) (check (4 * a + 2 * b)) 11 | 12 | let main (w:unit) = 13 | let _ = main_p 1 1 in 14 | (* let _ = 15 | for i = 1 to 1000000 do 16 | main (Random.int 1000) (Random.int 1000) 17 | done *) 18 | () 19 | 20 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/high/app-nonrec.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let apply (ab:int) (af: int->unit) ax = af ax 4 | 5 | let check (cx:int) (cy:int) = assert (cx = cy) 6 | 7 | let main_p (n:int) = 8 | apply n (check n) n 9 | 10 | let main (w:unit) = 11 | let _ = main_p 2 in 12 | (* let _ = 13 | for i = 1 to 1000000 do 14 | main (Random.int 1000) 15 | done *) 16 | () 17 | 18 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/high/app-succ.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let succ (sb:int) (sf:int->unit) sx = sf (sx + 1) 4 | 5 | let rec app (b:int) (f:int->unit) x (k:int) = 6 | if k > 0 then app (b - 1) (succ (b - 1) f) (x - 1) (k - 1) else f x 7 | 8 | let check (cx:int) (cy:int) = assert (cx <= cy) 9 | 10 | let main_p (n:int) (m:int) = app n (check n) n m 11 | 12 | let main (w:unit) = 13 | let _ = main_p 5 4 in 14 | let _ = main_p 30 (-2) in 15 | let _ = main_p 0 3 in 16 | let _ = main_p (-4) (-6) in 17 | let _ = main_p (-102) 1 in 18 | (* let _ = 19 | for i = 1 to 1000000 do 20 | main (Random.int 1000) (Random.int 1000) 21 | done *) 22 | () 23 | 24 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/high/intro-ord2.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec app (a:int) (f:int->unit) (x:int) (k:int) = 3 | if k > 0 then 4 | app a f (x + 1) (k - 1) 5 | else f x 6 | 7 | let check (cx:int) (cy:int) = assert (cx <= cy) 8 | 9 | let main_p (i:int) (j:int) = app i (check i) i j 10 | 11 | let main (w:unit) = 12 | let _ = main_p 5 2 in 13 | (* let _ = 14 | for i = 1 to 1000000 do 15 | main (Random.int 1000) (Random.int 1000) 16 | done *) 17 | () 18 | 19 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/high/intro-ord3.ml: -------------------------------------------------------------------------------- 1 | 2 | let succ (sb:int) (sf:int->unit) sx = sf (sx + 1) 3 | 4 | let rec app3 (b:int) (f:int->unit) (a:int) (g:int->(int->unit)->unit) (k:int) = 5 | if k > 0 then app3 b (succ b f) b g (k - 1) else g b f 6 | 7 | let app ax (ab:int) (af:int->unit) = af ax 8 | 9 | let check (cx:int) (cy:int) = assert (cx <= cy) 10 | 11 | let main_p (i:int) (j:int) = app3 i (check i) i (app i) j 12 | 13 | let main (w:unit) = 14 | let _ = main_p 2 4 in 15 | (* let _ = 16 | for i = 1 to 1000000 do 17 | main (Random.int 1000) (Random.int 1000) 18 | done *) 19 | () 20 | 21 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/high/repeat_order.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec repeat (f:int->int) n s = 3 | if n = 0 then 4 | s 5 | else 6 | f (repeat f (n - 1) s) 7 | 8 | let succ x = x + 1 9 | 10 | let main_p (mn:int) = 11 | assert(repeat succ mn 0 >= mn) 12 | 13 | let main (w:unit) = 14 | let _ = main_p 2 in 15 | (* let _ = 16 | for i = 1 to 1000000 do 17 | main (Random.int 1000) 18 | done *) 19 | () 20 | 21 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/list/fold_div.ml: -------------------------------------------------------------------------------- 1 | let rec fold_left f (acc:int) (xs:int list) = 2 | match xs with 3 | [] -> acc 4 | | x::xs' -> fold_left f (f acc x) xs' 5 | 6 | let rec make_list n = 7 | if n <= 0 then [] 8 | else n :: make_list (n - 1) 9 | 10 | let div x y = (assert (y <> 0); x / y) 11 | 12 | let main (n:int) (m:int) = 13 | if n > 0 && m > 0 then 14 | let xs = make_list n in 15 | assert(fold_left div m xs >= 0) 16 | else () 17 | 18 | let _ = main 1 1 -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/list/fold_fun_list.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec make_list n = 4 | if n <= 0 5 | then [] 6 | else (fun m -> n + m) :: make_list (n - 1) 7 | 8 | let rec fold_right (f:(int->int)->(int->int)->int->int) (xs:(int->int) list) (init:int->int) = 9 | match xs with 10 | [] -> init 11 | | x::xs' -> f x (fold_right f xs' init) 12 | 13 | let compose (f:int->int) (g:int->int) (d:int) = f (g d) 14 | 15 | let id (c:int) = c 16 | 17 | let main (n:int) = 18 | if n > 0 then 19 | let xs = make_list n in 20 | let f = fold_right compose xs id in 21 | assert (f 0 >= 0) 22 | else () 23 | 24 | let _ = main 3 -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/list/fold_left.ml: -------------------------------------------------------------------------------- 1 | let rec fold_left (f:int->int->int) acc xs = 2 | match xs with 3 | [] -> acc 4 | | x::xs' -> fold_left f (f acc x) xs' 5 | 6 | let rec make_list n = 7 | if n < 0 then [] 8 | else n :: make_list (n - 1) 9 | 10 | let add x y = x + y 11 | 12 | let main (n:int) (m:int) = 13 | if n > 0 then 14 | let xs = make_list n in 15 | assert (fold_left add m xs >= m) 16 | else () 17 | 18 | let _ = main 1 1 19 | let _ = main 1 (-1) -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/list/fold_right.ml: -------------------------------------------------------------------------------- 1 | let rec fold_right (f:int->int->int) xs acc = 2 | match xs with 3 | [] -> acc 4 | | x::xs' -> f x (fold_right f xs' acc) 5 | 6 | let rec make_list n = 7 | if n < 0 8 | then [] 9 | else n :: make_list (n - 1) 10 | 11 | let add x y = x + y 12 | 13 | let main (n:int) (m:int) = 14 | if n > 0 && m > 0 then 15 | let xs = make_list n in 16 | assert (fold_right add xs m >= m) 17 | else () 18 | 19 | let _ = main 1 1 -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/list/forall_leq.ml: -------------------------------------------------------------------------------- 1 | let rec for_all f (xs:int list) = 2 | match xs with 3 | [] -> 1 4 | | x::xs' -> 5 | if (f x > 0) && (for_all f xs' > 0) then 1 6 | else 0 7 | 8 | let check x = 9 | if (x >= 0) then 1 10 | else 0 11 | 12 | let rec make_list n = 13 | if n < 0 14 | then [] 15 | else n :: make_list (n - 1) 16 | 17 | let main (n:int) = 18 | if n > 0 then 19 | assert (for_all check (make_list n) > 0) 20 | else () 21 | 22 | let _ = main 3 -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/list/introlist.ml: -------------------------------------------------------------------------------- 1 | let rec make_list m = 2 | if m <= 0 then [] 3 | else m :: make_list (m - 1) 4 | 5 | let f xs = match xs with 6 | | [] -> () 7 | | x :: xs -> assert (x > 0) 8 | 9 | let main (n:int) = 10 | let xs = make_list n in 11 | f xs 12 | 13 | let _ = main 1 -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/list/isnil.ml: -------------------------------------------------------------------------------- 1 | let is_nil (xs:int list) = 2 | match xs with 3 | [] -> 1 4 | | _ -> 0 5 | 6 | let rec make_list n = 7 | if n = 0 8 | then [] 9 | else n :: make_list (n - 1) 10 | 11 | let main (n:int) = 12 | if n > 0 13 | then 14 | let xs = make_list n in 15 | assert((is_nil xs) <> 1) 16 | else () 17 | 18 | let _ = main 3 -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/list/iter.ml: -------------------------------------------------------------------------------- 1 | let rec iter (f:int -> unit) xs = 2 | match xs with 3 | [] -> () 4 | | x::xs' -> f x; iter f xs' 5 | 6 | let rec make_list n = 7 | if n < 0 8 | then [] 9 | else n :: make_list (n - 1) 10 | 11 | let check x = assert (x >= 0) 12 | 13 | let main (n:int) = 14 | if n > 0 then 15 | let xs = make_list n in 16 | iter check xs 17 | else () 18 | 19 | let _ = main 3 -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/list/length.ml: -------------------------------------------------------------------------------- 1 | let rec length (xs:int list) = 2 | match xs with 3 | [] -> 0 (*l=0 v=0*) 4 | | x::xs' -> 1 + length xs' (*n>=l>=1 v=1*) 5 | 6 | let rec make_list n = 7 | if n = 0 8 | then [] (* 'a list *) 9 | else n :: make_list (n - 1) 10 | 11 | let main (n:int) = 12 | if n > 0 then 13 | let xs = make_list n in 14 | assert (length xs = n) 15 | else () 16 | 17 | let _ = main 1 18 | -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/list/list.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec make_list n = 3 | if n <= 0 4 | then [] 5 | else n :: make_list (n - 1) 6 | 7 | let rec length (xs:int list) = 8 | match xs with 9 | [] -> 0 10 | | x::xs' -> 1 + length xs' 11 | 12 | let main (n:unit) = 13 | let xs = [0; 1; 2] in 14 | let ys = make_list 3 in 15 | assert(length xs = length ys) 16 | 17 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/list/mem.ml: -------------------------------------------------------------------------------- 1 | let rec mem (x:int) (xs:int list) = 2 | match xs with 3 | [] -> 0 4 | | x'::xs' -> 5 | if x = x' then 1 6 | else if (mem x xs' > 0) then 1 7 | else 0 8 | 9 | let rec make_list n (x:int) = 10 | if n < 0 11 | then [] 12 | else x :: make_list (n - 1) x 13 | 14 | let main (n:int) (m:int) = 15 | if n > 0 then 16 | let xs = make_list n m in 17 | match xs with 18 | | [] -> () 19 | | x::xs' -> assert (mem m xs > 0) 20 | else () 21 | 22 | let _ = main 1 0 -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/list/nth.ml: -------------------------------------------------------------------------------- 1 | let rec nth n (xs:int list) = 2 | match xs with 3 | | [] -> -1 4 | | x::xs' -> if n = 0 then x else nth (n - 1) xs' 5 | 6 | let rec make_list n = 7 | if n < 0 8 | then [] 9 | else n :: make_list (n - 1) 10 | 11 | let main (n:int) = 12 | if n > 0 then 13 | let xs = make_list n in 14 | assert(nth (n - 1) xs >= 0) 15 | else () 16 | 17 | let _ = main 1 -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/list/reverse.ml: -------------------------------------------------------------------------------- 1 | 2 | (*rename error*) 3 | let rec reverseinner (xs:int list) (acc:int list) = 4 | match xs with 5 | [] -> acc 6 | | x :: xs' -> reverseinner xs' (x :: acc) 7 | 8 | let reverse (xs:int list) = reverseinner xs [] 9 | 10 | let rec make_list n = 11 | if n = 0 12 | then [] 13 | else n :: make_list (n - 1) 14 | 15 | let hd (xs:int list) = 16 | match xs with 17 | [] -> -1 18 | | x::xs' -> x 19 | 20 | let main (n:int) = 21 | let xs = make_list n in 22 | if n > 0 then assert(hd (reverse xs) > 0) 23 | else () 24 | 25 | let _ = main 2 -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/list/simple.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec mapfilter (f:int->int list) (l:int list) = match l with 3 | | [] -> [] 4 | | h::t -> 5 | let r = mapfilter f t in 6 | let x = f h in 7 | match x with 8 | | [] -> r 9 | | z::e -> (z::r) 10 | 11 | let pos y = 12 | if 0 < y then 13 | y::[] 14 | else 15 | [] 16 | 17 | let main (u:unit) = 18 | let xs = [1;2;1] in 19 | let ys = mapfilter pos xs in 20 | assert(List.length ys = List.length xs) 21 | 22 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DOrder/list/zip.ml: -------------------------------------------------------------------------------- 1 | let rec zip (xs:int list) (ys:int list) = 2 | match xs with 3 | [] -> ( 4 | match ys with 5 | [] -> [] 6 | | y::ys' -> assert(false) ; [] 7 | ) 8 | | x::xs' -> 9 | (match ys with 10 | [] -> assert(false) ; [] 11 | | y::ys' -> (x, y)::(zip xs' ys')) 12 | 13 | let rec make_list n = 14 | if n < 0 15 | then [] 16 | else n :: make_list (n - 1) 17 | 18 | let main (n:int) = 19 | if n > 0 then 20 | let xs = make_list n in 21 | let ys = zip xs xs in 22 | assert(List.length ys = List.length xs) 23 | else () 24 | 25 | let _ = main 1 -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/array/a-dotprod.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as a-prod 3 | *) 4 | 5 | let rec dotprod dn (vd1: int array) (vd2: int array) di sum = 6 | if di >= dn then 7 | sum 8 | else 9 | dotprod dn vd1 vd2 (di + 1) (sum + (Array.get vd1 di) * (Array.get vd2 di)) 10 | 11 | let main_p (z:int) (n:int) = 12 | if z = 0 && n > 0 then 13 | let v1 = Array.make n 1 in 14 | let v2 = Array.make n 1 in 15 | dotprod n v1 v2 z z; () 16 | else () 17 | 18 | let main (w:unit) = 19 | let _ = main_p 0 4 in 20 | let _ = main_p 10 10 in 21 | () 22 | 23 | let _ = main () 24 | -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/array/a-init1.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as a-init 3 | *) 4 | 5 | 6 | let rec init idx tn (ia: int array) = 7 | if idx < 0 then init 0 tn ia 8 | else if idx >= tn then () 9 | else (Array.set ia idx 1; init (idx + 1) tn ia) 10 | 11 | let main_p (k:int) (n:int) (i:int) = 12 | if i >= k && i >= 0 && i < n then 13 | (let a = Array.make n 0 in 14 | init k n a; 15 | let item = Array.get a i in 16 | assert(item >= 1)) 17 | else () 18 | 19 | let main (w:unit) = 20 | let _ = main_p 2 5 3 in 21 | let _ = main_p (-10) 10 2 in 22 | () 23 | 24 | let _ = main () 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/array/a-init2.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec init idx tn (ta: int array) = 4 | if idx >= tn then () 5 | else (Array.set ta idx 1; init (idx + 1) tn ta) 6 | 7 | let main_p (n:int) (i:int) = 8 | if i >= 0 && i < n then 9 | let a = Array.make n 0 in 10 | init i n a; 11 | let item = Array.get a i in 12 | assert(item >= 1) (* check that the array has been revised *) 13 | else () 14 | 15 | let main (w:unit) = 16 | let _ = main_p 10 3 in 17 | let _ = main_p 20 5 in 18 | () 19 | 20 | let _ = main () 21 | 22 | -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/array/a-iter.ml: -------------------------------------------------------------------------------- 1 | 2 | let succ si = si + 1 3 | 4 | let rec iter_helper (hf: int -> int) hi hn (ha: int array) = 5 | if (hi < hn) then 6 | let _ = hf (Array.get ha hi) in 7 | iter_helper hf (hi + 1) hn ha 8 | else () 9 | 10 | let rec iter (mf: int -> int) (ma: int array) = 11 | let mn = Array.length ma in 12 | iter_helper mf 0 mn ma 13 | 14 | let main_p (n:int) = 15 | if n > 0 then 16 | let a = Array.make n 0 in 17 | iter succ a 18 | else () 19 | 20 | let main (w:unit) = 21 | let _ = main_p 30 in 22 | let _ = main_p 10 in 23 | () 24 | 25 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/array/a-map.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec map_helper (hf: int -> int) hi hn (ha: int array) (hb: int array) = 3 | if (hi < hn) then 4 | let _ = Array.set hb hi (hf (Array.get ha hi)) in 5 | map_helper hf (hi + 1) hn ha hb 6 | else hb 7 | 8 | let rec map (mf: int -> int) (ma: int array) = 9 | let mn = Array.length ma in 10 | let mb = Array.make mn 0 in 11 | map_helper mf 0 mn ma mb 12 | 13 | let succ si = si + 1 14 | 15 | let main_p (n:int) = 16 | if n > 0 then 17 | let a = Array.make n 0 in 18 | assert(Array.length (map succ a) = Array.length a) 19 | else () 20 | 21 | let main (w:unit) = 22 | let _ = main_p 24 in 23 | let _ = main_p 10 in 24 | () 25 | 26 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/array/a-reverse.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec reverse ri rn (ra: int array) (rb: int array) = 4 | if (ri < rn) then 5 | let _ = Array.set rb (rn - ri - 1) (Array.get ra ri) in 6 | reverse (ri + 1) rn ra rb 7 | else () 8 | 9 | let main_p (n:int) = 10 | if n > 0 then 11 | let a = Array.make n 0 in 12 | let b = Array.make n 0 in 13 | reverse 0 n a b 14 | else () 15 | 16 | let main (w:unit) = 17 | let _ = main_p 8 in 18 | let _ = main_p 12 in 19 | () 20 | 21 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/array/bcopy.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec bcopy_aux (src: int array) (des: int array) i m = 3 | if i >= m then true 4 | else 5 | ( 6 | Array.set des i (Array.get src i); 7 | 0 <= i && i < (Array.length src) && bcopy_aux src des (i+1) m 8 | ) 9 | 10 | let bcopy (src: int array) (des: int array) = bcopy_aux src des 0 (Array.length src) 11 | 12 | let main_p (mn:int) (mm:int) = 13 | if mn > 0 && mn <= mm then 14 | let array1 = Array.make mn 0 in 15 | let array2 = Array.make mm 0 in 16 | assert(bcopy array1 array2 = true) 17 | else () 18 | 19 | let main (w:unit) = 20 | let _ = main_p 5 10 in 21 | let _ = main_p 12 26 in 22 | () 23 | 24 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/first/addition.ml: -------------------------------------------------------------------------------- 1 | (* 2 | From: jayhorn/benchmarks SatAddition01_true.java 3 | *) 4 | 5 | let rec addition (lm:int) (ln:int) = 6 | if ln = 0 then lm 7 | else if ln > 0 then 8 | addition (lm + 1) (ln - 1) 9 | else addition (lm - 1) (ln + 1) 10 | 11 | let main_p (m:int) (n:int) = 12 | if n > 0 && m > 0 then 13 | assert(addition m n = m + n) 14 | else () 15 | 16 | let main (w:unit) = 17 | let _ = main_p 10 4 in 18 | let _ = main_p 30 5 in 19 | (* let _ = 20 | for i = 1 to 1000000 do 21 | main (Random.int 1000) (Random.int 1000) 22 | done *) 23 | () 24 | 25 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/first/for_bounded_loop1.ml: -------------------------------------------------------------------------------- 1 | (* 2 | From: SV-COMP 2020 for_bounded_loop1.c 3 | *) 4 | 5 | let rec loop (i:int) (n:int) (x:int) (y:int) = 6 | if i >= n then x - y 7 | else 8 | let xp = x - y in 9 | assert(xp = 0); 10 | let yp = y + i in 11 | loop (i + 1) n (xp + yp) (yp) 12 | 13 | let main_p (n:int) = 14 | if n <= 0 then () 15 | else assert(loop 0 n 0 0 = 0) 16 | 17 | let main (w:unit) = 18 | let _ = main_p 10 in 19 | let _ = main_p 30 in 20 | (* let _ = 21 | for i = 1 to 1000000 do 22 | main (Random.int 1000) 23 | done *) 24 | () 25 | 26 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/first/half.ml: -------------------------------------------------------------------------------- 1 | (* 2 | From: SV-COMP 2020 half.c 3 | https://github.com/sosy-lab/sv-benchmarks/tree/master/c/loop-new 4 | *) 5 | 6 | let rec half i k n = 7 | if i >= 2 * k then assert(n = k) 8 | else 9 | if i mod 2 = 0 then 10 | half (i + 1) k (n + 1) 11 | else half (i + 1) k n 12 | 13 | let main_p (mn:int) = 14 | if mn < 0 then () 15 | else half 0 mn 0 16 | 17 | let main (w:unit) = 18 | let _ = main_p 12 in 19 | let _ = main_p 540 in 20 | (* let _ = 21 | for i = 1 to 1000000 do 22 | main (Random.int 1000) 23 | done *) 24 | () 25 | 26 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/first/mult_twice.ml: -------------------------------------------------------------------------------- 1 | (* 2 | From: jayhorn/benchmarks MultCommutative01_true.java 3 | *) 4 | 5 | let rec mult (mn:int) (mm:int) = 6 | if mn <= 0 || mm <= 0 then 7 | 0 8 | else 9 | mn + mult mn (mm - 1) 10 | 11 | let main_p (n:int) (m:int) = 12 | if m < 0 && n < 0 then () 13 | else 14 | let res1 = mult m n in 15 | let res2 = mult n m in 16 | assert(res1 = res2) 17 | 18 | let main (w:unit) = 19 | let _ = main_p 3 4 in 20 | let _ = main_p 7 5 in 21 | (* let _ = 22 | for i = 1 to 1000000 do 23 | main (Random.int 1000) (Random.int 1000) 24 | done *) 25 | () 26 | 27 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/first/sum6.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec sum n = 4 | if n <= 0 5 | then 0 6 | else n + sum (n - 1) 7 | 8 | let main_p (mn:int) = 9 | assert (6 * mn - 15 <= sum mn) 10 | 11 | let main (w:unit) = 12 | let _ = main_p 10 in 13 | let _ = main_p 47 in 14 | (* let _ = 15 | for i = 1 to 1000000 do 16 | main (Random.int 1000) 17 | done *) 18 | () 19 | 20 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/high/apply_twice.ml: -------------------------------------------------------------------------------- 1 | 2 | let apply (af:int -> int) (ax:int) = af ax 3 | 4 | let twice (tx:int) = 2 * tx 5 | 6 | let neg_twice (nx:int) = 0 - (2 * nx) 7 | 8 | let main_p (n:int) = 9 | let res = 10 | if n >= 0 then 11 | apply twice n 12 | else 13 | apply neg_twice n 14 | in 15 | assert(res >= 0) 16 | 17 | let main (w:unit) = 18 | let _ = main_p 4 in 19 | let _ = main_p 0 in 20 | let _ = main_p (-34) in 21 | (* let _ = 22 | for i = 1 to 1000000 do 23 | main (Random.int 1000) 24 | done *) 25 | () 26 | 27 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/high/call_back.ml: -------------------------------------------------------------------------------- 1 | 2 | let mk_adder (x:int) = 3 | let adder (i:int) = i + x in 4 | adder 5 | 6 | let main_p (mx:int) (mi:int) = 7 | let addr = mk_adder mx in 8 | assert (addr mi = mi + mx) 9 | 10 | let main (w:unit) = 11 | let _ = main_p 10 3 in 12 | let _ = main_p 30 2 in 13 | (* let _ = 14 | for i = 1 to 1000000 do 15 | main (Random.int 1000) (Random.int 1000) 16 | done *) 17 | () 18 | 19 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/high/flip_twice_2.ml: -------------------------------------------------------------------------------- 1 | 2 | let twice tf (tx:int) (ty:int) = tf (tf tx ty) ty 3 | 4 | let flip (f: int -> int -> int) (x:int) (y:int) = f y x 5 | 6 | let square_diff sx sy = (sx + sy) * (sx - sy) 7 | 8 | let main_p (mx:int) = 9 | let res = flip (twice square_diff) mx mx 10 | in 11 | assert(res = mx * (0 - mx)) 12 | 13 | let main (w:unit) = 14 | let _ = main_p 6 in 15 | let _ = main_p 0 in 16 | let _ = main_p (-34) in 17 | (* let _ = 18 | for i = 1 to 1000000 do 19 | main (Random.int 1000) 20 | done *) 21 | () 22 | 23 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/high/mixed_id.ml: -------------------------------------------------------------------------------- 1 | 2 | let id_int (x_idi:int) = x_idi 3 | 4 | let id_f (x_idf:int -> int) = x_idf 5 | 6 | let mid_y (yk:int) = id_int yk 7 | 8 | let z x = id_f x 9 | 10 | let main_p (k:int) = 11 | assert(z mid_y k = k) 12 | 13 | let main (w:unit) = 14 | let _ = main_p 20 in 15 | let _ = main_p 30 in 16 | let _ = main_p (-20) in 17 | (* let _ = 18 | for i = 1 to 1000000 do 19 | main (Random.int 1000) 20 | done *) 21 | () 22 | 23 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/high/multi_compose.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let mf (fx:int) = fx + 5 4 | 5 | let mg (gx:int) = 2 * gx 6 | 7 | let mh (hx:int) = hx - 5 8 | 9 | let compose_1 (f1:int -> int) (g1:int -> int) (x1:int) = f1 (g1 x1) 10 | 11 | let compose_2 (f2:int -> int) (g2:int -> int) (x2:int) = g2 (f2 x2) 12 | 13 | let main_p (mx:int) = 14 | let ans1 = mh (compose_1 mf mg mx) = 2 * mx in 15 | let ans2 = mf (compose_2 mg mh mx) = 2 * mx in 16 | assert(ans1 && ans2 = true) 17 | 18 | let main (w:unit) = 19 | let _ = main_p 20 in 20 | let _ = main_p 30 in 21 | let _ = main_p (-20) in 22 | (* let _ = 23 | for i = 1 to 1000000 do 24 | main (Random.int 1000) 25 | done *) 26 | () 27 | 28 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/high/power.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let comp (cf:int -> int) (cg:int -> int) cx = cf (cg cx) 4 | 5 | let id (dx:int) = dx 6 | 7 | let rec power (f: int -> int) i = 8 | if i = 0 then id 9 | else comp f (power f (i - 1)) 10 | 11 | let succ (sx:int) = sx + 1 12 | 13 | let main_p (m:int) (n:int) = 14 | if m > 0 then 15 | assert(power succ m n >= n) 16 | else () 17 | 18 | let main (w:unit) = 19 | let _ = main_p 4 2 in 20 | let _ = main_p 0 0 in 21 | (* let _ = 22 | for i = 1 to 1000000 do 23 | main (Random.int 1000) (Random.int 1000) 24 | done *) 25 | () 26 | 27 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/negative/01_ic3.ml: -------------------------------------------------------------------------------- 1 | 2 | (* 3 | * Input data error 4 | *) 5 | 6 | let rec loop (lx:int) (ly:int) = 7 | if (lx > 20) then 8 | let t1 = lx in 9 | let t2 = ly in 10 | loop (t1 + t2) (t1 + t2) 11 | else assert (ly >= 1) 12 | 13 | let main (mm:unit) = 14 | let x = 30 in 15 | let y = -1000 in 16 | loop x y (* Should assert failure *) 17 | 18 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/negative/ack01false.ml: -------------------------------------------------------------------------------- 1 | (* 2 | Assertion error 3 | *) 4 | 5 | let rec ack m n = 6 | if m = 0 then n + 1 7 | else if n = 0 then ack (m - 1) 1 8 | else ack (m - 1) (ack m (n - 1)) 9 | 10 | let main_p (mm:int) (mn:int) = 11 | if (mm >= 0 && mn >= 0) 12 | then assert(ack mm mn < mn) 13 | else () 14 | 15 | let main (w:unit) = 16 | let _ = main_p 2 3 in 17 | let _ = main_p 4 5 in 18 | (* let _ = 19 | for i = 1 to 1000000 do 20 | main (Random.int 1000) (Random.int 1000) 21 | done *) 22 | () 23 | 24 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/negative/compose.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * Input data error 3 | *) 4 | 5 | let compose x g h = g (h x) 6 | 7 | let id (ix:int) = ix 8 | 9 | let add (ay:int) = ay + 1 10 | 11 | let main_p (n:int) = 12 | if n <= 0 then assert(compose n add id > 1) 13 | else () 14 | 15 | let main (w:unit) = 16 | let _ = main_p (-100) in 17 | let _ = main_p 0 in 18 | (* let _ = 19 | for i = 1 to 1000000 do 20 | main (Random.int 1000) 21 | done *) 22 | () 23 | 24 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/negative/ex23.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loop (ly:int) (lz:int) (lc:int) = 4 | if lc < 36 then 5 | if lz >= 0 && lz < 4608 then 6 | loop ly (lz+1) (lc+1) 7 | else -1 8 | else lz 9 | 10 | let main_p (y:int) = 11 | if y < 0 then 12 | (let c = 0 in 13 | let z = y * 36 in 14 | let ans = loop y z c in 15 | assert(ans >= 0 && ans <= 4608)) 16 | else () 17 | 18 | let main (w:unit) = 19 | let _ = main_p (-234) in 20 | let _ = main_p (-3) in 21 | (* let _ = 22 | for i = 1 to 1000000 do 23 | main (Random.int 1000) 24 | done *) 25 | () 26 | 27 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/negative/inductive1-1.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * Assertion error 3 | *) 4 | 5 | let rec loop (x:int) (i:int) = 6 | if i < 0 then 7 | x 8 | else if x < 1 then (* x <= 0*) 9 | loop (x - 1) (i - 1) 10 | else if x > 2 then (* x >= 3*) 11 | loop x (i - 1) 12 | else (* 1 2 *) 13 | loop (3 - x) (i - 1) 14 | 15 | let main_p (n:int) = 16 | assert (loop (-3) n >= 3) 17 | 18 | let main (w:unit) = 19 | let _ = main_p 15 in 20 | let _ = main_p 0 in 21 | (* let _ = 22 | for i = 1 to 1000000 do 23 | main (Random.int 1000) 24 | done *) 25 | () 26 | 27 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/negative/repeat.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * Implementation error 3 | *) 4 | 5 | let rec repeat (f: int -> int) n s = 6 | if n = 0 then 7 | s 8 | else 9 | repeat f (n - 1) s 10 | 11 | let succ (x:int) = x + 1 12 | 13 | let main_p (n:int) = 14 | if n > 0 then assert(repeat succ n 0 >= n) 15 | else () 16 | 17 | let main (w:unit) = 18 | let _ = main_p 0 in 19 | let _ = main_p 10 in 20 | (* let _ = 21 | for i = 1 to 1000000 do 22 | main (Random.int 1000) 23 | done *) 24 | () 25 | 26 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/negative/xy10.ml: -------------------------------------------------------------------------------- 1 | (* 2 | Implementation error 3 | Polka_st gets expected 4 | *) 5 | 6 | 7 | let rec loopa ax ay (az:int) = 8 | if (ay < 20) then 9 | loopa (ax+10) (ay+1) az 10 | else 11 | assert (ax <= az && ay >= az + 1) 12 | 13 | let main_p (z:int) = 14 | let x = 0 in 15 | let y = 0 in 16 | loopa x y z 17 | 18 | let main (w:unit) = 19 | let _ = main_p 10 in 20 | let _ = main_p 0 in 21 | let _ = main_p (-100) in 22 | (* let _ = 23 | for i = 1 to 1000000 do 24 | main (Random.int 1000) 25 | done *) 26 | () 27 | 28 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/negative/xy4.ml: -------------------------------------------------------------------------------- 1 | (* 2 | Input data error 3 | *) 4 | 5 | 6 | let rec loopa ax ay = 7 | if ay < 4 then 8 | loopa (ax + 4) (ay + 1) 9 | else ax 10 | 11 | let rec loopb bx by = 12 | if bx > 0 then 13 | loopb (bx - 4) (by - 1) 14 | else assert (by > (-1)) 15 | 16 | let main (mm:unit) = 17 | let x = 0 in 18 | let y = 0 in 19 | 20 | let rx = loopa x y in 21 | loopb rx (-1) 22 | 23 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/negative/xyz.ml: -------------------------------------------------------------------------------- 1 | (* 2 | Implementation error 3 | Polka_st gets expected 4 | *) 5 | 6 | 7 | let rec loopa ax ay az = 8 | if (ax < 10) then 9 | loopa (ax + 1) (ay + 1) (az - 7) 10 | else az 11 | 12 | let rec loopb bx by bz = 13 | if (bx > 0) then 14 | (let rz = bz + 2 in 15 | let rx = bx - 1 in 16 | let ry = by - 1 in 17 | loopb rx ry rz) 18 | else assert (bz > (-1)) 19 | 20 | let main (mm:unit) = 21 | let x = 0 in 22 | let y = 0 in 23 | let z = 0 in 24 | 25 | let rsz = loopa x y z in 26 | let rsx = 10 in 27 | loopb rsx rsx rsz 28 | 29 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/negative/xyz2.ml: -------------------------------------------------------------------------------- 1 | (* 2 | Assertion error 3 | *) 4 | 5 | let rec loopa ax ay az = 6 | if (ax < 10) then 7 | loopa (ax + 1) (ay + 1) (az - 2) 8 | else az 9 | 10 | let rec loopb bx by bz = 11 | if (bx >= 1) then 12 | (let rz = bz + 2 in 13 | let rx = bx - 1 in 14 | let ry = by - 1 in 15 | loopb rx ry rz) 16 | else assert (bz < 1 = false) 17 | 18 | let main (mm:unit) = 19 | let x = 0 in 20 | let y = 0 in 21 | let z = 0 in 22 | 23 | let rsz = loopa x y z in 24 | let rsx = 10 in 25 | loopb rsx rsx rsz 26 | 27 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/DRIFT/negative/zip_unzip.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * Implementation error 3 | *) 4 | 5 | let helper hg hx hy = hg (hx - 1) (hy + 1) 6 | 7 | let rec unzip ux uk = 8 | if ux = 0 then 9 | uk 0 0 10 | else 11 | unzip (ux - 1) (helper uk) 12 | 13 | let rec zip zx zy = 14 | if zx = 0 then (assert (zy = 0); 0) 15 | else (assert (zy <> 0); 1 + zip (zx - 1) (zy - 1)) 16 | 17 | let main_p (n:int) = 18 | if n > 0 then assert(unzip n zip = n) 19 | else () 20 | 21 | let main (w:unit) = 22 | let _ = main_p (-20) in 23 | let _ = main_p 10 in 24 | (* let _ = 25 | for i = 1 to 1000000 do 26 | main (Random.int 1000) 27 | done *) 28 | () 29 | 30 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/array/a-dotprod.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as a-prod 3 | *) 4 | 5 | let make_array n i = assert (0 <= i && i < n); 0 6 | let rec dotprod n v1 v2 i sum = 7 | if i >= n then 8 | sum 9 | else 10 | dotprod n v1 v2 (i + 1) (sum + v1 i * v2 i) 11 | let main_p z n = 12 | let v1 = make_array n in 13 | let v2 = make_array n in 14 | if z=0 then (dotprod n v1 v2 z z; ()) else () 15 | 16 | let main (w:unit) = 17 | let _ = main_p 0 4 in 18 | let _ = main_p 10 10 in 19 | (* let _ = 20 | for i = 1 to 1000 do 21 | main_p (Random.int 1000) (Random.int 1000) 22 | done in *) 23 | () 24 | 25 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/array/a-init1.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as a-init 3 | *) 4 | 5 | let make_array n i = assert (0 <= i && i < n); 0 6 | let update i a x j :int= if j > i - 1 && j <= i then x else a (j) 7 | let rec init i n a = 8 | if i < 0 then init 0 n a 9 | else if i >= n then a else init (i + 1) n (update i a 1) 10 | let main_p k n i = 11 | if i >= k && i >= 0 && i < n then 12 | let x = init k n (make_array n) in 13 | if 0 <= i && i < n then 14 | assert (x i >= 1) 15 | else () 16 | let main (w:unit) = 17 | let _ = main_p 2 5 3 in 18 | let _ = main_p (-10) 10 2 in 19 | () 20 | 21 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/array/a-init2.ml: -------------------------------------------------------------------------------- 1 | let mk_array n i = if 0<=i && i=n then a 5 | else init (i+1) n (update i a 1) 6 | 7 | let main_p n i = 8 | let x = init 0 n (mk_array n) in 9 | if 0<=i && i=1) (* check that the array has been initialized *) 11 | else () 12 | 13 | let main (w:unit) = 14 | let _ = main_p 10 3 in 15 | let _ = main_p 20 5 in 16 | () 17 | 18 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/array/a-reverse.ml: -------------------------------------------------------------------------------- 1 | 2 | let make_array n i = assert (0 <= i && i < n); 0 3 | let update i (n:int) a x j = assert (0 <= i && i < n); if j = i then x else a(j) 4 | 5 | let rec reverse ri rn ra rb = 6 | if (ri < rn) then 7 | let rb2 = update (rn - ri - 1) rn rb (ra(ri)) in 8 | reverse (ri + 1) rn ra rb2 9 | else () 10 | 11 | let main_p (n:int) = 12 | let a = make_array n in 13 | let b = make_array n in 14 | reverse 0 n a b 15 | 16 | let main (w:unit) = 17 | let _ = main_p 8 in 18 | let _ = main_p 12 in 19 | (* let _ = 20 | for i = 1 to 1000 do 21 | main_p (Random.int 1000) 22 | done in *) 23 | () 24 | 25 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/ack.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as ack 3 | USED: PEPM2013 as ack 4 | *) 5 | 6 | let rec ack m n = 7 | if m = 0 then n + 1 8 | else if n = 0 then ack (m - 1) 1 9 | else ack (m - 1) (ack m (n - 1)) 10 | 11 | let main_p (mm:int) (mn:int) = 12 | if (mm >= 0 && mn >= 0) 13 | then assert(ack mm mn >= mn) 14 | else () 15 | 16 | let main (w:unit) = 17 | let _ = main_p 3 2 in 18 | (* let _ = 19 | for i = 1 to 1000000 do 20 | main (Random.int 1000) (Random.int 1000) 21 | done *) 22 | () 23 | 24 | let _ = main () 25 | 26 | -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/copy_intro.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PEPM2013 as copy_intro 3 | *) 4 | 5 | let rec copy (x:int) = 6 | if x = 0 then 0 7 | else 1 + copy (x - 1) 8 | 9 | let main_p (n:int) = 10 | assert (copy (copy n) = n) 11 | 12 | let main (w:unit) = 13 | let _ = main_p 100 in 14 | (* let _ = 15 | for i = 1 to 1000000 do 16 | main (Random.int 1000) 17 | done *) 18 | () 19 | 20 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/enc-rev_accum.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec rev n m = 4 | if n = 0 5 | then m 6 | else rev (n - 1) (m + 1) 7 | 8 | let main_p (mn:int) = 9 | if mn > 0 then assert (rev mn 0 >= mn) 10 | else () 11 | 12 | let main (w:unit) = 13 | let _ = main_p 300 in 14 | (* let _ = 15 | for i = 1 to 1000000 do 16 | main (Random.int 1000) 17 | done *) 18 | () 19 | 20 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/enc-rev_append-1.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec append x y = 3 | if x = 0 then 4 | y 5 | else 6 | 1 + append (x - 1) y 7 | 8 | let rec rev n = 9 | if n = 0 10 | then 0 11 | else append (rev (n - 1)) 1 12 | 13 | let main_p (mn:int) (mm:int) = 14 | if mn >= 0 then assert (rev mn = mn) 15 | else () 16 | 17 | let main (w:unit) = 18 | let _ = main_p 3 5 in 19 | (* let _ = 20 | for i = 1 to 1000000 do 21 | main (Random.int 1000) (Random.int 1000) 22 | done *) 23 | () 24 | 25 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/enc-rev_append-2.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec append x y = 4 | if x = 0 then 5 | y 6 | else 7 | 1 + append (x - 1) y 8 | 9 | let rec rev n = 10 | if n = 0 11 | then 0 12 | else append (rev (n - 1)) 1 13 | 14 | let main_p (mn:int) (mm:int) = 15 | if mn >= 0 && mm >= 0 then 16 | assert (append mn mm = mn + mm) 17 | else () 18 | 19 | let main (w:unit) = 20 | let _ = main_p 3 5 in 21 | (* let _ = 22 | for i = 1 to 1000000 do 23 | main (Random.int 1000) (Random.int 1000) 24 | done *) 25 | () 26 | 27 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/enc-zip.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec zip x y = 3 | if x = 0 4 | then 5 | if y = 0 6 | then 0 7 | else (assert(false); y) 8 | else 9 | if y = 0 10 | then (assert(false); x) 11 | else 1 + zip (x - 1) (y - 1) 12 | 13 | let main_p (n:int) = 14 | assert (zip n n = n) 15 | 16 | let main (w:unit) = 17 | let _ = main_p 100 in 18 | (* let _ = 19 | for i = 1 to 1000000 do 20 | main (Random.int 1000) 21 | done *) 22 | () 23 | 24 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/enc-zip3.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loop (lx:unit) = loop lx 4 | 5 | let rec zip x y = 6 | if x = 0 7 | then 8 | if y = 0 9 | then 0 10 | else loop () 11 | else 12 | if y = 0 13 | then loop () 14 | else 1 + zip (x - 1) (y - 1) 15 | 16 | let main_p (n:int) = 17 | assert (zip n n = n) 18 | 19 | let main (w:unit) = 20 | let _ = main_p 456 in 21 | (* let _ = 22 | for i = 1 to 1000000 do 23 | main (Random.int 1000) 24 | done *) 25 | () 26 | 27 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/enc-zip4.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec zip x y = 4 | if x = 0 5 | then if y = 0 then 0 else (assert(false); y) 6 | else if y = 0 then (assert(false); x) 7 | else 1 + zip (x - 1) (y - 1) 8 | 9 | let main_p (n:int) = 10 | let m = zip n n in 11 | assert (m = n) 12 | 13 | let main (w:unit) = 14 | let _ = main_p 10 in 15 | (* let _ = 16 | for i = 1 to 1000000 do 17 | main (Random.int 1000) 18 | done *) 19 | () 20 | 21 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/enc-zip_map.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loop (lx:unit) = loop lx 4 | let rec zip (x:int) (y:int) = 5 | if x = 0 then 6 | if y = 0 then 0 7 | else loop () (* Dead END! *) 8 | else if y = 0 then loop () (* Dead END! *) 9 | else 1 + zip (x - 1) (y - 1) 10 | 11 | let rec map (mx:int) = 12 | if mx = 0 then 0 else 1 + map (mx - 1) 13 | 14 | let main_p (n:int) = 15 | if n >= 0 then assert(map (zip n n) >= n) 16 | else () 17 | 18 | let main (w:unit) = 19 | let _ = main_p 10 in 20 | (* let _ = 21 | for i = 1 to 1000000 do 22 | main (Random.int 1000) 23 | done *) 24 | () 25 | 26 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/enc-zip_map2.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loop (lx:int) = loop lx 4 | 5 | let rec zip (x:int) (y:int) = 6 | if x = 0 then 7 | if y = 0 then 0 8 | else loop y 9 | else if y = 0 then loop x 10 | else 1 + zip (x - 1) (y - 1) 11 | 12 | let rec map (mx:int) = 13 | if mx = 0 then mx else 1 + map (mx - 1) 14 | 15 | let main_p (n:int) = 16 | if n >= 0 then assert(map (zip n n) = n) 17 | else () 18 | 19 | let main (w:unit) = 20 | let _ = main_p 30 in 21 | (* let _ = 22 | for i = 1 to 1000000 do 23 | main (Random.int 1000) 24 | done *) 25 | () 26 | 27 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/enc-zipmap.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as l-zipmap 3 | USED: PEPM2013 as l-zipmap 4 | *) 5 | 6 | let rec zip x y = 7 | if x = 0 then 8 | if y = 0 then 9 | x 10 | else 11 | (assert(false); y) 12 | else 13 | if y = 0 then 14 | (assert(false); x) 15 | else 16 | 1 + zip (x - 1) (y - 1) 17 | 18 | let rec map mx = 19 | if mx <= 0 then mx else 1 + map (mx - 1) 20 | 21 | let main_p (n:int) = 22 | assert (map (zip n n) = n) 23 | 24 | let main (w:unit) = 25 | let _ = main_p 31 in 26 | (* let _ = 27 | for i = 1 to 1000000 do 28 | main (Random.int 1000) 29 | done *) 30 | () 31 | 32 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/fib.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec fib n = 3 | if n < 2 then 1 else 4 | fib (n - 1) + fib (n - 2) 5 | 6 | let main_p (mn:int) = 7 | assert (fib mn >= mn) 8 | 9 | let main (w:unit) = 10 | let _ = main_p 34 in 11 | (* let _ = 12 | for i = 1 to 1000000 do 13 | main (Random.int 1000) 14 | done *) 15 | () 16 | 17 | let _ = main () 18 | -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/flow.ml: -------------------------------------------------------------------------------- 1 | 2 | let lamp (x:unit) = x 3 | 4 | let f = 5 | let id (dx:int -> unit) = dx in 6 | let unused = id (fun _ -> assert(false)) in 7 | lamp 8 | 9 | let main (i:unit)= 10 | f () 11 | 12 | let _ = main () 13 | -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/fxx.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let f x y = assert (x <= 0 || y > 0) 4 | 5 | let main_p (mx:int) = 6 | f mx mx 7 | 8 | let main (w:unit) = 9 | let _ = main_p 10 in 10 | (* let _ = 11 | for i = 1 to 1000000 do 12 | main (Random.int 1000) 13 | done *) 14 | () 15 | 16 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/gib.ml: -------------------------------------------------------------------------------- 1 | (* 2 | let rec gib a b n = 3 | if n=0 then a 4 | else if n=1 then b 5 | else gib a b (n-1) + gib a b (n-2) 6 | 7 | let main n = 8 | assert (gib 0 1 n >= 0) 9 | *) 10 | 11 | let rec gib ga gb gn = 12 | if gn = 0 then ga 13 | else if gn = 1 then gb 14 | else gib ga gb (gn - 1) + gib ga gb (gn - 2) 15 | 16 | let main_p (n:int) (a:int) (b:int) = 17 | if a >= 0 && b >= 0 && n >= 0 then 18 | assert(gib 0 1 n >= 0) 19 | else () 20 | 21 | let main (w:unit) = 22 | let _ = main_p 10 1 2 in 23 | (* let _ = 24 | for i = 1 to 1000000 do 25 | main (Random.int 1000) (Random.int 1000) (Random.int 1000) 26 | done *) 27 | () 28 | 29 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/gib2.ml: -------------------------------------------------------------------------------- 1 | (* 2 | let rec gib a b n = 3 | if n=0 then a 4 | else if n=1 then b 5 | else gib a b (n-1) + gib a b (n-2) 6 | 7 | let main n = 8 | assert (gib 0 1 n >= 0) 9 | *) 10 | 11 | let rec gib ga gb gn = 12 | if gn = 0 then ga 13 | else if gn = 1 then gb 14 | else gib ga gb (gn - 1) + gib ga gb (gn - 2) 15 | 16 | let main_p (n:int) (a:int) (b:int) = 17 | if a >= 0 && b >= 0 && n >= 0 then 18 | assert(gib a b n >= 0) 19 | else () 20 | 21 | let main (w:unit) = 22 | let _ = main_p 10 3 5 in 23 | (* let _ = 24 | for i = 1 to 1000000 do 25 | main (Random.int 1000) (Random.int 1000) (Random.int 1000) 26 | done *) 27 | () 28 | 29 | let _ = main () 30 | -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/inductive1-1.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loop x i = 4 | if i < 0 then 5 | x 6 | else if x < 1 then (* x <= 0*) 7 | loop (x - 1) (i - 1) 8 | else if x > 2 then (* x >= 3*) 9 | loop x (i - 1) 10 | else (* 1 2 *) 11 | loop (3 - x) (i - 1) 12 | 13 | let main_p (n:int) = 14 | assert (loop 3 n >= 3) 15 | 16 | let main (w:unit) = 17 | let _ = main_p 15 in 18 | (* let _ = 19 | for i = 1 to 1000000 do 20 | main (Random.int 1000) 21 | done *) 22 | () 23 | 24 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/inductive1-2.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loop x i = 4 | if i < 0 then 5 | x 6 | else if x < 1 then 7 | loop (x - 1) (i - 1) 8 | else if x > 2 then 9 | loop x (i - 1) 10 | else 11 | loop (3 - x) (i - 1) 12 | 13 | let main_p (n:int) = 14 | assert (loop 1 n >= 0) 15 | 16 | let main (w:unit) = 17 | let _ = main_p 4 in 18 | (* let _ = 19 | for i = 1 to 1000000 do 20 | main (Random.int 1000) 21 | done *) 22 | () 23 | 24 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/inductive1-3.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec loop x i = 4 | if i < 0 then 5 | x 6 | else if x < 1 then 7 | loop (x - 1) (i - 1) 8 | else if x > 2 then 9 | loop x (i - 1) 10 | else 11 | loop (3 - x) (i - 1) 12 | 13 | let main_p (n:int) = 14 | assert (loop (-3) n <= (-3)) 15 | 16 | let main (w:unit) = 17 | let _ = main_p 10 in 18 | (* let _ = 19 | for i = 1 to 1000000 do 20 | main (Random.int 1000) 21 | done *) 22 | () 23 | 24 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/inductive2.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec f x = 4 | if x < -1 then 5 | f (-2) 6 | else if x <= 0 then 7 | -1 8 | else if x <= 2 then 9 | 3 - x 10 | else 11 | x 12 | 13 | let main (n:unit) = 14 | assert (f 3 >= 0) 15 | 16 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/inductive3-2.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec f x = 4 | if x < -1 then 5 | f (-2) 6 | else if x <= 1 then 7 | 2 * x - 1 8 | else 9 | x 10 | 11 | let main_p (n:int) = 12 | if n >= -1 then assert(f n >= -3) 13 | else () 14 | 15 | let main (w:unit) = 16 | let _ = main_p 12 in 17 | let _ = main_p (-1) in 18 | (* let _ = 19 | for i = 1 to 1000000 do 20 | main (Random.int 1000) 21 | done *) 22 | () 23 | 24 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/inductive3.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec f x = 4 | if x < -1 then 5 | f (-2) 6 | else if x <= 1 then 7 | 2 * x - 1 8 | else 9 | x 10 | 11 | let main_p (n:int) = 12 | if n >= 2 then assert(f n >= 0) 13 | else () 14 | 15 | let main (w:unit) = 16 | let _ = main_p 2 in 17 | (* let _ = 18 | for i = 1 to 1000000 do 19 | main (Random.int 1000) 20 | done *) 21 | () 22 | 23 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/inductive4.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec f g x = 4 | if x < (-3) then (* x<=-4 *) 5 | f g (-4) 6 | else if x <= 1 then (* -3<=x<=1 *) 7 | g x 8 | else (* x>1 *) 9 | f (f g) (x - 2) 10 | 11 | let incr y = y + 1 12 | 13 | let main_p (n:int) = 14 | assert(f incr n >= -3) 15 | 16 | let main (w:unit) = 17 | let _ = main_p 12 in 18 | (* let _ = 19 | for i = 1 to 1000000 do 20 | main (Random.int 1000) 21 | done *) 22 | () 23 | 24 | let _ = main () 25 | -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/inductive5.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec f x = 3 | if x < -2 then 4 | f (-3) 5 | else if x < 2 then 6 | 2 * x - 1 7 | else if x <= 2 then 8 | f (2 * x - 1) 9 | else 10 | x 11 | 12 | let main_p (n:int) = 13 | if n > -2 then assert(f n >= (-3)) 14 | else () 15 | 16 | let main (w:unit) = 17 | let _ = main_p 3 in 18 | (* let _ = 19 | for i = 1 to 1000000 do 20 | main (Random.int 1000) 21 | done *) 22 | () 23 | 24 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/inductive6-2.ml: -------------------------------------------------------------------------------- 1 | 2 | let f g x = 3 | if x > 0 then 4 | g x 5 | else 6 | 1 7 | 8 | let decr dx = dx - 1 9 | 10 | let main_p (n:int) = 11 | if n >= 3 then assert(f decr n > 0) 12 | else () 13 | 14 | let main (w:unit) = 15 | let _ = main_p 79 in 16 | (* let _ = 17 | for i = 1 to 1000000 do 18 | main (Random.int 1000) 19 | done *) 20 | () 21 | 22 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/inductive6.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let f g x = 4 | if x > 0 then 5 | g x 6 | else 7 | 1 8 | 9 | let decr dx = dx - 1 10 | 11 | let main (n:unit) = 12 | assert(f decr 3 > 0) 13 | 14 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/lock.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as r-lock 3 | USED: PEPM2013 as r-lock 4 | *) 5 | 6 | let lock st = assert (st = 0); 1 7 | let unlock st = assert (st = 1); 0 8 | let f n st = if n > 0 then lock (st) else st 9 | let g n st = if n > 0 then unlock (st) else st 10 | 11 | let main_p (mn:int) = 12 | assert ((g mn (f mn 0)) = 0) 13 | 14 | let main (w:unit) = 15 | let _ = main_p 10 in 16 | (* let _ = 17 | for i = 1 to 1000000 do 18 | main (Random.int 1000) 19 | done *) 20 | () 21 | 22 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/map.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec map x = (* x <= 3000 *) 4 | if x = 0 5 | then 0 6 | else 1 + map (x - 1) (* x < 0 && 0 < x <= 3000 *) 7 | 8 | let main_p (n:int) = 9 | if n >= 0 then assert (map n = n) 10 | else () 11 | 12 | let main (w:unit) = 13 | let _ = main_p 30 in 14 | (* let _ = 15 | for i = 1 to 1000000 do 16 | main (Random.int 1000) 17 | done *) 18 | () 19 | 20 | let _ = main () 21 | -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/map_map.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec map x = 4 | if x = 0 then x else 1 + map (x - 1) 5 | 6 | let main_p (n:int) = 7 | if n >= 0 then assert(map (map n) = n) 8 | else () 9 | 10 | let main (w:unit) = 11 | let _ = main_p 15 in 12 | (* let _ = 13 | for i = 1 to 1000000 do 14 | main (Random.int 1000) 15 | done *) 16 | () 17 | 18 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/mc91.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as mc91 3 | USED: PEPM2013 as mc91 4 | 5 | Res: OCaml -> 91 6 | imprecision: Oct: 91 <= v <= 101 7 | Liquid Haskell: false by property {-@ mc91 :: x:Int -> {b:Int | (b == 91)} @-} 8 | *) 9 | 10 | let rec mc91 x = 11 | if x > 100 12 | then x - 10 13 | else mc91 (mc91 (x + 11)) 14 | 15 | let main_p (n:int) = 16 | if n <= 101 17 | then assert (mc91 n = 91) 18 | else () 19 | 20 | let main (w:unit) = 21 | let _ = main_p 12 in 22 | (* let _ = 23 | for i = 1 to 1000000 do 24 | main (Random.int 1000) 25 | done *) 26 | () 27 | 28 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/mc91_95.ml: -------------------------------------------------------------------------------- 1 | 2 | (* 3 | Res: OCaml -> 91 4 | imprecision: Oct: 91 <= v <= 101 5 | Liquid Haskell: false by property {-@ m :: x:Int -> {b:Int | (b == 91)} @-} 6 | *) 7 | 8 | let rec m x = 9 | if x > 100 10 | then x - 10 11 | else m (m (x + 11)) 12 | 13 | let main_p (n:int) = 14 | if n <= 95 15 | then assert (m n = 91) 16 | else () 17 | 18 | let main (w:unit) = 19 | let _ = main_p 83 in 20 | (* let _ = 21 | for i = 1 to 1000000 do 22 | main (Random.int 1000) 23 | done *) 24 | () 25 | 26 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/mc91_98.ml: -------------------------------------------------------------------------------- 1 | 2 | (* 3 | Res: OCaml -> 91 4 | imprecision: Oct: 91 <= v <= 101 5 | Liquid Haskell: false by property {-@ m :: x:Int -> {b:Int | (b == 91)} @-} 6 | *) 7 | 8 | let rec m x = 9 | if x > 100 10 | then x - 10 11 | else m (m (x + 11)) 12 | 13 | let main_p (n:int) = 14 | if n <= 98 15 | then assert (m n = 91) 16 | else () 17 | 18 | let main (w:unit) = 19 | let _ = main_p 76 in 20 | (* let _ = 21 | for i = 1 to 1000000 do 22 | main (Random.int 1000) 23 | done *) 24 | () 25 | 26 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/mc91_99.ml: -------------------------------------------------------------------------------- 1 | 2 | (* 3 | Res: OCaml -> 91 4 | imprecision: Oct: 91 <= v <= 101 5 | Liquid Haskell: false by property {-@ m :: x:Int -> {b:Int | (b == 91)} @-} 6 | *) 7 | 8 | let rec m x = 9 | if x > 100 10 | then x - 10 11 | else m (m (x + 11)) 12 | 13 | let main_p (n:int) = 14 | if n <= 99 15 | then assert (m n = 91) 16 | else () 17 | 18 | let main (w:unit) = 19 | let _ = main_p 1 in 20 | (* let _ = 21 | for i = 1 to 1000000 do 22 | main (Random.int 1000) 23 | done *) 24 | () 25 | 26 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/mult.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as mult 3 | USED: PEPM2013 as mult 4 | *) 5 | 6 | let rec mult n m = 7 | if n <= 0 || m <= 0 then 8 | 0 9 | else 10 | n + mult n (m - 1) 11 | 12 | let main_p (mn:int) = 13 | assert (mn <= mult mn mn) 14 | 15 | let main (w:unit) = 16 | let _ = main_p 25 in 17 | (* let _ = 18 | for i = 1 to 1000000 do 19 | main (Random.int 1000) 20 | done *) 21 | () 22 | 23 | let _ = main () 24 | -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/sum.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as sum 3 | USED: PEPM2013 as sum 4 | *) 5 | 6 | let rec sum n = 7 | if n <= 0 8 | then 0 9 | else n + sum (n - 1) 10 | 11 | let main_p (mn:int) = 12 | assert (mn <= sum mn) 13 | 14 | let main (w:unit) = 15 | let _ = main_p 204 in 16 | (* let _ = 17 | for i = 1 to 1000000 do 18 | main (Random.int 1000) 19 | done *) 20 | () 21 | 22 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/sum2.ml: -------------------------------------------------------------------------------- 1 | 2 | (* 3 | Res: OCaml -> 10453878 4 | imprecision: Oct: 4752 <= v 5 | Liquid Haskell: TODO: need to TEST! 6 | *) 7 | 8 | let rec sum n = 9 | if n <= 0 then 10 | 0 11 | else 12 | n + sum (n - 1) 13 | 14 | let main_p (mn:int) = 15 | assert (2 * mn - 1 <= sum mn) 16 | 17 | let main (w:unit) = 18 | let _ = main_p 47 in 19 | (* let _ = 20 | for i = 1 to 1000000 do 21 | main (Random.int 1000) 22 | done *) 23 | () 24 | 25 | let _ = main () 26 | 27 | (* Reason: wid overapproximate *) -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/sum3.ml: -------------------------------------------------------------------------------- 1 | (* 2 | Res: OCaml -> 42813631 3 | imprecision: Oct: 9253 <= v 4 | Liquid Haskell: TODO: need to TEST! 5 | *) 6 | 7 | let rec sum n = 8 | if n <= 0 then 9 | 0 10 | else 11 | n + sum (n - 1) 12 | 13 | let main_p (mn:int) = 14 | assert (3 * mn - 3 <= sum mn) 15 | 16 | let main (w:unit) = 17 | let _ = main_p 92 in 18 | (* let _ = 19 | for i = 1 to 1000000 do 20 | main (Random.int 1000) 21 | done *) 22 | () 23 | 24 | let _ = main () 25 | 26 | (* Reason: wid overapproximate *) -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/sum4.ml: -------------------------------------------------------------------------------- 1 | (* 2 | Res: OCaml -> 284635 3 | imprecision: Oct: 754 <= v 4 | Liquid Haskell: TODO: need to TEST! 5 | *) 6 | 7 | let rec sum n = 8 | if n <= 0 then 9 | 0 10 | else 11 | n + sum (n - 1) 12 | 13 | let main_p (mn:int) = 14 | assert (4 * mn - 6 <= sum mn) 15 | 16 | let main (w:unit) = 17 | let _ = main_p 754 in 18 | (* let _ = 19 | for i = 1 to 1000000 do 20 | main (Random.int 1000) 21 | done *) 22 | () 23 | 24 | let _ = main () 25 | 26 | (* Reason: wid overapproximate *) -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/first/sum_intro.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PEPM2013 as sum_intro 3 | *) 4 | 5 | let add x y = x + y 6 | 7 | let rec sum n = 8 | if n <= 0 then 9 | 0 10 | else 11 | add n (sum (n - 1)) 12 | 13 | let main_p (mn:int) = 14 | assert (mn <= sum mn) 15 | 16 | let main (w:unit) = 17 | let _ = main_p 123 in 18 | (* let _ = 19 | for i = 1 to 1000000 do 20 | main (Random.int 1000) 21 | done *) 22 | () 23 | 24 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/high/apply.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as apply 3 | *) 4 | 5 | 6 | let apply (f: int -> bool) x = f x 7 | let g (y:int) (z:int) = (y = z) 8 | let rec k i n = if i >= n then true else (apply (g n) n && k (i+1) n) 9 | 10 | let main_p (mn:int) = 11 | assert(k 0 mn = true) 12 | 13 | let main (w:unit) = 14 | let _ = main_p 20 in 15 | (* let _ = 16 | for i = 1 to 1000000 do 17 | main (Random.int 1000) 18 | done *) 19 | () 20 | 21 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/high/exc-fact.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as e-fact 3 | USED: PEPM2013 as e-fact 4 | *) 5 | 6 | 7 | let rec fact fn (exnx: int -> int) = 8 | if fn <= 0 then 9 | exnx 0 10 | else 11 | let exn1 k = if k = 0 then 1 else exnx k in 12 | fn * fact (fn - 1) exn1 13 | 14 | let ex en = 0 - 1 15 | 16 | let main_p (n:int) = 17 | if n > 0 then assert(fact n ex >= (0 - 1)) 18 | else () 19 | 20 | let main (w:unit) = 21 | let _ = main_p 342 in 22 | (* let _ = 23 | for i = 1 to 1000000 do 24 | main (Random.int 1000) 25 | done *) 26 | () 27 | 28 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/high/exc-simple.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as e-simpl 3 | USED: PEPM2013 as e-simpl 4 | FROM: Leroy & Pessaux, "Type-Based Analysis of Uncaught Exceptionis, " TOPLAS, 2000 5 | 6 | let ff n = if n >= 0 then () else raise (Failer 0) 7 | let main n = try ff n with Failer 0 -> () 8 | *) 9 | 10 | let f fn (fk: int -> unit) = if fn >= 0 then assert(true) else fk 0 11 | let g gn = assert (gn = 0) 12 | 13 | let main_p (n:int) = 14 | f n g 15 | 16 | let main (w:unit) = 17 | let _ = main_p (-3) in 18 | (* let _ = 19 | for i = 1 to 1000000 do 20 | main (Random.int 1000) 21 | done *) 22 | () 23 | 24 | let _ = main () 25 | -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/high/exception.ml: -------------------------------------------------------------------------------- 1 | (* 2 | Leroy & Pessaux, "Type-Based Analysis of Uncaught Exceptionis, " TOPLAS, 2000 3 | 4 | let ff n = if n >= 0 then () else raise 0 in 5 | try ff ?n? with Failer 0 -> () 6 | *) 7 | 8 | 9 | let f fn (fk:int -> bool) = if fn >= 0 then true else fk 0 10 | let g gn = gn = 0 11 | 12 | let main_p (n:int) = 13 | assert (f n g) 14 | 15 | let main (w:unit) = 16 | let _ = main_p (-5) in 17 | (* let _ = 18 | for i = 1 to 1000000 do 19 | main (Random.int 1000) 20 | done *) 21 | () 22 | 23 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/high/hrec.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as hrec 3 | *) 4 | 5 | 6 | let rec f (fg: int -> int) fx = if fx >= 0 then fg fx else f (f fg) (fg fx) 7 | let succ sx = sx + 1 8 | 9 | let main_p (n:int) = 10 | assert (f succ n >= 0) 11 | 12 | let main (w:unit) = 13 | let _ = main_p (-44) in 14 | (* let _ = 15 | for i = 1 to 1000000 do 16 | main (Random.int 1000) 17 | done *) 18 | () 19 | 20 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/high/inc.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec ar (ari: int) = 0 3 | 4 | let update (ua: int -> int) ui ux uj = if uj = ui then ux else ua uj 5 | 6 | let rec g ge (ga: int -> int) gj = 7 | if gj < ge then 8 | (assert(0 <= gj && gj < ge); 9 | g ge (update ga gj (ga (gj) + 1)) (gj + 1)) 10 | else () 11 | 12 | let main_p (n:int) = 13 | g n ar 0 14 | 15 | let main (w:unit) = 16 | let _ = main_p 30 in 17 | (* let _ = 18 | for i = 1 to 1000000 do 19 | main (Random.int 1000) 20 | done *) 21 | () 22 | 23 | let _ = main () 24 | (* unit *) -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/high/intro1.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as intro1 3 | *) 4 | 5 | let f x (g:int -> bool) = g (x + 1) 6 | 7 | let h (y:int) = y > 0 8 | 9 | let main_p (n:int) = 10 | if n > 0 then assert (f n h) 11 | else () 12 | 13 | let main (w:unit) = 14 | let _ = main_p 120 in 15 | (* let _ = 16 | for i = 1 to 1000000 do 17 | main (Random.int 1000) 18 | done *) 19 | () 20 | 21 | let _ = main () 22 | -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/high/intro2.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as intro2 3 | *) 4 | 5 | 6 | let f x (g:int -> bool) = g (x + 1) 7 | 8 | let h (y:int) = y > 0 9 | 10 | let main_p (n:int) = 11 | if n >= 0 then assert(f n h) 12 | else () 13 | 14 | let main (w:unit) = 15 | let _ = main_p 0 in 16 | (* let _ = 17 | for i = 1 to 1000000 do 18 | main (Random.int 1000) 19 | done *) 20 | () 21 | 22 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/high/intro3.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as intro3 3 | *) 4 | 5 | 6 | let f (x:int) (g:int -> bool) = g (x + 1) 7 | 8 | let h (z:int) (y:int) = y > z 9 | 10 | let main_p (n:int) = 11 | if n >= 0 then assert(f n (h n)) 12 | else () 13 | 14 | let main (w:unit) = 15 | let _ = main_p 15 in 16 | (* let _ = 17 | for i = 1 to 1000000 do 18 | main (Random.int 1000) 19 | done *) 20 | () 21 | 22 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/high/max.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as max 3 | USED: PEPM2013 as max 4 | *) 5 | 6 | 7 | let max (max2: int -> int -> int) (mx:int) (my:int) (mz:int) = max2 (max2 mx my) mz 8 | let f (fx:int) (fy:int) = if fx >= fy then fx else fy 9 | 10 | let main_p (x:int) (y:int) (z:int) = 11 | let m = max f x y z in 12 | assert (f x m = m) 13 | 14 | let main (w:unit) = 15 | let _ = main_p 3 4 5 in 16 | (* let _ = 17 | for i = 1 to 1000000 do 18 | main (Random.int 1000) (Random.int 1000) (Random.int 1000) 19 | done *) 20 | () 21 | 22 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/high/mc91_cps.ml: -------------------------------------------------------------------------------- 1 | 2 | (* 3 | Res: OCaml -> 91 4 | imprecision: Oct: 91 <= v 5 | Liquid Haskell: TODO: need to TEST! 6 | *) 7 | 8 | 9 | let rec m mx (mk:int -> bool): bool = 10 | if mx > 100 11 | then true && mk (mx - 10) 12 | else 13 | let f (fr:int) = m fr mk in 14 | m (mx + 11) f 15 | 16 | let main_p (n:int) = 17 | if n <= 101 then 18 | (let k kr = (kr = 91) in 19 | assert (m n k = true)) 20 | else () 21 | 22 | let main (w:unit) = 23 | let _ = main_p 22 in 24 | (* let _ = 25 | for i = 1 to 1000000 do 26 | main (Random.int 1000) 27 | done *) 28 | () 29 | 30 | let _ = main () 31 | -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/high/neg2.ml: -------------------------------------------------------------------------------- 1 | 2 | let g (gx: int) = 2 * gx 3 | 4 | let twice (tx: int) (tf: int -> int) = tf (tf tx) 5 | 6 | let neg (nx: int) = (0 - nx) 7 | 8 | let main_p (n:int) = 9 | let z = twice (g n) neg in 10 | if (n > 0) then assert (z >= 0) 11 | else assert (z <= 0) 12 | 13 | let main (w:unit) = 14 | let _ = main_p 25 in 15 | let _ = main_p (-4) in 16 | (* let _ = 17 | for i = 1 to 1000000 do 18 | main (Random.int 1000) 19 | done *) 20 | () 21 | 22 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/high/recursive.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec f (g: int -> int) x = if x >= 0 then g x else f (f g) (g x) 3 | let succ sx = sx + 1 4 | 5 | let main_p (n:int) = 6 | assert (f succ n > n) 7 | 8 | let main (w:unit) = 9 | let _ = main_p 1293 in 10 | (* let _ = 11 | for i = 1 to 1000000 do 12 | main (Random.int 1000) 13 | done *) 14 | () 15 | 16 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/high/repeat.ml: -------------------------------------------------------------------------------- 1 | (* 2 | USED: PLDI2011 as repeat 3 | *) 4 | 5 | 6 | let succ sx = sx + 1 7 | 8 | let rec repeat (rf: int -> int) rn rs = 9 | if rn = 0 then 10 | rs 11 | else 12 | rf (repeat rf (rn - 1) rs) 13 | 14 | let main_p (n:int) = 15 | assert (repeat succ n 0 = n) 16 | 17 | let main (w:unit) = 18 | let _ = main_p 103 in 19 | (* let _ = 20 | for i = 1 to 1000000 do 21 | main (Random.int 1000) 22 | done *) 23 | () 24 | 25 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/high/repeat4.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let succ sx = sx + 1 4 | 5 | let rec repeat (rf: int -> int) rn = 6 | if rn = 0 7 | then 0 8 | else rf (repeat rf (rn - 1)) 9 | 10 | let main_p (n:int) = 11 | assert (repeat succ n = n) 12 | 13 | let main (w:unit) = 14 | let _ = main_p 15 in 15 | (* let _ = 16 | for i = 1 to 1000000 do 17 | main (Random.int 1000) 18 | done *) 19 | () 20 | 21 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/high/sigma_sum.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec sum n = 4 | if n <= 0 5 | then 0 6 | else n + sum (n - 1) 7 | 8 | let rec sigma (f: int -> int) n = 9 | if n <= 0 10 | then 0 11 | else f n + sigma f (n - 1) 12 | 13 | let main_p (mn:int) = 14 | assert (sigma sum mn >= mn) 15 | 16 | let main (w:unit) = 17 | let _ = main_p 54 in 18 | (* let _ = 19 | for i = 1 to 1000000 do 20 | main (Random.int 1000) 21 | done *) 22 | () 23 | 24 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/high/sum_cps.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let rec cps_sum (cn: int) (ck: int -> unit) = 4 | if cn <= 0 then 5 | ck 0 6 | else 7 | let f (fx: int) = ck (fx + cn) in 8 | cps_sum (cn - 1) f 9 | 10 | let main_p (n:int) = 11 | let u (ux: int) = assert (ux >= n) in 12 | cps_sum n u 13 | 14 | let main (w:unit) = 15 | let _ = main_p 100 in 16 | (* let _ = 17 | for i = 1 to 1000000 do 18 | main (Random.int 1000) 19 | done *) 20 | () 21 | 22 | let _ = main () -------------------------------------------------------------------------------- /tests/benchmarks_call/r_type/high/twice.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let twice (tf: int -> int) tx = tf (tf tx) 4 | let f fx = 2 * fx 5 | 6 | let main_p (n:int) = 7 | if n > 0 8 | then assert (twice f n > n) 9 | else () 10 | 11 | let main (w:unit) = 12 | let _ = main_p 123 in 13 | (* let _ = 14 | for i = 1 to 1000000 do 15 | main (Random.int 1000) 16 | done *) 17 | () 18 | 19 | let _ = main () -------------------------------------------------------------------------------- /tests/effects/all-ev-pos.ml: -------------------------------------------------------------------------------- 1 | (* *** Based on COAR: ********************************************************** 2 | let rec sum x = if x <= 0 then 0 else x + sum (x - 1) 3 | [@@@assert "typeof(sum) <: (x:{ x:int | true }) -> { ret : int | ret > x }"] 4 | [@@@assert "typeof(sum) <: (x:{ x:int | x > 1 }) -> { ret : int | ret > x }"] 5 | [@@@assert "typeof(sum) <: (x:{ x:int | true }) -> { ret : int | ret >= x }"] 6 | ****************************************************************************** *) 7 | 8 | (* Properties: prop-all-ev-pos.eff *) 9 | 10 | let rec sum x = 11 | ev x; 12 | if x <= 0 then 0 else x + (sum (x - 1)) 13 | 14 | let main (v:int(*-:{v:Int | true}*)) = 15 | if v < 0 then sum (0 - v) else sum v 16 | -------------------------------------------------------------------------------- /tests/effects/all-ev-pos.yml.prp: -------------------------------------------------------------------------------- 1 | (* All Events Are Positive *) 2 | 3 | QSet = [0;1]; 4 | delta = fun evx (q, acc) -> 5 | if (evx < 0) then (1, acc) else (0, acc); 6 | IniCfg = (0, 0); 7 | assert = fun (q, acc) -> q = 0; 8 | -------------------------------------------------------------------------------- /tests/effects/auction.ml: -------------------------------------------------------------------------------- 1 | let refund k kamt h _ = 2 | if k <= 1 then () 3 | else begin ev 3; h () end 4 | 5 | let close j g = 6 | if j = 1 then () 7 | else begin ev 2; g () end 8 | 9 | let rec bid i amtW f = 10 | let amt = amtW + 1 in 11 | if nondet then 12 | begin ev 1; bid (i + 1) amt (refund i amtW f) end 13 | else 14 | close i f 15 | 16 | let idf _ = () 17 | 18 | let main (u: unit(*-:{v: Unit | unit}*)) = 19 | bid 1 1 idf 20 | -------------------------------------------------------------------------------- /tests/effects/concurrent_sum.ml: -------------------------------------------------------------------------------- 1 | 2 | let choose x = 3 | if nondet then begin 4 | ev 1; 5 | 0 6 | end else if nondet then begin 7 | ev 2; 8 | 0 9 | end else begin 10 | ev 3; 11 | 0 12 | end 13 | 14 | let rec sum n = 15 | if n = 0 then 0 16 | else begin 17 | choose (); 18 | sum (n-1) end 19 | 20 | let main (n:int(*-:{v:Int | v>0}*)) = 21 | sum n 22 | -------------------------------------------------------------------------------- /tests/effects/concurrent_sum.yml.prp: -------------------------------------------------------------------------------- 1 | QSet = [0;1]; 2 | 3 | delta = fun evx (q, acc) -> 4 | if (q = 0 && evx <= 3) then (0, evx + acc) 5 | else (1, acc); 6 | 7 | IniCfg = (0, 0); 8 | 9 | assertFinal = fun (q, acc) -> q = 0 && acc <= 3*prefn; 10 | -------------------------------------------------------------------------------- /tests/effects/depend.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | let main (v:int(*-:{v:Int | true}*)) = 5 | if v = 0 then begin ev 1; 0 end else 0 6 | -------------------------------------------------------------------------------- /tests/effects/depend.yml.prp: -------------------------------------------------------------------------------- 1 | (* Dependent *) 2 | 3 | QSet = [0]; 4 | 5 | delta = fun evx (q, acc) -> 6 | if evx > prefv then (q,acc + evx) else (q, acc); 7 | 8 | IniCfg = (0, 0); 9 | 10 | assert = fun (q, acc) -> (acc >= 0); 11 | 12 | -------------------------------------------------------------------------------- /tests/effects/disj-gte.ml: -------------------------------------------------------------------------------- 1 | let rec f x pos neg = 2 | if x > 0 then 3 | ev pos 4 | else if x < 0 then 5 | ev neg 6 | else 7 | (); 8 | 9 | if x > 0 then 10 | f (x-1) pos neg 11 | else if x < 0 then 12 | f (x+1) pos neg 13 | else 14 | 0 15 | 16 | let main (v:int(*-:{v:Int | true}*)) (p:int(*-:{v:Int | true}*)) (n:int(*-:{v:Int | true}*)) = 17 | if p > 0 && n < 0 then 18 | f v p n 19 | else 0 20 | -------------------------------------------------------------------------------- /tests/effects/disj-gte.yml.prp: -------------------------------------------------------------------------------- 1 | (* Disjunctive *) 2 | 3 | QSet = [0;1;2;3]; 4 | 5 | delta = fun evx (q, acc) -> 6 | if ((q = 0) || (q = 1)) && (evx > 0) then (1,acc) 7 | else if (q = 1) && (evx < 0) then (3, acc) 8 | else if ((q = 0) || (q = 2)) && (evx < 0) then (2,acc) 9 | else if (q = 2) && (evx > 0) then (3, acc) 10 | else (3, acc); 11 | 12 | IniCfg = (0, 0); 13 | 14 | (* if event is pos, x must be even ; *) 15 | assert = fun (q, acc) -> (q < 3); 16 | 17 | -------------------------------------------------------------------------------- /tests/effects/disj-nondet.ml: -------------------------------------------------------------------------------- 1 | let rec f x b pos neg = 2 | if b = 0 then 3 | ev pos 4 | else 5 | ev neg; 6 | if (x <= 0) then 0 else f (x-1) b pos neg 7 | 8 | 9 | let main (v:int(*-:{v:Int | true}*)) (p:int(*-:{v:Int | true}*)) (n:int(*-:{v:Int | true}*)) = 10 | if p > 0 && n < 0 then 11 | let bb = if nondet then 1 else 0 in 12 | f v bb p n 13 | else 0 14 | 15 | -------------------------------------------------------------------------------- /tests/effects/disj-nondet.yml.prp: -------------------------------------------------------------------------------- 1 | (* Disjunctive *) 2 | 3 | QSet = [0;1;2;3]; 4 | 5 | delta = fun evx (q, acc) -> 6 | if ((q = 0) || (q = 1)) && (evx > 0) then (1,acc) 7 | else if (q = 1) && (evx < 0) then (3, acc) 8 | else if ((q = 0) || (q = 2)) && (evx < 0) then (2,acc) 9 | else if (q = 2) && (evx > 0) then (3, acc) 10 | else (3, acc); 11 | 12 | IniCfg = (0, 0); 13 | 14 | (* if event is pos, x must be even ; *) 15 | assert = fun (q, acc) -> (q < 3); 16 | 17 | -------------------------------------------------------------------------------- /tests/effects/disj.ml: -------------------------------------------------------------------------------- 1 | let rec f x pos neg = 2 | if x mod 2 = 0 then 3 | ev pos 4 | else 5 | ev neg; 6 | if (x <= 0) then 0 else f (x-2) pos neg 7 | 8 | 9 | let main (v:int(*-:{v:Int | true}*)) (p:int(*-:{v:Int | true}*)) (n:int(*-:{v:Int | true}*)) = 10 | if p > 0 && n < 0 then 11 | f v p n 12 | else 0 13 | 14 | -------------------------------------------------------------------------------- /tests/effects/disj.yml.prp: -------------------------------------------------------------------------------- 1 | (* Disjunctive *) 2 | 3 | QSet = [0;1;2;3]; 4 | 5 | delta = fun evx (q, acc) -> 6 | if ((q = 0) || (q = 1)) && (evx > 0) then (1,acc) 7 | else if (q = 1) && (evx < 0) then (3, acc) 8 | else if ((q = 0) || (q = 2)) && (evx < 0) then (2,acc) 9 | else if (q = 2) && (evx > 0) then (3, acc) 10 | else (3, acc); 11 | 12 | IniCfg = (0, 0); 13 | 14 | (* if event is pos, x must be even ; *) 15 | assert = fun (q, acc) -> (q < 3); 16 | 17 | -------------------------------------------------------------------------------- /tests/effects/higher-order.ml: -------------------------------------------------------------------------------- 1 | let rec apply f x = (ev 1; if x <= 0 then 0 else ((apply f (f x)))) 2 | 3 | let pred x = x - 1 4 | let succ x = x + 1 5 | 6 | let main (n:int(*-:{v:Int | true}*)) = 7 | let _ = apply pred n in 8 | ev 2; 0 -------------------------------------------------------------------------------- /tests/effects/higher-order.yml.prp: -------------------------------------------------------------------------------- 1 | (* 2 | Traces are just [1;2] 3 | q0 --1--> q1 --2--> q2 4 | q3 is the error state 5 | *) 6 | QSet = [0; 1; 2; 3]; 7 | 8 | delta = fun evx (q, acc) -> 9 | if ((evx = 1) && (q = 0 || q = 1)) then (1,acc) 10 | else if ((evx = 2) && (q = 1)) then (2,acc) 11 | else (3,0); 12 | 13 | IniCfg = (0, 0); 14 | 15 | assertFinal = fun (q, acc) -> q = 2; 16 | -------------------------------------------------------------------------------- /tests/effects/last-ev-even.ml: -------------------------------------------------------------------------------- 1 | let rec foo vv f = 2 | if vv = 0 then begin ev f; 0 end 3 | else begin ev vv; foo (vv-1) f end 4 | 5 | let main (v:int(*-:{v:Int | true}*)) (final:int(*-:{v:Int | true}*)) = 6 | if (final mod 2 = 0) then 7 | foo v final 8 | else 9 | foo v (if v >= 0 then final+1 else final) 10 | 11 | -------------------------------------------------------------------------------- /tests/effects/last-ev-even.yml.prp: -------------------------------------------------------------------------------- 1 | (* Last event seen is even *) 2 | 3 | QSet = [0]; 4 | 5 | delta = fun evx (q, acc) -> (q,evx); 6 | 7 | IniCfg = (0, 0); 8 | 9 | assertFinal = fun (q, acc) -> acc mod 2 = 0; 10 | -------------------------------------------------------------------------------- /tests/effects/lics18-amortized.yml.prp: -------------------------------------------------------------------------------- 1 | QSet = [0;1]; 2 | 3 | (* [default state, error state] *) 4 | 5 | delta = fun evx (q, (enq, deq, tick)) -> 6 | if (q=0 && evx = 0) then (q, (enq+1, deq, tick)) 7 | else if (q=0 && evx = 1) then (q, (enq, deq+1, tick)) 8 | else if (q=0 && evx = 2) then (q, (enq, deq, tick+1)) 9 | else (1, (enq, deq, tick)); 10 | 11 | IniCfg = (0, (0,0,0)); 12 | 13 | assertFinal = fun (q, (enq, deq, tick)) -> q=0 && tick = enq+prefl2 && tick = deq-prefl1; 14 | (* assertFinal = fun (q, (enq, deq, tick)) -> q=0 && tick = enq+prefl2; *) 15 | -------------------------------------------------------------------------------- /tests/effects/lics18-hoshrink.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec shrink t f d = 3 | if f () <= 0 then 0 4 | else begin 5 | ev 1; (* ev[Shrink] *) 6 | let t' = f() - d in 7 | shrink t' (fun x -> t') d end 8 | 9 | let main (gl_t:int(*-:{v:Int | true}*)) (gl_d:int(*-:{v:Int | true}*)) = 10 | ev (gl_t/gl_d); 11 | shrink gl_t (fun x -> gl_t) gl_d 12 | -------------------------------------------------------------------------------- /tests/effects/lics18-hoshrink.yml.prp: -------------------------------------------------------------------------------- 1 | (* Dependent *) 2 | 3 | QSet = [0]; 4 | 5 | delta = fun evx (q, acc) -> (q, (acc+evx)); 6 | 7 | IniCfg = (0, 0); 8 | 9 | assertFinal = fun (q, acc) -> (acc = prefgl_t/prefgl_d); 10 | 11 | -------------------------------------------------------------------------------- /tests/effects/lics18-web.ml: -------------------------------------------------------------------------------- 1 | (* Adapted from: 2 | A Fixpoint Logic and Dependent Effects for 3 | Temporal Property Verification 4 | Nanjo et al, LICS 2018 *) 5 | 6 | let rec listener i npool pend = 7 | if nondet && pend < npool then begin 8 | ev 1; (* Accept *) 9 | listener i npool (pend + 1) 10 | end else if pend > 0 then begin 11 | ev 2; (* Handle *) 12 | listener i npool (pend - 1) 13 | end else begin 14 | ev 3; (* Wait *) 15 | listener i npool pend 16 | end 17 | 18 | let main (npool:int(*-:{v:Int | true}*)) (i0:int(*-:{v:Int | true}*)) = 19 | listener i0 npool 0 20 | -------------------------------------------------------------------------------- /tests/effects/market.ml: -------------------------------------------------------------------------------- 1 | let sell n1 = ev 2; ev n1; () 2 | 3 | let buy n2 = ev 1; ev n2; () 4 | 5 | let activity f n3 = f n3; ev 0; () 6 | 7 | let rec repeat n4 = 8 | if (n4<=0) then 0 9 | else 10 | begin 11 | activity buy 1; 12 | activity sell 1; 13 | 1 + repeat (n4-1) 14 | end 15 | 16 | let main (budget:int(*-:{v:Int | v >= 0}*)) (stock:int(*-:{v:Int | v >= 0}*)) (n:int(*-:{v:Int | v > 0}*)) = 17 | if (stock >= budget && budget >= n) then 18 | begin 19 | activity sell (-stock); 20 | activity buy (-budget); 21 | repeat n 22 | end 23 | else 24 | 0 25 | -------------------------------------------------------------------------------- /tests/effects/market.yml.prp: -------------------------------------------------------------------------------- 1 | QSet = [0;1;2;3]; 2 | 3 | (* [stable state, consumer state, producer state, error state] *) 4 | 5 | delta = fun evx (q, (budget, stock)) -> 6 | if (q=0 && evx > 0 && evx < 3) then (evx, (budget, stock)) 7 | else if (q=1 && evx<>0) then (q, ((budget-evx), stock)) 8 | else if (q=2 && evx<>0) then (q, (budget, (stock-evx))) 9 | else if ((q=1||q=2) && evx=0) then (0, (budget, stock)) 10 | else (3, (budget, stock)); 11 | 12 | IniCfg = (0, (0,0)); 13 | 14 | assert = fun (q, (budget, stock)) -> q < 3 && budget >=0 && stock >=0 && stock >= budget; -------------------------------------------------------------------------------- /tests/effects/max-min.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec compute vv bound1 inc = 3 | ev vv; 4 | if vv = bound1 then 0 else compute (inc vv) bound1 inc 5 | 6 | let main (v:int(*-:{v:Int | true}*)) (w:int(*-:{v:Int | true}*)) (m:int(*-:{v:Int | true}*)) = 7 | let f = (fun t -> if v >= 0 then t-1 else t+1) in 8 | if (v>=0 && v <= 100000) then 9 | let bound = -v in 10 | compute v bound f 11 | else if (v<0 && v >= (-100000)) then 12 | let bound = -v in 13 | compute v bound f 14 | else 15 | 0 16 | -------------------------------------------------------------------------------- /tests/effects/max-min.yml.prp: -------------------------------------------------------------------------------- 1 | (* Max == -1 * Min *) 2 | 3 | QSet = [0;1]; 4 | 5 | delta = fun evx (q, (max,min)) -> 6 | if evx < min && evx > max then (1, (evx, evx)) 7 | else if evx < min then (1, (max,evx)) 8 | else if evx > max then (1, (evx,min)) 9 | else (1, (max,min)); 10 | 11 | IniCfg = (0, (-100000,100000)); 12 | 13 | assertFinal = fun (q, (max,min)) -> max + min = 0; 14 | -------------------------------------------------------------------------------- /tests/effects/mochi-sum.ml: -------------------------------------------------------------------------------- 1 | (* *** Based on COAR: ********************************************************** 2 | let rec sum x = if x <= 0 then 0 else x + sum (x - 1) 3 | [@@@assert "typeof(sum) <: (x:{ x:int | true }) -> { ret : int | ret > x }"] 4 | [@@@assert "typeof(sum) <: (x:{ x:int | x > 1 }) -> { ret : int | ret > x }"] 5 | [@@@assert "typeof(sum) <: (x:{ x:int | true }) -> { ret : int | ret >= x }"] 6 | ****************************************************************************** *) 7 | 8 | (* Properties: prop-all-ev-pos.eff *) 9 | 10 | let rec sum x = 11 | ev x; 12 | if x <= 0 then 0 else x + sum (x - 1) 13 | 14 | let main (v:int(*-:{v:Int | true}*)) = 15 | if v < 0 then sum (0 - v) else sum v 16 | -------------------------------------------------------------------------------- /tests/effects/monotonic.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec mono t x = 3 | ev t; 4 | if x <= 0 then 0 5 | else 6 | mono (t+x) (x-1) (* increase t by positive amount *) 7 | 8 | let main (u: int(*-:{v:Int | true}*)) = 9 | if u>0 then mono 1 u else 0 10 | 11 | -------------------------------------------------------------------------------- /tests/effects/monotonic.yml.prp: -------------------------------------------------------------------------------- 1 | (* 2 | Event values increase [1;2;5;...] 3 | Save previous value 4 | q1 is the error state 5 | *) 6 | QSet = [0;1]; 7 | 8 | delta = fun evx (q, acc) -> 9 | if (q = 0 && evx >= acc) then (0, evx) 10 | else (1, 0); 11 | 12 | IniCfg = (0, 0); 13 | 14 | assertFinal = fun (q, acc) -> q = 0; 15 | -------------------------------------------------------------------------------- /tests/effects/nondet_max.ml: -------------------------------------------------------------------------------- 1 | (* A program that chooses n numbers between 0 and m. 2 | Each number is chosen between 0 and m non-deterministically. 3 | The property file checks if every chosen number is ≤ m. *) 4 | 5 | let rec make_list n f = 6 | if n = 0 then 0 7 | else begin 8 | ev (f n); 9 | make_list (n-1) f 10 | end 11 | 12 | let main (n:int(*-:{v:Int | v>0}*)) = 13 | let rec get_random_int n1 = 14 | if n1 = 0 then 0 15 | else 16 | if nondet then get_random_int (n1-1) 17 | else n1 18 | in 19 | make_list n (get_random_int) 20 | -------------------------------------------------------------------------------- /tests/effects/nondet_max.yml.prp: -------------------------------------------------------------------------------- 1 | QSet = [0;1]; 2 | 3 | delta = fun evx (q, acc) -> 4 | if (q = 0 && evx >= acc) then (0, evx) 5 | else if (q = 0) then (0, acc) 6 | else (q, acc); 7 | 8 | IniCfg = (0, 0); 9 | 10 | assert = fun (q, acc) -> q = 0 && acc <= prefn; 11 | -------------------------------------------------------------------------------- /tests/effects/num_evens.ml: -------------------------------------------------------------------------------- 1 | (* A program emits an event every alternate iteration of f. 2 | It makes sure that the overall number of effects is smaller 3 | than half of m. *) 4 | 5 | let main (m:int(*-:{v:Int | v>0}*)) = 6 | let flip x = 7 | if x = 1 then 0 8 | else 1 9 | in 10 | let rec f m1 flag = 11 | if m1 = 0 then () 12 | else 13 | (if flag=1 then begin ev 1; f (m1-1) end 14 | else f (m1-1)) 15 | (flip flag) 16 | in 17 | f m 0 18 | -------------------------------------------------------------------------------- /tests/effects/num_evens.yml.prp: -------------------------------------------------------------------------------- 1 | QSet = [0;1]; 2 | 3 | delta = fun evx (q, acc) -> 4 | if (q = 0 && evx=1) then (0, acc+1) 5 | else (1, acc); 6 | 7 | IniCfg = (0, 0); 8 | 9 | assert = fun (q, acc) -> (q = 0 && (2*acc <= prefm)); -------------------------------------------------------------------------------- /tests/effects/old/3states-aut.ml: -------------------------------------------------------------------------------- 1 | type q = Q0 | Q1 | Q2 | Q3 2 | type tup = Tup of q * int 3 | 4 | let rec ev d acc = 5 | match acc with 6 | | Tup(Q0,_) -> Tup(Q1,1) 7 | | Tup(Q1,_) -> Tup(Q2,1) 8 | | _ -> Tup(Q3,1) 9 | 10 | (* at least 3 events happen, then only "v" events *) 11 | let rec aut n _s0 = 12 | if n > 0 then begin 13 | let _s1 = ev n _s0 in 14 | aut (n-1) _s1 15 | end else _s0 16 | 17 | let main (n:int(*-:{v:Int | true}*)) = 18 | let _s00 = Tup(Q0,0) in 19 | if n > 5 then begin 20 | let _s01 = aut n _s00 in 21 | match _s01 with 22 | | Tup(Q0,_) -> assert(false) 23 | | Tup(Q1,_) -> assert(false) 24 | | Tup(Q2,_) -> assert(false) 25 | | _ -> () 26 | end -------------------------------------------------------------------------------- /tests/effects/old/3states.ml: -------------------------------------------------------------------------------- 1 | (* simple 3-state automaton, the final state accepting. *) 2 | let ev d _s = 3 | if _s = 0 then 1 4 | else if _s = 1 then 2 5 | else if _s = 2 then 3 6 | else -1 7 | 8 | let nondet (i:int) = (i * i * i * 500) mod 199 9 | 10 | (* at least 3 events happen, then only "v" events *) 11 | let rec aut n _s0 = 12 | if n > 0 then begin 13 | let _s1 = ev n _s0 in 14 | aut (n-1) _s1 15 | end else _s0 16 | 17 | let main (n:int(*-:{v:Int | true}*)) = 18 | let _s00 = 0 in 19 | if n > 5 then begin 20 | let _s01 = aut n _s00 in 21 | assert (_s01 < 0) 22 | end -------------------------------------------------------------------------------- /tests/effects/order-irrel-nondet.ml: -------------------------------------------------------------------------------- 1 | (* 2 | there are two particular events (let us treat them as integers 3 | c and -c for some c) such that at most one of them is permitted 4 | to occur during any execution 5 | *) 6 | let rec order d c b = 7 | if (d > 0) then begin 8 | (* begin if ( d mod 2 = 0 ) then ev c else ev(-c) end; *) 9 | ev (if b = 1 then c else (-c)); 10 | order (d - 2) c b 11 | end else 0 12 | 13 | let main (dd:int(*-:{v:Int | true}*)) (cc:int(*-:{v:Int | v > 0}*)) = 14 | let bb = if nondet then 1 else 0 in 15 | order dd cc bb 16 | 17 | -------------------------------------------------------------------------------- /tests/effects/order-irrel-nondet.yml.prp: -------------------------------------------------------------------------------- 1 | (* there are two particular events (let us treat them as integers 2 | c and -c for some c) such that at most one of them is permitted 3 | to occur during any execution *) 4 | 5 | QSet = [0;1]; 6 | 7 | delta = fun evx (q, acc) -> 8 | if q = 1 then (1, acc) 9 | else if acc = 0 then (q, evx) 10 | else if acc = evx then (q, acc) 11 | else (1,acc); 12 | 13 | IniCfg = (0, 0); 14 | 15 | assertFinal = fun (q, acc) -> q = 0; 16 | -------------------------------------------------------------------------------- /tests/effects/order-irrel.ml: -------------------------------------------------------------------------------- 1 | (* 2 | there are two particular events (let us treat them as integers 3 | c and -c for some c) such that at most one of them is permitted 4 | to occur during any execution 5 | *) 6 | let rec order d c = 7 | if (d > 0) then begin 8 | (* begin if ( d mod 2 = 0 ) then ev c else ev(-c) end; *) 9 | ev (if d mod 2 = 0 then c else (-c)); 10 | order (d - 2) c 11 | end else 0 12 | 13 | let main (dd:int(*-:{v:Int | true}*)) (cc:int(*-:{v:Int | v > 0}*)) = 14 | order dd cc 15 | 16 | -------------------------------------------------------------------------------- /tests/effects/order-irrel.yml.prp: -------------------------------------------------------------------------------- 1 | (* there are two particular events (let us treat them as integers 2 | c and -c for some c) such that at most one of them is permitted 3 | to occur during any execution *) 4 | 5 | QSet = [0;1]; 6 | 7 | delta = fun evx (q, acc) -> 8 | if q = 1 then (1, acc) 9 | else if acc = 0 then (q, evx) 10 | else if acc = evx then (q, acc) 11 | else (1,acc); 12 | 13 | IniCfg = (0, 0); 14 | 15 | assertFinal = fun (q, acc) -> q = 0; 16 | -------------------------------------------------------------------------------- /tests/effects/overview1.ml: -------------------------------------------------------------------------------- 1 | (* 2 | there are two particular events 3 | (let us treat them as integers c and -c for some c) 4 | and a temporal ordering: 5 | q0 --(c)--> q1 --(-c)--> q2 6 | where q0 and q1 are error states 7 | *) 8 | 9 | let rec busy n t = 10 | if n <= 0 then begin 11 | ev -t; 12 | 0 13 | end else busy (n - 1) t 14 | 15 | let main (x:int(*-:{v:Int | true}*)) (n:int(*-:{v:Int | true}*)) = 16 | ev x; 17 | busy n x 18 | 19 | 20 | (* 21 | if dd > 0 then begin ev dd; ev(-dd) end 22 | else begin ev(-dd); ev dd; end 23 | *) 24 | 25 | -------------------------------------------------------------------------------- /tests/effects/overview1.yml.prp: -------------------------------------------------------------------------------- 1 | QSet = [0;1;2]; 2 | 3 | delta = fun evx (q, acc) -> 4 | if (q = 0) then (1, evx) 5 | else if (q = 1) && (acc + evx = 0) then (2, acc) 6 | else if (q = 2) then (2, acc) 7 | else (q, acc); 8 | 9 | IniCfg = (0, 0); 10 | 11 | assertFinal = fun (q, acc) -> q = 2; 12 | -------------------------------------------------------------------------------- /tests/effects/reentr.ml: -------------------------------------------------------------------------------- 1 | let rec reent d = 2 | ev 1; (* acquire *) 3 | if (d > 0) then 4 | begin 5 | if nondet then begin reent (d-1); ev (-1) (* release *) end 6 | else () 7 | end 8 | else 9 | () 10 | 11 | let main (n: int(*-:{v:Int | v > 0}*)) = 12 | reent n; ev (-1) (* release *) 13 | 14 | -------------------------------------------------------------------------------- /tests/effects/reentr.yml.prp: -------------------------------------------------------------------------------- 1 | (* Never release more than acquire *) 2 | 3 | QSet = [0;1]; 4 | 5 | delta = fun evx (q, acc) -> 6 | if q = 0 && (acc + evx) >= 0 then (q, acc + evx) 7 | else if q = 0 && (acc + evx) < 0 then (1, acc + evx) 8 | else (q, acc); 9 | 10 | IniCfg = (0, 0); 11 | 12 | assert = fun (q, acc) -> q = 0; 13 | 14 | -------------------------------------------------------------------------------- /tests/effects/resource-analysis.ml: -------------------------------------------------------------------------------- 1 | let rec spend n = 2 | ev -1; 3 | if n <= 0 then 0 else spend (n-1) 4 | 5 | let main (gas:int(*-:{v:Int | true}*)) (n:int(*-:{v:Int | true}*)) = 6 | if (gas > n && n >= 0) then begin ev gas; spend n end else 0 7 | -------------------------------------------------------------------------------- /tests/effects/resource-analysis.yml.prp: -------------------------------------------------------------------------------- 1 | (* Resource Analysis *) 2 | 3 | QSet = [0]; 4 | 5 | delta = fun evx (q, acc) -> (q,acc + evx); 6 | 7 | IniCfg = (0, 0); 8 | 9 | assert = fun (q, acc) -> (acc >= 0); 10 | -------------------------------------------------------------------------------- /tests/effects/sum-appendix.ml: -------------------------------------------------------------------------------- 1 | 2 | let sum x = 3 | ev 1; (fun y -> x + y) 4 | 5 | let main (u: unit(*-:{v:Unit | unit}*)) = 6 | ev 2; 7 | ev (sum (ev 3; 10) (ev 4; 20)) 8 | -------------------------------------------------------------------------------- /tests/effects/sum-appendix.yml.prp: -------------------------------------------------------------------------------- 1 | QSet = [0]; 2 | 3 | delta = fun evx (q, acc) -> (q, (evx + acc)); 4 | 5 | IniCfg = (0, 0); 6 | 7 | assert = fun (q, acc) -> acc >= 0; 8 | 9 | assertFinal = fun (q, acc) -> acc = 40; 10 | -------------------------------------------------------------------------------- /tests/effects/sum-of-ev-even.ml: -------------------------------------------------------------------------------- 1 | let rec sum x = 2 | ev x; 3 | if x <= 0 then 0 else sum (x - 2) 4 | 5 | let main (v:int(*-:{v:Int | true}*)) = 6 | if v mod 2 = 0 then sum v else sum (v + 1) 7 | -------------------------------------------------------------------------------- /tests/effects/sum-of-ev-even.yml.prp: -------------------------------------------------------------------------------- 1 | (* Accumulate the Sum, and Sum is Even *) 2 | 3 | QSet = [0]; 4 | 5 | delta = fun evx (q, acc) -> (q,acc + evx); 6 | 7 | IniCfg = (0, 0); 8 | 9 | assert = fun (q, acc) -> true; 10 | 11 | assertFinal = fun (q, acc) -> (acc mod 2 = 0); 12 | 13 | -------------------------------------------------------------------------------- /tests/effects/temperature.ml: -------------------------------------------------------------------------------- 1 | let rec f x pos neg = 2 | if x mod 2 = 0 then 3 | ev pos 4 | else 5 | ev neg; 6 | if (x <= 0) then 0 else f (x-2) (pos+1) (neg-1) 7 | 8 | 9 | let main (v:int(*-:{v:Int | true}*)) (p:int(*-:{v:Int | true}*)) (n:int(*-:{v:Int | true}*)) = 10 | if p > 0 && n < 0 then 11 | f v p n 12 | else 0 13 | 14 | -------------------------------------------------------------------------------- /tests/effects/temperature.yml.prp: -------------------------------------------------------------------------------- 1 | (* Disjunctive *) 2 | 3 | QSet = [0;1;2;3]; 4 | 5 | delta = fun evx (q, acc) -> 6 | if ((q = 0) && (evx > 0)) then (1, evx) 7 | else if ((q = 0) && (evx < 0)) then (2, evx) 8 | (* q1=heating *) 9 | else if ((q = 1) && (evx > acc)) then (1, evx) 10 | (* q2=cooling *) 11 | else if ((q = 2) && (evx < acc)) then (2, evx) 12 | else (3, evx); 13 | 14 | IniCfg = (0, 0); 15 | 16 | (* if event is pos, x must be even ; *) 17 | assert = fun (q, acc) -> (q < 3); 18 | 19 | -------------------------------------------------------------------------------- /tests/effects/tr_tuple/overview1.0.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nyu-acsys/drift/8e24ffeac993d5f6fd37125e212a82f3df33fb78/tests/effects/tr_tuple/overview1.0.bin -------------------------------------------------------------------------------- /tests/effects/traffic_light.ml: -------------------------------------------------------------------------------- 1 | let next x = 2 | ev x; 3 | x - 1 4 | 5 | let rec loop s = 6 | if (s > 0) then loop (next s) 7 | else () 8 | 9 | let main (u: unit(*-:{v:Unit | unit}*)) = 10 | ev 0; 11 | loop 4 12 | 13 | -------------------------------------------------------------------------------- /tests/effects/traffic_light.yml.prp: -------------------------------------------------------------------------------- 1 | (* ============================================================================================ *) 2 | (* === III. 3-State AUTOMATON & Initial CFG === *) 3 | (* ============================================================================================ *) 4 | 5 | QSet = [0; 1; 2; 3]; 6 | 7 | delta = fun evx (q, (max, min)) -> 8 | if evx < min then (q, (max,evx)) 9 | else if evx > max then (q, (evx,min)) 10 | else (q, (max,min)); 11 | 12 | IniCfg = (0, (0, 0)); 13 | 14 | assertFinal = fun (q, (max, min)) -> max + min = 0; 15 | 16 | -------------------------------------------------------------------------------- /tests/effects/unsafe/all-ev-pos.yml.prp: -------------------------------------------------------------------------------- 1 | (* All Events Are Positive *) 2 | 3 | QSet = [0;1]; 4 | delta = fun evx (q, acc) -> 5 | if (evx < 0) then (1, acc) else (0, acc); 6 | IniCfg = (0, 0); 7 | assert = fun (q, acc) -> q = 0; 8 | -------------------------------------------------------------------------------- /tests/effects/unsafe/auction.ml: -------------------------------------------------------------------------------- 1 | let rec refund j = 2 | if j <= 0 then () 3 | else begin ev 3; refund (j - 1) end 4 | 5 | let close n = 6 | if n=1 then () 7 | else begin ev 2; refund (n-1) end 8 | 9 | let rec bid i = 10 | if nondet then 11 | begin ev 1; bid (i + 1) end 12 | else 13 | close i 14 | 15 | let main (u: unit(*-:{v: Unit | unit}*)) = 16 | bid 0 17 | -------------------------------------------------------------------------------- /tests/effects/unsafe/depend.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | let main (v:int(*-:{v:Int | true}*)) = 5 | if v = 0 then begin ev 1; 0 end else 0 6 | -------------------------------------------------------------------------------- /tests/effects/unsafe/depend.yml.prp: -------------------------------------------------------------------------------- 1 | (* Dependent *) 2 | 3 | QSet = [0]; 4 | 5 | delta = fun evx (q, acc) -> 6 | if evx > prefv then (q,acc - evx) else (q, acc); 7 | 8 | IniCfg = (0, 0); 9 | 10 | assert = fun (q, acc) -> (acc >= 0); 11 | 12 | -------------------------------------------------------------------------------- /tests/effects/unsafe/disj-gte.ml: -------------------------------------------------------------------------------- 1 | let rec f x pos neg = 2 | if x > 0 then 3 | ev pos 4 | else if x < 0 then 5 | ev neg 6 | else 7 | (); 8 | 9 | if x > 0 then 10 | f (x-1) pos neg 11 | else if x < 0 then 12 | f (x+1) neg pos 13 | else 14 | 0 15 | 16 | let main (v:int(*-:{v:Int | true}*)) (p:int(*-:{v:Int | true}*)) (n:int(*-:{v:Int | true}*)) = 17 | (* if p > 0 && n < 0 then 18 | f v p n 19 | else 0 20 | *) 21 | f v p n -------------------------------------------------------------------------------- /tests/effects/unsafe/disj-gte.yml.prp: -------------------------------------------------------------------------------- 1 | (* Disjunctive *) 2 | 3 | QSet = [0;1;2;3]; 4 | 5 | delta = fun evx (q, acc) -> 6 | if ((q = 0) || (q = 1)) && (evx > 0) then (1,acc) 7 | else if (q = 1) && (evx < 0) then (3, acc) 8 | else if ((q = 0) || (q = 2)) && (evx < 0) then (2,acc) 9 | else if (q = 2) && (evx > 0) then (3, acc) 10 | else (3, acc); 11 | 12 | IniCfg = (0, 0); 13 | 14 | (* if event is pos, x must be even ; *) 15 | assert = fun (q, acc) -> (q < 3); 16 | 17 | -------------------------------------------------------------------------------- /tests/effects/unsafe/disj.ml: -------------------------------------------------------------------------------- 1 | let rec f x pos neg = 2 | if x mod 2 = 0 then 3 | ev pos 4 | else 5 | ev neg; 6 | if (x <= 0) then 0 else f (x-2) pos neg 7 | 8 | 9 | let main (v:int(*-:{v:Int | true}*)) (p:int(*-:{v:Int | true}*)) (n:int(*-:{v:Int | true}*)) = 10 | if p > 0 then (* && n < 0 then *) 11 | f v p n 12 | else 0 13 | 14 | -------------------------------------------------------------------------------- /tests/effects/unsafe/disj.yml.prp: -------------------------------------------------------------------------------- 1 | (* Disjunctive *) 2 | 3 | QSet = [0;1;2;3]; 4 | 5 | delta = fun evx (q, acc) -> 6 | if ((q = 0) || (q = 1)) && (evx > 0) then (1,acc) 7 | else if (q = 1) && (evx < 0) then (3, acc) 8 | else if ((q = 0) || (q = 2)) && (evx < 0) then (2,acc) 9 | else if (q = 2) && (evx > 0) then (3, acc) 10 | else (3, acc); 11 | 12 | IniCfg = (0, 0); 13 | 14 | (* if event is pos, x must be even ; *) 15 | assert = fun (q, acc) -> (q < 3); 16 | 17 | -------------------------------------------------------------------------------- /tests/effects/unsafe/higher-order.ml: -------------------------------------------------------------------------------- 1 | let rec apply f x = (ev 1; if x <= 0 then 0 else ((apply f (f x)))) 2 | 3 | let pred x = x - 1 4 | let succ x = x + 1 5 | 6 | let main (n:int(*-:{v:Int | true}*)) = 7 | let _ = apply pred n in 8 | ev 2; 0 -------------------------------------------------------------------------------- /tests/effects/unsafe/higher-order.yml.prp: -------------------------------------------------------------------------------- 1 | (* 2 | Traces are just [1;2] 3 | q0 --1--> q1 --2--> q2 4 | q3 is the error state 5 | *) 6 | QSet = [0; 1; 2; 3]; 7 | 8 | delta = fun evx (q, acc) -> 9 | if ((evx = 1) && (q = 0 || q = 1)) then (1,acc) 10 | else if ((evx = 2) && (q = 1)) then (2,acc) 11 | else (3,0); 12 | 13 | IniCfg = (3, 0); 14 | 15 | assertFinal = fun (q, acc) -> q = 2; 16 | -------------------------------------------------------------------------------- /tests/effects/unsafe/last-ev-even.ml: -------------------------------------------------------------------------------- 1 | let rec foo vv f = 2 | if vv = 0 then begin ev f; 0 end 3 | else begin ev vv; foo (vv-1) f end 4 | 5 | let main (v:int(*-:{v:Int | true}*)) (final:int(*-:{v:Int | true}*)) = 6 | if (final mod 2 = 0) then 7 | foo v final 8 | else 9 | foo v (if v >= 0 then final+1 else final) 10 | 11 | -------------------------------------------------------------------------------- /tests/effects/unsafe/last-ev-even.yml.prp: -------------------------------------------------------------------------------- 1 | (* Last event seen is even *) 2 | 3 | QSet = [0]; 4 | 5 | delta = fun evx (q, acc) -> (q,evx+1); 6 | 7 | IniCfg = (0, 0); 8 | 9 | assertFinal = fun (q, acc) -> acc mod 2 = 0; 10 | -------------------------------------------------------------------------------- /tests/effects/unsafe/lics18-amortized.yml.prp: -------------------------------------------------------------------------------- 1 | QSet = [0;1]; 2 | 3 | (* [default state, error state] *) 4 | 5 | delta = fun evx (q, (enq, deq, tick)) -> 6 | if (q=0 && evx = 0) then (q, (enq+1, deq, tick)) 7 | else if (q=0 && evx = 1) then (q, (enq, deq+1, tick)) 8 | else if (q=0 && evx = 2) then (q, (enq, deq, tick+2)) 9 | else (1, (enq, deq, tick)); 10 | 11 | IniCfg = (0, (0,0,0)); 12 | 13 | assertFinal = fun (q, (enq, deq, tick)) -> q=0 && tick = enq+prefl2 && tick = deq-prefl1; 14 | (* assertFinal = fun (q, (enq, deq, tick)) -> q=0 && tick = enq+prefl2; *) 15 | -------------------------------------------------------------------------------- /tests/effects/unsafe/lics18-hoshrink.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec shrink t f d = 3 | if f () <= 0 then 0 4 | else begin 5 | ev 1; (* ev[Shrink] *) 6 | let t' = f() - d in 7 | shrink t' (fun x -> t') d end 8 | 9 | let main (gl_t:int(*-:{v:Int | true}*)) (gl_d:int(*-:{v:Int | true}*)) = 10 | ev (gl_t/gl_d); 11 | shrink gl_t (fun x -> gl_t) gl_d 12 | -------------------------------------------------------------------------------- /tests/effects/unsafe/lics18-hoshrink.yml.prp: -------------------------------------------------------------------------------- 1 | (* Dependent *) 2 | 3 | QSet = [0]; 4 | 5 | delta = fun evx (q, acc) -> (q, (acc-evx)); 6 | 7 | IniCfg = (0, 0); 8 | 9 | assertFinal = fun (q, acc) -> (acc = prefgl_t/prefgl_d); 10 | 11 | -------------------------------------------------------------------------------- /tests/effects/unsafe/lics18-web.ml: -------------------------------------------------------------------------------- 1 | (* Adapted from: 2 | A Fixpoint Logic and Dependent Effects for 3 | Temporal Property Verification 4 | Nanjo et al, LICS 2018 *) 5 | 6 | let rec listener i npool pend = 7 | if nondet && pend < npool then begin 8 | ev 1; (* Accept *) 9 | listener i npool (pend + 1) 10 | end else if pend > 0 then begin 11 | ev 2; (* Handle *) 12 | listener i npool (pend - 1) 13 | end else begin 14 | ev 3; (* Wait *) 15 | listener i npool pend 16 | end 17 | 18 | let main (npool:int(*-:{v:Int | true}*)) (i0:int(*-:{v:Int | true}*)) = 19 | listener i0 npool 0 20 | -------------------------------------------------------------------------------- /tests/effects/unsafe/market.ml: -------------------------------------------------------------------------------- 1 | let sell n1 = ev 5; ev n1; () 2 | 3 | let buy n2 = ev 1; ev n2; () 4 | 5 | let activity f n3 = f n3; ev 0; () 6 | 7 | let rec repeat n4 = 8 | if (n4<=0) then 0 9 | else 10 | begin 11 | activity buy 1; 12 | activity sell 1; 13 | 1 + repeat (n4-1) 14 | end 15 | 16 | let main (budget:int(*-:{v:Int | v >= 0}*)) (stock:int(*-:{v:Int | v >= 0}*)) (n:int(*-:{v:Int | v > 0}*)) = 17 | if (stock >= budget && budget >= n) then 18 | begin 19 | activity sell (-stock); 20 | activity buy (-budget); 21 | repeat n 22 | end 23 | else 24 | 0 25 | -------------------------------------------------------------------------------- /tests/effects/unsafe/market.yml.prp: -------------------------------------------------------------------------------- 1 | QSet = [0;1;2;3]; 2 | 3 | (* [stable state, consumer state, producer state, error state] *) 4 | 5 | delta = fun evx (q, (budget, stock)) -> 6 | if (q=0 && evx > 0 && evx < 3) then (evx, (budget, stock)) 7 | else if (q=1 && evx<>0) then (q, ((budget-evx), stock)) 8 | else if (q=2 && evx<>0) then (q, (budget, (stock-evx))) 9 | else if ((q=1||q=2) && evx=0) then (0, (budget, stock)) 10 | else (3, (budget, stock)); 11 | 12 | IniCfg = (0, (0,0)); 13 | 14 | assert = fun (q, (budget, stock)) -> q < 3 && budget >=0 && stock >=0 && stock >= budget; -------------------------------------------------------------------------------- /tests/effects/unsafe/max-min.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec compute vv bound1 inc = 3 | ev vv; 4 | if vv = bound1 then 0 else compute (inc vv) bound1 inc 5 | 6 | let main (v:int(*-:{v:Int | true}*)) (w:int(*-:{v:Int | true}*)) (m:int(*-:{v:Int | true}*)) = 7 | let f = (fun t -> if v >= 0 then t-1 else t+1) in 8 | if (v>=0 && v <= 100000) then 9 | let bound = -v in 10 | compute v bound f 11 | else if (v<0 && v >= (-100000)) then 12 | let bound = -v in 13 | compute v bound f 14 | else 15 | 0 16 | -------------------------------------------------------------------------------- /tests/effects/unsafe/max-min.yml.prp: -------------------------------------------------------------------------------- 1 | (* Max == -1 * Min *) 2 | 3 | QSet = [0;1]; 4 | 5 | delta = fun evx (q, (max,min)) -> 6 | if evx < min && evx > max then (1, (evx, evx)) 7 | else if evx < min then (1, (max,evx)) 8 | else if evx > max then (1, (evx,min)) 9 | else (1, (max,min)); 10 | 11 | IniCfg = (0, (-100000,100000)); 12 | 13 | assertFinal = fun (q, (max,min)) -> max + min > 0; 14 | -------------------------------------------------------------------------------- /tests/effects/unsafe/monotonic.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec mono t x = 3 | ev t; 4 | if x <= 0 then 0 5 | else 6 | mono (t+x) (x-1) (* increase t by positive amount *) 7 | 8 | let main (u: int(*-:{v:Int | true}*)) = 9 | if u>0 then mono 1 u else 0 10 | 11 | -------------------------------------------------------------------------------- /tests/effects/unsafe/monotonic.yml.prp: -------------------------------------------------------------------------------- 1 | (* 2 | Event values increase [1;2;5;...] 3 | Save previous value 4 | q1 is the error state 5 | *) 6 | QSet = [0;1]; 7 | 8 | delta = fun evx (q, acc) -> 9 | if (q = 0 && evx < acc) then (0, evx) 10 | else (1, 0); 11 | 12 | IniCfg = (0, 0); 13 | 14 | assertFinal = fun (q, acc) -> q = 0; 15 | -------------------------------------------------------------------------------- /tests/effects/unsafe/order-irrel.ml: -------------------------------------------------------------------------------- 1 | (* 2 | there are two particular events (let us treat them as integers 3 | c and -c for some c) such that at most one of them is permitted 4 | to occur during any execution 5 | *) 6 | let rec order d c = 7 | if (d > 0) then begin 8 | (* begin if ( d mod 2 = 0 ) then ev c else ev(-c) end; *) 9 | ev (if d mod 2 = 0 then c else (-c)); 10 | order (d - 2) c 11 | end else 0 12 | 13 | let main (dd:int(*-:{v:Int | true}*)) (cc:int(*-:{v:Int | v > 0}*)) = 14 | order dd cc 15 | 16 | -------------------------------------------------------------------------------- /tests/effects/unsafe/order-irrel.yml.prp: -------------------------------------------------------------------------------- 1 | (* there are two particular events (let us treat them as integers 2 | c and -c for some c) such that at most one of them is permitted 3 | to occur during any execution *) 4 | 5 | QSet = [0;1]; 6 | 7 | delta = fun evx (q, acc) -> 8 | if q = 1 then (1, acc) 9 | else if acc = 0 then (q, evx) 10 | else if acc > evx then (q, acc) 11 | else (1,acc); 12 | 13 | IniCfg = (0, 0); 14 | 15 | assertFinal = fun (q, acc) -> q = 0; 16 | -------------------------------------------------------------------------------- /tests/effects/unsafe/overview1.ml: -------------------------------------------------------------------------------- 1 | (* 2 | there are two particular events 3 | (let us treat them as integers c and -c for some c) 4 | and a temporal ordering: 5 | q0 --(c)--> q1 --(-c)--> q2 6 | where q0 and q1 are error states 7 | *) 8 | 9 | let rec busy n t = 10 | if n <= 0 then begin 11 | ev t; 12 | 0 13 | end else busy (n - 1) t 14 | 15 | let main (x:int(*-:{v:Int | true}*)) (n:int(*-:{v:Int | true}*)) = 16 | ev x; 17 | busy n x 18 | 19 | 20 | (* 21 | if dd > 0 then begin ev dd; ev(-dd) end 22 | else begin ev(-dd); ev dd; end 23 | *) 24 | 25 | -------------------------------------------------------------------------------- /tests/effects/unsafe/overview1.yml.prp: -------------------------------------------------------------------------------- 1 | QSet = [0;1;2]; 2 | 3 | delta = fun evx (q, acc) -> 4 | if (q = 0) then (1, evx) 5 | else if (q = 1) && (acc + evx = 0) then (2, acc) 6 | else if (q = 2) then (2, acc) 7 | else (q, acc); 8 | 9 | IniCfg = (0, 0); 10 | 11 | assertFinal = fun (q, acc) -> q = 2; 12 | -------------------------------------------------------------------------------- /tests/effects/unsafe/reentr.ml: -------------------------------------------------------------------------------- 1 | let rec reent d = 2 | ev 1; (* acquire *) 3 | if (d > 0) then 4 | begin 5 | if nondet then begin reent (d-1); ev (-2) (* release *) end 6 | else () 7 | end 8 | else 9 | () 10 | 11 | let main (n: int(*-:{v:Int | v > 0}*)) = 12 | reent n; ev (-1) (* release *) 13 | 14 | -------------------------------------------------------------------------------- /tests/effects/unsafe/reentr.yml.prp: -------------------------------------------------------------------------------- 1 | (* Never release more than acquire *) 2 | 3 | QSet = [0;1]; 4 | 5 | delta = fun evx (q, acc) -> 6 | if q = 0 && (acc + evx) >= 0 then (q, acc + evx) 7 | else if q = 0 && (acc + evx) < 0 then (1, acc + evx) 8 | else (q, acc); 9 | 10 | IniCfg = (0, 0); 11 | 12 | assert = fun (q, acc) -> q = 0; 13 | 14 | -------------------------------------------------------------------------------- /tests/effects/unsafe/resource-analysis.ml: -------------------------------------------------------------------------------- 1 | let rec spend n = 2 | ev -2; 3 | if n <= 0 then 0 else spend (n-1) 4 | 5 | let main (gas:int(*-:{v:Int | true}*)) (n:int(*-:{v:Int | true}*)) = 6 | if (gas > n && n >= 0) then begin ev gas; spend n end else 0 7 | -------------------------------------------------------------------------------- /tests/effects/unsafe/resource-analysis.yml.prp: -------------------------------------------------------------------------------- 1 | (* Resource Analysis *) 2 | 3 | QSet = [0]; 4 | 5 | delta = fun evx (q, acc) -> (q,acc + evx); 6 | 7 | IniCfg = (0, 0); 8 | 9 | assert = fun (q, acc) -> (acc >= 0); 10 | -------------------------------------------------------------------------------- /tests/effects/unsafe/sum-appendix.ml: -------------------------------------------------------------------------------- 1 | 2 | let sum x = 3 | ev 1; (fun y -> x + y) 4 | 5 | let main (u: unit(*-:{v:Unit | unit}*)) = 6 | ev 2; 7 | ev (sum (ev 3; 10) (ev 4; 20)) 8 | -------------------------------------------------------------------------------- /tests/effects/unsafe/sum-appendix.yml.prp: -------------------------------------------------------------------------------- 1 | QSet = [0]; 2 | 3 | delta = fun evx (q, acc) -> (q, (evx - acc)); 4 | 5 | IniCfg = (0, 0); 6 | 7 | assert = fun (q, acc) -> acc >= 0; 8 | 9 | assertFinal = fun (q, acc) -> acc = 40; 10 | -------------------------------------------------------------------------------- /tests/effects/unsafe/sum-of-ev-even.ml: -------------------------------------------------------------------------------- 1 | let rec sum x = 2 | ev x; 3 | if x <= 0 then 0 else sum (x - 2) 4 | 5 | let main (v:int(*-:{v:Int | true}*)) = 6 | if v mod 2 = 1 then sum v else sum (v + 1) 7 | -------------------------------------------------------------------------------- /tests/effects/unsafe/sum-of-ev-even.yml.prp: -------------------------------------------------------------------------------- 1 | (* Accumulate the Sum, and Sum is Even *) 2 | 3 | QSet = [0]; 4 | 5 | delta = fun evx (q, acc) -> (q,acc + evx); 6 | 7 | IniCfg = (0, 0); 8 | 9 | assert = fun (q, acc) -> true; 10 | 11 | assertFinal = fun (q, acc) -> (acc mod 2 = 0); 12 | 13 | -------------------------------------------------------------------------------- /tests/effects/unsafe/temperature.ml: -------------------------------------------------------------------------------- 1 | let rec f x pos neg = 2 | if x mod 2 = 0 then 3 | ev pos 4 | else 5 | ev neg; 6 | if (x <= 0) then 0 else f (x-2) (pos) (neg-1) 7 | 8 | 9 | let main (v:int(*-:{v:Int | true}*)) (p:int(*-:{v:Int | true}*)) (n:int(*-:{v:Int | true}*)) = 10 | if p > 0 && n < 0 then 11 | f v p n 12 | else 0 13 | 14 | -------------------------------------------------------------------------------- /tests/effects/unsafe/temperature.yml.prp: -------------------------------------------------------------------------------- 1 | (* Disjunctive *) 2 | 3 | QSet = [0;1;2;3]; 4 | 5 | delta = fun evx (q, acc) -> 6 | if ((q = 0) && (evx > 0)) then (1, evx) 7 | else if ((q = 0) && (evx < 0)) then (2, evx) 8 | (* q1=heating *) 9 | else if ((q = 1) && (evx > acc)) then (1, evx) 10 | (* q2=cooling *) 11 | else if ((q = 2) && (evx < acc)) then (2, evx) 12 | else (3, evx); 13 | 14 | IniCfg = (0, 0); 15 | 16 | (* if event is pos, x must be even ; *) 17 | assert = fun (q, acc) -> (q < 3); 18 | 19 | -------------------------------------------------------------------------------- /tests/list.ml: -------------------------------------------------------------------------------- 1 | 2 | let main n = 3 | let ra = Array.make 4 0 in (* ra: {v: Int | v = 2} *) 4 | let i = 3 in (* y: {v: Int | v = 3} *) 5 | Array.set ra 2 i (* {v: Int | v = 5} *) 6 | 7 | 8 | let _ = main 10 -------------------------------------------------------------------------------- /tests/relation.ml: -------------------------------------------------------------------------------- 1 | 2 | let rec recurs_n rn ri = 3 | let c = 0 in 4 | let d = 9 in 5 | if rn <= 0 then ri 6 | else 7 | (let r = 5 ; 8 | recurs_n (rn - 1) (ri + 1) 9 | in r) 10 | 11 | let main (n(*-:{v:Int | v > 0}*)) = 12 | recurs_n n 0 13 | 14 | 15 | 16 | (* ((lambda recurs_n^0. 17 | ((lambda main^1. (main^2 prefn^3)^4)^5 18 | (lambda n^6. ((recurs_n^7 n^8)^9 0^10)^11)^12)^13)^14 19 | (mu recurs_n^15 rn^16. 20 | (lambda ri^17. 21 | ((lambda c^18. 22 | ((rn^19 <= 0^20)^21 ? ri^22 : 23 | ((recurs_n^23 (rn^24 - 1^25)^26)^27 (ri^28 + 1^29)^30)^31)^32)^33 24 | 0^34)^35)^36)^37)^38 *) 25 | -------------------------------------------------------------------------------- /tests/test1: -------------------------------------------------------------------------------- 1 | let x = 1 in 2 | let y = 2 in 3 | let z = x + y in 4 | z 5 | -------------------------------------------------------------------------------- /tests/untyped.ml: -------------------------------------------------------------------------------- 1 | let main (x(*-:{v:Int | true}*)) = 2 | (if true then 1 else false) + 1 3 | --------------------------------------------------------------------------------