Added Selene's modification

This commit is contained in:
soyouzpanda 2024-06-01 20:58:56 +02:00
parent ab1ba60b36
commit 0ed5e6b81f
3 changed files with 9 additions and 6 deletions

View file

@ -19,6 +19,7 @@ let doit filename = begin
Cfg_printer.output_dot !Options.cfg_out cfg;
let f = match !Options.domain with
| "signs" -> SignIterator.iterate cfg
| "interval" -> IntervalIterator.iterate cfg
| "constants" -> ConstIterator.iterate cfg
| _ -> ConstIterator.iterate cfg in
Format.printf "@[<v 0>Failed asserts :@ %a@]" pp_asserts f end

View file

@ -23,12 +23,12 @@ module Interval : NAKED_VALUE_DOMAIN = struct
let join z1 z2 = rand4 z1.lower z2.lower z1.upper z2.upper
let meet z1 z2 =
if Z.leq z1.upper z2.lower || Z.leq z2.upper z1.lower then raise Absurd
if Z.lt z1.upper z2.lower || Z.lt z2.upper z1.lower then raise Absurd
else rand (Z.max z1.lower z2.lower) (Z.min z1.upper z2.upper)
let widen z1 z2 =
rand
(if Z.leq z1.lower z2.lower then z1.lower else min_infty)
(if Z.geq z1.upper z2.upper then z1.upper else infty)
(if Z.lt z1.lower z2.lower then z1.lower else min_infty)
(if Z.gt z1.upper z2.upper then z1.upper else infty)
let narrow = meet
let subset z1 z2 = Z.geq z1.lower z2.lower && Z.leq z1.upper z2.upper
@ -70,7 +70,7 @@ module Interval : NAKED_VALUE_DOMAIN = struct
let rec compare z1 z2 = function
| AST_EQUAL ->
let z = join z1 z2 in
let z = meet z1 z2 in
(z, z)
| AST_NOT_EQUAL ->
if
@ -97,8 +97,8 @@ module Interval : NAKED_VALUE_DOMAIN = struct
let r1 = rand z1.lower (Z.min z1.upper z2.upper) in
let r2 = rand (Z.max z1.lower z2.lower) z2.upper in
(r1, r2)
| AST_GREATER -> compare z2 z1 AST_LESS
| AST_GREATER_EQUAL -> compare z2 z1 AST_GREATER_EQUAL
| AST_GREATER -> let r1, r2 = compare z2 z1 AST_LESS in r2, r1
| AST_GREATER_EQUAL -> let r1, r2 = compare z2 z1 AST_GREATER_EQUAL in r2, r1
let bwd_binary z1 z2 op r =
match op with

View file

@ -81,12 +81,14 @@ module Iterator (D : DOMAIN) = struct
end
end
open Interval
open Sign
open Constant
open Naked
open Value_domain
module ConstIterator = Iterator(NonRelational(AddTopBot(Constants)))
module SignIterator = Iterator(NonRelational(AddTopBot(Signs)))
module IntervalIterator = Iterator(NonRelational(AddTopBot(Interval)))
(*
let iterate cfg =
let () = Random.self_init () in