123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607(**************************************************************************)(* This file is part of the Codex semantics library. *)(* *)(* Copyright (C) 2013-2025 *)(* CEA (Commissariat à l'énergie atomique et aux énergies *)(* alternatives) *)(* *)(* you can redistribute it and/or modify it under the terms of the GNU *)(* Lesser General Public License as published by the Free Software *)(* Foundation, version 2.1. *)(* *)(* It is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Lesser General Public License for more details. *)(* *)(* See the GNU Lesser General Public License version 2.1 *)(* for more details (enclosed in the file LICENSE). *)(* *)(**************************************************************************)moduletypeS=sigincludeSva_sig.BITVECTOR;;valconcretize:bitvector->Lattices.BVSet.tvalabstract:size:int->Lattices.BVSet.t->bitvectorvalpretty:Format.formatter->bitvector->unitvalparse_string:string->bitvectorendmoduleCollecting=structincludeBinary_collectingletequal=Bitvector_Lattice.equalletsubset=Lattices.BVSet.ZSet.subsetletinter=Bitvector_Lattice.inter~size:(Units.In_bits.of_int(-1))endmoduleQuadrivalent=Lattices.QuadrivalentmoduleTest(Implem:S)=structmoduleStringSet=Set.Make(String);;(* All combinations with n bits *)letrecalln=ifn==0thenStringSet.singleton""elseletallprev=all(n-1)inletcatab=String.concat""[a;b]inStringSet.union(StringSet.map(cat"0")allprev)@@StringSet.union(StringSet.map(cat"1")allprev)@@(StringSet.map(cat"?")allprev);;lettest_soundness1absopconcopa=(* Format.printf "Abstract computation: %a %a@." Implem.pretty a Implem.pretty (absop a);
* Format.printf "Result: %a %a@."
* Collecting.pretty (concop (Implem.concretize a))
* Collecting.pretty (Implem.concretize (absop a)); *)Collecting.subset(concop(Implem.concretizea))(Implem.concretize(absopa))||failwith"Soundness check failed";;lettest_completeness1absopconcopa=(* Format.printf "Abstract computation: %a %a@." Implem.pretty a Implem.pretty (absop a);
* Format.printf "Result: %a %a@."
* Collecting.pretty (concop (Implem.concretize a))
* Collecting.pretty (Implem.concretize (absop a)); *)Collecting.equal(concop(Implem.concretizea))(Implem.concretize(absopa))||failwith"Completeness check failed";;lettest_best_transformer1~sizeabsopconcopa=(* Format.printf "Abstract computation: %a %a@." Implem.pretty a Implem.pretty (absop a);
* Format.printf "Result: %a %a %a %a@."
* Collecting.pretty (concop (Implem.concretize a))
* Collecting.pretty (Implem.concretize (absop a))
* Implem.pretty (Implem.abstract ~size @@ concop (Implem.concretize a))
* Collecting.pretty (Implem.concretize @@ Implem.abstract ~size @@ concop (Implem.concretize a))
* ; *)Collecting.equal(Implem.concretize@@Implem.abstract~size@@concop(Implem.concretizea))(Implem.concretize(absopa))||failwith"Maximally precise check failed";;lettest_soundness2absopconcopab=(* Format.printf "Abstract computation: %a op %a = %a@." Implem.pretty a Implem.pretty b Implem.pretty (absop a b);
* Format.printf "Result: %a %a@."
* Collecting.pretty (concop (Implem.concretize a) (Implem.concretize b))
* Collecting.pretty (Implem.concretize (absop a b)); *)Collecting.subset(concop(Implem.concretizea)(Implem.concretizeb))(Implem.concretize(absopab))||(* failwith *)(* (Format.printf "Soundness check failed: %a op %a = %a should be %a\n" Implem.pretty a Implem.pretty b Implem.pretty (absop a b) Collecting.pretty (concop (Implem.concretize a) (Implem.concretize b)) ; true) *)true;;lettest_soundness2_predabsopconcopab=(* Format.printf "Abstract computation: %a op %a = %a@." Implem.pretty a Implem.pretty b Quadrivalent.pretty (absop a b); *)(* Format.printf "Result: %a %a@."
* Quadrivalent.pretty (concop (Implem.concretize a) (Implem.concretize b))
* Quadrivalent.pretty (absop a b); *)Quadrivalent.includes(absopab)(concop(Implem.concretizea)(Implem.concretizeb))||failwith"Soundness check failed";;(* I could give an example of soundness or incompleteness. *)lettest_completeness2absopconcopab=(* Format.printf "Abstract computation: %a %a@." Implem.pretty a Implem.pretty (absop a b);
* Format.printf "Result: %a %a@."
* Collecting.pretty (concop (Implem.concretize a) (Implem.concretize b))
* Collecting.pretty (Implem.concretize (absop a b)); *)Collecting.equal(concop(Implem.concretizea)(Implem.concretizeb))(Implem.concretize(absopab))||failwith"Completeness check failed";;lettest_completeness2_predabsopconcopab=(* Format.printf "Abstract computation: %a op %a = %a@." Implem.pretty a Implem.pretty b Quadrivalent.pretty (absop a b); *)(* Format.printf "Result: %a %a@."
* Quadrivalent.pretty (concop (Implem.concretize a) (Implem.concretize b))
* Quadrivalent.pretty (absop a b); *)Quadrivalent.equal(concop(Implem.concretizea)(Implem.concretizeb))(absopab)||failwith(Format.asprintf"Completeness/best transformer check failed: %a op %a = %a, best result is %a"Implem.prettyaImplem.prettybQuadrivalent.pretty(absopab)Quadrivalent.pretty(concop(Implem.concretizea)(Implem.concretizeb)));;lettest_best_transformer2~sizeabsopconcopab=(* Format.printf "Abstract computation: %a %a@." Implem.pretty a Implem.pretty (absop a b);
* Format.printf "Result: %a %a@."
* Collecting.pretty (concop (Implem.concretize a) (Implem.concretize b))
* Collecting.pretty (Implem.concretize (absop a b)); *)Collecting.equal(Implem.concretize@@Implem.abstract~size@@concop(Implem.concretizea)(Implem.concretizeb))(Implem.concretize(absopab))||failwith(Format.asprintf"Maximal precision check failed: %a op %a returns %a, optimal result is %a"Implem.prettyaImplem.prettybImplem.pretty(absopab)Implem.pretty(Implem.abstract~size@@concop(Implem.concretizea)(Implem.concretizeb)))(* Collecting.equal (concop (Implem.concretize a) (Implem.concretize b))
* (Implem.concretize (absop a b)) || failwith "Maximal precision check failed" *);;(* no test_best_transformer2_pred, as this is the same than test_best_transformer2_complete. *)(* test_soundness2 Implem.(band) Collecting.band (Implem.parse_string "1?10?") (Implem.parse_string "1?10?");;
* test_completeness2 Implem.(band) Collecting.band (Implem.parse_string "1?10?") (Implem.parse_string "1?10?");; *)letall_test_f1fbitsabsopconcop=(allbits)|>StringSet.iter(funa->(* Format.printf "testing for a=%s@." a; *)leta=Implem.parse_stringain(* Format.printf "a = %a res = %a@." Implem.pretty a Implem.pretty (absop a); *)assert(fabsopconcopa));;letall_test_f2fbitsabsopconcop=(allbits)|>StringSet.iter(funa->(allbits)|>StringSet.iter(funb->(* Format.printf "testing for a=%s b=%s@." a b; *)leta=Implem.parse_stringainletb=Implem.parse_stringbin(* Format.printf "res = %a@." Implem.pretty (absop a b); *)assert(fabsopconcopab)));;letall_test_f2'f(bitsa,bitsb)absopconcop=(allbitsa)|>StringSet.iter(funa->(allbitsb)|>StringSet.iter(funb->(* Format.printf "testing for a=%s b=%s@." a b; *)leta=Implem.parse_stringainletb=Implem.parse_stringbin(* Format.printf "res = %a@." Implem.pretty (absop a b); *)assert(fabsopconcopab)));;letall_test_f3f(bitsa,bitsb,bitsr)absopconcop=(allbitsa)|>StringSet.iter(funa->(allbitsb)|>StringSet.iter(funb->(allbitsr)|>StringSet.iter(funr->(* Format.printf "testing for a=%s b=%s@." a b; *)leta=Implem.parse_stringainletb=Implem.parse_stringbinletr=Implem.parse_stringrin(* Format.printf "res = %a@." Implem.pretty (absop a b); *)assert(fabsopconcopabr))));;letall_test_f3'f(bitsa,bitsb,bitsr)absopconcop=(allbitsa)|>StringSet.iter(funa->(allbitsb)|>StringSet.iter(funb->[Quadrivalent.True;Quadrivalent.False;Quadrivalent.Bottom;Quadrivalent.Top]|>List.iter(funr->(* Format.printf "testing for a=%s b=%s@." a b; *)leta=Implem.parse_stringainletb=Implem.parse_stringbin(* Format.printf "res = %a@." Implem.pretty (absop a b); *)assert(fabsopconcopabr))));;(* Note: complete implies maximally precise.contents.
Actually, my completeness checks that we are sound and complete. *)letall_test_soundness1=all_test_f1test_soundness1;;letall_test_completeness1=all_test_f1test_completeness1;;letall_test_best1size=all_test_f1(test_best_transformer1~size);;letall_test_soundness2=all_test_f2test_soundness2;;letall_test_soundness2_pred=all_test_f2test_soundness2_pred;;letall_test_completeness2=all_test_f2test_completeness2;;letall_test_completeness2_pred=all_test_f2test_completeness2_pred;;letall_test_best2size=all_test_f2(test_best_transformer2~size);;moduleBF=Implem.Bitvector_Forward;;moduleBR=Implem.Bitvector_Backward;;moduleCBF=Collecting.Bitvector_Forward;;moduleCBB=Collecting.Bitvector_Backward;;letsize1=Units.In_bits.of_int1;;letsize2=Units.In_bits.of_int2;;letsize3=Units.In_bits.of_int3;;letsize4=Units.In_bits.of_int4;;moduleTest()=struct(* all_test_soundness2 1 BF.band Collecting.band;;
* Format.printf "band is sound@.";; *)all_test_completeness21(BF.band~size:size1)(CBF.band~size:size1);;Format.printf"band is sound and complete@.";;(* all_test_soundness2 1 BF.bor Collecting.bor;;
* Format.printf "bor is sound@.";; *)all_test_completeness21(BF.bor~size:size1)(CBF.bor~size:size1);;Format.printf"bor is sound and complete@.";;(* all_test_soundness2 1 BF.bxor CBF.bxor;;
* Format.printf "bxor is sound@.";; *)all_test_completeness21(BF.bxor~size:size1)(CBF.bxor~size:size1);;Format.printf"bxor is sound and complete@.";;letflags=(Operator.Flags.Biadd.pack~nsw:false~nuw:false~nusw:false)inall_test_soundness24(BF.biadd~size:size4~flags)(CBF.biadd~size:size4~flags);;Format.printf"biadd is sound@.";;(* all_test_best2 4 4 (BF.biadd ~size:size4) (CBF.biadd ~size:size4);;
* Format.printf "biadd is maximally precise@.";; *)(* biadd is incomplete, and not maximaly precise (e.g. cannot compute 1 + 1 = 2). *)letflags=(Operator.Flags.Bisub.pack~nsw:false~nuw:false~nusw:false)inall_test_soundness24(BF.bisub~size:size4~flags)(CBF.bisub~size:size4~flags);;Format.printf"bisub is sound@.";;(* bisub is incomplete and not maximally precise. *)(* all_test_soundness1 2 (BF.buext ~size:size4 ~oldsize:2) (CBF.buext ~size:size4 ~oldsize:2);;
* Format.printf "buext is sound@.";; *)all_test_completeness12(BF.buext~size:size4~oldsize:size2)(CBF.buext~size:size4~oldsize:size2);;Format.printf"buext is sound and complete@.";;all_test_soundness12(BF.bsext~size:size4~oldsize:size2)(CBF.bsext~size:size4~oldsize:size2);;Format.printf"bsext is sound@.";;(* bsext is incomplete, as we loose the fact the the copied bits are all equal. *)all_test_best142(BF.bsext~size:size4~oldsize:size2)(CBF.bsext~size:size4~oldsize:size2);;Format.printf"bsext is maximally precise@.";;letflags=(Operator.Flags.Bshl.pack~nsw:false~nuw:false)inall_test_soundness24(BF.bshl~size:size4~flags)(CBF.bshl~size:size4~flags);;Format.printf"bshl is sound@.";;(* bshl is incomplete: 1 << ? = ??, while {1 << 0} U {1 << 1} = {1,10} *)letflags=(Operator.Flags.Bshl.pack~nsw:false~nuw:false)inall_test_best244(BF.bshl~size:size4~flags)(CBF.bshl~size:size4~flags);;Format.printf"bshl is maximally precise@.";;all_test_soundness24(BF.blshr~size:size4)(CBF.blshr~size:size4);;Format.printf"blshr is sound@.";;(* blshr is incomplete: 1 << ? = ??, while {1 << 0} U {1 << 1} = {1,10} *)all_test_best244(BF.blshr~size:size4)(CBF.blshr~size:size4);;Format.printf"blshr is maximally precise@.";;all_test_soundness24(BF.bashr~size:size4)(CBF.bashr~size:size4);;Format.printf"bashr is sound@.";;all_test_best244(BF.bashr~size:size4)(CBF.bashr~size:size4);;Format.printf"bashr is maximally precise@.";;(* all_test_soundness2_pred 2 (BF.beq ~size:size2) (CBF.beq ~size:size2);;
* Format.printf "beq is sound@.";; *)all_test_completeness2_pred2(BF.beq~size:size2)(CBF.beq~size:size2);;Format.printf"beq is sound and complete@.";;(* all_test_soundness2_pred 4 (BF.bisle ~size:size4) (CBF.bisle ~size:size4);;
* Format.printf "bisle is sound@.";; *)all_test_completeness2_pred2(BF.bisle~size:size4)(CBF.bisle~size:size4);;Format.printf"bisle is sound and complete@.";;(* all_test_soundness2_pred 4 (BF.biule ~size:size4) (CBF.biule ~size:size4);;
* Format.printf "biule is sound@.";; *)all_test_completeness2_pred2(BF.biule~size:size4)(CBF.biule~size:size4);;Format.printf"biule is sound and complete@.";;(* all_test_soundness2 3 (BF.bconcat ~size1:size3 ~size2:size3) (CBF.bconcat ~size1:size3 ~size2:size3);;
* Format.printf "bconcat is sound@.";; *)all_test_completeness23(BF.bconcat~size1:size3~size2:size3)(CBF.bconcat~size1:size3~size2:size3);;Format.printf"bconcat is sound and complete@.";;(* all_test_soundness1 4 (BF.bextract ~index:1 ~size:size2 ~oldsize:size4) (CBF.bextract ~index:1 ~size:size2 ~oldsize:size4);;
* Format.printf "bextract is sound@.";; *)all_test_completeness14(BF.bextract~index:size1~size:size2~oldsize:size4)(CBF.bextract~index:size1~size:size2~oldsize:size4);;Format.printf"bextract is sound and complete@.";;all_test_soundness24(BF.bimul~size:size4~flags:(Operator.Flags.Bimul.pack~nsw:false~nuw:false))(CBF.bimul~size:size4~flags:(Operator.Flags.Bimul.pack~nsw:false~nuw:false));;Format.printf"bimul is sound@.";;(* bisub is incomplete. *)end;;all_test_soundness24(BF.biudiv~size:size4)(CBF.biudiv~size:size4);;Format.printf"biudiv is sound@.";;all_test_soundness24(BF.biumod~size:size4)(CBF.biumod~size:size4);;Format.printf"biumod is sound@.";;all_test_soundness23(BF.bisdiv~size:size3)(CBF.bisdiv~size:size3);;Format.printf"bisdiv is sound@.";;all_test_soundness24(BF.bismod~size:size4)(CBF.bismod~size:size4);;Format.printf"bismod is sound@.";;(* all_test_completeness1 2 (BF.bnot ~size:size2) (CBF.bnot ~size:size2);;
* Format.printf "bnot is sound@.";; *)(* end;; *)(* I could give an example of soundness or incompleteness. *)lettest_backward_soundness1absopconcopar=matchabsoparwith|None->true|Somex->(* Should always return a refinement. *)assert(Collecting.subset(Implem.concretizex)(Implem.concretizea));(* Should x be such that its image through concop encompasses what is both in r
and in the image of a. *)(* Format.printf "Result: a=%a r=%a res=%a@." Implem.pretty a Implem.pretty r Implem.pretty x; *)(* Format.fprintf "Error? %a %a" Collecting.pretty (concop @@ Implem.concretize x) *)assert(Collecting.subset(Collecting.inter(Implem.concretizer)(concop@@Implem.concretizea))(concop@@Implem.concretizex));true(* Collecting.subset (Implem.concretize)
* (\* Format.printf "Abstract computation: %a %a@." Implem.pretty a Implem.pretty (absop a b);
* * Format.printf "Result: %a %a@."
* * Collecting.pretty (concop (Implem.concretize a) (Implem.concretize b))
* * Collecting.pretty (Implem.concretize (absop a b)); *\)
* Collecting.equal (concop (Implem.concretize a) (Implem.concretize b))
* (Implem.concretize (absop a b)) || failwith "Completeness check failed" *);;(* I could give an example of soundness or incompleteness. *)lettest_backward_soundness2absopconcopabr=letnewa,newb=matchabsopabrwith|None,None->a,b|Somea,None->a,b|None,Someb->a,b|Somea,Someb->a,bin(* Should always return a refinement. *)assert(Collecting.subset(Implem.concretizenewa)(Implem.concretizea));assert(Collecting.subset(Implem.concretizenewb)(Implem.concretizeb));Format.printf"Result: a=%a b=%a r=%a newa=%a newb=%a@."Implem.prettyaImplem.prettybImplem.prettyrImplem.prettynewaImplem.prettynewb;(* Should newa and newb be such that its image through concop encompasses what is both in r
and in the image of a,b. *)assert(Collecting.subset(Collecting.inter(Implem.concretizer)(concop(Implem.concretizea)(Implem.concretizeb)))(concop(Implem.concretizenewa)(Implem.concretizenewb)));true(* Collecting.subset (Implem.concretize)
* (\* Format.printf "Abstract computation: %a %a@." Implem.pretty a Implem.pretty (absop a b);
* * Format.printf "Result: %a %a@."
* * Collecting.pretty (concop (Implem.concretize a) (Implem.concretize b))
* * Collecting.pretty (Implem.concretize (absop a b)); *\)
* Collecting.equal (concop (Implem.concretize a) (Implem.concretize b))
* (Implem.concretize (absop a b)) || failwith "Completeness check failed" *);;lettest_backward_soundness2_predabsopconcopabr=letnewa,newb=matchabsopabrwith|None,None->a,b|Somea,None->a,b|None,Someb->a,b|Somea,Someb->a,bin(* Should always return a refinement. *)assert(Collecting.subset(Implem.concretizenewa)(Implem.concretizea));assert(Collecting.subset(Implem.concretizenewb)(Implem.concretizeb));Format.printf"Result: a=%a b=%a r=%a newa=%a newb=%a@."Implem.prettyaImplem.prettybQuadrivalent.prettyrImplem.prettynewaImplem.prettynewb;(* Should newa and newb be such that its image through concop encompasses what is both in r
and in the image of a,b. *)assert(Quadrivalent.includes(concop(Implem.concretizenewa)(Implem.concretizenewb))(Quadrivalent.interr(concop(Implem.concretizea)(Implem.concretizeb))));(* This also tests completeness. *)(* assert(Quadrivalent.equal
* (Quadrivalent.inter r (concop (Implem.concretize a) (Implem.concretize b)))
* (concop (Implem.concretize newa) (Implem.concretize newb))
* ); *)true(* Collecting.subset (Implem.concretize)
* (\* Format.printf "Abstract computation: %a %a@." Implem.pretty a Implem.pretty (absop a b);
* * Format.printf "Result: %a %a@."
* * Collecting.pretty (concop (Implem.concretize a) (Implem.concretize b))
* * Collecting.pretty (Implem.concretize (absop a b)); *\)
* Collecting.equal (concop (Implem.concretize a) (Implem.concretize b))
* (Implem.concretize (absop a b)) || failwith "Completeness check failed" *);;lettest_backward_completeness2_predabsopconcopabr=(* let r = Quadrivalent.inter r @@ absopf a b in *)letnewa,newb=matchabsopabrwith|None,None->a,b|Somea,None->a,b|None,Someb->a,b|Somea,Someb->a,bin(* Should always return a refinement. *)assert(Collecting.subset(Implem.concretizenewa)(Implem.concretizea));assert(Collecting.subset(Implem.concretizenewb)(Implem.concretizeb));Format.printf"Result: a=%a b=%a r=%a newa=%a newb=%a@."Implem.prettyaImplem.prettybQuadrivalent.prettyrImplem.prettynewaImplem.prettynewb;(* Should newa and newb be such that its image through concop encompasses what is both in r
and in the image of a,b. *)assert(Quadrivalent.equal(Quadrivalent.interr(concop(Implem.concretizea)(Implem.concretizeb)))(concop(Implem.concretizenewa)(Implem.concretizenewb)));(* This also tests completeness. *)(* assert(Quadrivalent.equal
* (Quadrivalent.inter r (concop (Implem.concretize a) (Implem.concretize b)))
* (concop (Implem.concretize newa) (Implem.concretize newb))
* ); *)true(* Collecting.subset (Implem.concretize)
* (\* Format.printf "Abstract computation: %a %a@." Implem.pretty a Implem.pretty (absop a b);
* * Format.printf "Result: %a %a@."
* * Collecting.pretty (concop (Implem.concretize a) (Implem.concretize b))
* * Collecting.pretty (Implem.concretize (absop a b)); *\)
* Collecting.equal (concop (Implem.concretize a) (Implem.concretize b))
* (Implem.concretize (absop a b)) || failwith "Completeness check failed" *);;letforward_then_backward_predfwdbwd=funabr->letr=Quadrivalent.interr@@fwdabinbwdabr;;letall_test_backward_soundness1=all_test_f2'test_backward_soundness1;;letall_test_backward_soundness2=all_test_f3test_backward_soundness2;;letall_test_backward_soundness2_pred=all_test_f3'test_backward_soundness2_pred;;(* let all_test_backward_completeness2_pred = all_test_f3' test_backward_completeness2_pred;; *)moduleBTest()=struct(* all_test_backward_soundness1 (2,2) (BR.bnot ~size:size2) (Collecting.bnot ~size:size2);;
* Format.printf "rev_bnot is sound (and complete)@.";; *)all_test_backward_soundness2(2,2,2)(BR.band~size:size2)(CBF.band~size:size2);;Format.printf"rev_band is sound@.";;all_test_backward_soundness2(2,2,2)(BR.bor~size:size2)(CBF.bor~size:size2);;Format.printf"rev_bor is sound@.";;all_test_backward_soundness2(2,2,2)(BR.bxor~size:size2)(CBF.bxor~size:size2);;Format.printf"rev_bxor is sound@.";;all_test_backward_soundness2(2,2,4)(BR.bconcat~size1:size2~size2:size2)(CBF.bconcat~size1:size2~size2:size2);;Format.printf"rev_bconcat is sound@.";;all_test_backward_soundness1(4,2)(BR.bextract~size:size2~index:size1~oldsize:size4)(CBF.bextract~size:size2~index:size1~oldsize:size4);;Format.printf"rev_bextract is sound@.";;all_test_backward_soundness1(2,4)(BR.buext~size:size4~oldsize:size2)(CBF.buext~size:size4~oldsize:size2);;Format.printf"rev_buext is sound@.";;all_test_backward_soundness1(2,4)(BR.bsext~size:size4~oldsize:size2)(CBF.bsext~size:size4~oldsize:size2);;Format.printf"rev_bsext is sound@.";;(* Takes around 15s. *)letflags=(Operator.Flags.Bshl.pack~nsw:false~nuw:false)inall_test_backward_soundness2(4,4,4)(BR.bshl~size:size4~flags)(CBF.bshl~size:size4~flags);;Format.printf"rev_bshl is sound@.";;all_test_backward_soundness2(4,4,4)(BR.blshr~size:size4)(CBF.blshr~size:size4);;Format.printf"rev_blshr is sound@.";;all_test_backward_soundness2(2,2,2)(BR.bashr~size:size2)(CBF.bashr~size:size2);;Format.printf"rev_bashr is sound@.";;all_test_backward_soundness2(4,4,4)(BR.bashr~size:size4)(CBF.bashr~size:size4);;Format.printf"rev_bashr is sound@.";;all_test_backward_soundness2_pred(3,3,3)(BR.beq~size:size3)(CBF.beq~size:size3);;Format.printf"rev_beq is sound@.";;(* all_test_backward_completeness2_pred (3,3,3) (forward_then_backward_pred (BF.beq ~size:size3) (BR.beq ~size:size3)) (CBF.beq ~size:size3);;
* Format.printf "rev_beq is complete@.";; *)all_test_backward_soundness2_pred(3,3,3)(BR.biule~size:size3)(CBF.biule~size:size3);;Format.printf"rev_biule is sound@.";;all_test_backward_soundness2_pred(3,3,3)(BR.bisle~size:size3)(CBF.bisle~size:size3);;Format.printf"rev_bisle is sound@.";;letflags=(Operator.Flags.Biadd.pack~nsw:false~nuw:false~nusw:false)inall_test_backward_soundness2(3,3,3)(BR.biadd~size:size3~flags)(CBF.biadd~size:size3~flags);;Format.printf"rev_biadd is sound@.";;letflags=(Operator.Flags.Bisub.pack~nsw:false~nuw:false~nusw:false)inall_test_backward_soundness2(3,3,3)(BR.bisub~size:size3~flags)(CBF.bisub~size:size3~flags);;Format.printf"rev_bisub is sound@.";;letflags=(Operator.Flags.Bimul.pack~nsw:false~nuw:false)inall_test_backward_soundness2(3,3,3)(BR.bimul~flags~size:size3)(CBF.bimul~flags~size:size3);;Format.printf"rev_bimul is sound@.";;letflags=(Operator.Flags.Bimul.pack~nsw:true~nuw:false)inall_test_backward_soundness2(3,3,3)(BR.bimul~flags~size:size3)(CBF.bimul~flags~size:size3);;Format.printf"rev_bimul is sound@.";;letflags=(Operator.Flags.Bimul.pack~nsw:false~nuw:true)inall_test_backward_soundness2(3,3,3)(BR.bimul~flags~size:size3)(CBF.bimul~flags~size:size3);;Format.printf"rev_bimul is sound@.";;letflags=(Operator.Flags.Bimul.pack~nsw:true~nuw:true)inall_test_backward_soundness2(3,3,3)(BR.bimul~flags~size:size3)(CBF.bimul~flags~size:size3);;Format.printf"rev_bimul is sound@.";;all_test_backward_soundness2(3,3,3)(BR.biudiv~size:size3)(CBF.biudiv~size:size3);;Format.printf"rev_biudiv is sound@.";;all_test_backward_soundness2(3,3,3)(BR.bisdiv~size:size3)(CBF.bisdiv~size:size3);;Format.printf"rev_bisdiv is sound@.";;all_test_backward_soundness2(3,3,3)(BR.biumod~size:size3)(CBF.biumod~size:size3);;Format.printf"rev_biumod is sound@.";;all_test_backward_soundness2(3,3,3)(BR.bismod~size:size3)(CBF.bismod~size:size3);;Format.printf"rev_bismod is sound@.";;end;;(* all_test_backward_completeness2_pred (3,3,3) (BR.biule ~size:size3) (CBF.biule ~size:size3);;
* Format.printf "rev_biule is complete@.";; *)(* all_test_backward_completeness2_pred (3,3,3) (BF.biule ~size:size3) (BR.biule ~size:size3) (CBF.biule ~size:size3);;
* Format.printf "rev_biule is complete@.";; *)(* XXX: tester la completeness de mes predicats; peut-etre en raffinant d'abord res apres avoir calcule op(x,y), puisque cést je pense ce que je présume et pour ca que je suis incomplete.
*
* XXX:biule marche pas mal, mais ameliorer *)(* all_test_backward_soundness2_pred (4,4,4) (BR.biule ~size:size4) (CBF.biule ~size:size4);;
* Format.printf "rev_biule is sound@.";; *)(* all_test_best2 3 3 (BF.bismod ~size:size3) (CBF.bismod ~size:size3);;
* Format.printf "bismod is maximlly precise@.";; *)(* all_test_soundness2 4 (BF.bisdiv ~size:size4) (CBF.bisdiv ~size:size4);;
* Format.printf "bisdiv is sound@.";; *)end;;(* module TestMust0_Must1 = Test(Known_bits_basis);; *)