diff options
author | Alex Auvolat <alex.auvolat@ansys.com> | 2014-07-04 17:55:50 +0200 |
---|---|---|
committer | Alex Auvolat <alex.auvolat@ansys.com> | 2014-07-04 17:55:50 +0200 |
commit | 3f53be86214bb9a7873a6cf3377c49e5f84d9729 (patch) | |
tree | 5509b5d0375ae632a7fb5e2cf74e7a4f38a2b897 /abstract/formula.ml | |
parent | 9628140878d0f57bbb37186b00164b80365f9b34 (diff) | |
parent | 696d07415d52b092c9c69a9b1042a8bc9cd51a90 (diff) | |
download | scade-analyzer-3f53be86214bb9a7873a6cf3377c49e5f84d9729.tar.gz scade-analyzer-3f53be86214bb9a7873a6cf3377c49e5f84d9729.zip |
Merge branch 'e-last'
Conflicts:
abstract/abs_interp.ml
tests/source/counters.scade
Diffstat (limited to 'abstract/formula.ml')
-rw-r--r-- | abstract/formula.ml | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/abstract/formula.ml b/abstract/formula.ml index 01f6655..0045489 100644 --- a/abstract/formula.ml +++ b/abstract/formula.ml @@ -50,19 +50,26 @@ type bool_expr = | BOr of bool_expr * bool_expr | BNot of bool_expr -let f_and a b = match a, b with - | BConst false, _ | _, BConst false -> BConst false - | BConst true, b -> b - | a, BConst true -> a - | a, b -> BAnd(a, b) +let is_false = function + | BConst false | BNot(BConst true) -> true + | _ -> false +let is_true = function + | BConst true | BNot(BConst false) -> true + | _ -> false + +let f_and a b = + if is_false a || is_false b then BConst false + else if is_true a then b + else if is_true b then a + else BAnd(a, b) let f_and_list = List.fold_left f_and (BConst true) -let f_or a b = match a, b with - | BConst true, _ | _, BConst true -> BConst true - | BConst false, b -> b - | a, BConst false -> a - | a, b -> BOr(a, b) +let f_or a b = + if is_true a || is_true b then BConst true + else if is_false a then b + else if is_false b then a + else BOr(a, b) let f_e_op op a b = match a, b with | EItem i, EItem j -> BConst (if op = E_EQ then i = j else i <> j) |