Skip to content
Snippets Groups Projects
Commit a81dea06 authored by David Bühler's avatar David Bühler
Browse files

[Eva] Subdivided_evaluation takes the max number of subdivisions as argument.

The maximal number of subdivisions is a new field of the context record for the
forward evaluation functions, as it is also used when calling the oracle.
parent bf817f2a
No related branches found
No related tags found
No related merge requests found
...@@ -746,6 +746,9 @@ module Make ...@@ -746,6 +746,9 @@ module Make
type context = type context =
{ (* The abstract domain state in which the evaluation takes place. *) { (* The abstract domain state in which the evaluation takes place. *)
state: Domain.t; state: Domain.t;
(* Maximum number of subdivisions. See {!Subdivided_evaluation} for
more details. *)
subdivision: int;
(* The remaining fuel: maximum number of nested oracle uses, decremented (* The remaining fuel: maximum number of nested oracle uses, decremented
at each call to the oracle. *) at each call to the oracle. *)
remaining_fuel: int; remaining_fuel: int;
...@@ -1093,7 +1096,8 @@ module Make ...@@ -1093,7 +1096,8 @@ module Make
fun expr -> fun expr ->
let valuation = !cache in let valuation = !cache in
let context = { context with remaining_fuel } in let context = { context with remaining_fuel } in
Subdivided_Evaluation.evaluate context valuation expr let subdivnb = context.subdivision in
Subdivided_Evaluation.evaluate context valuation ~subdivnb expr
>>=: fun (valuation, value) -> >>=: fun (valuation, value) ->
cache := valuation; cache := valuation;
value value
...@@ -1104,15 +1108,20 @@ module Make ...@@ -1104,15 +1108,20 @@ module Make
with maximal precision. *) with maximal precision. *)
let root_context state = let root_context state =
let remaining_fuel = root_fuel () in let remaining_fuel = root_fuel () in
{ state; remaining_fuel; oracle } let subdivision = Value_parameters.LinearLevel.get () in
{ state; subdivision; remaining_fuel; oracle }
(* Context for a fast forward evaluation with minimal precision. *) (* Context for a fast forward evaluation with minimal precision:
no subdivisions and no call to the oracle. *)
let low_context state = let low_context state =
let remaining_fuel = no_fuel in let remaining_fuel = no_fuel in
{ state; remaining_fuel; oracle } let subdivision = 0 in
{ state; subdivision; remaining_fuel; oracle }
let subdivided_forward_eval valuation state expr = let subdivided_forward_eval valuation state expr =
Subdivided_Evaluation.evaluate (root_context state) valuation expr let context = root_context state in
let subdivnb = context.subdivision in
Subdivided_Evaluation.evaluate context valuation ~subdivnb expr
(* ------------------------------------------------------------------------ (* ------------------------------------------------------------------------
Backward Evaluation Backward Evaluation
......
...@@ -772,8 +772,7 @@ module Make ...@@ -772,8 +772,7 @@ module Make
in in
subdivide_subexpr vars valuation result alarms subdivide_subexpr vars valuation result alarms
let evaluate context valuation expr = let evaluate context valuation ~subdivnb expr =
let subdivnb = Value_parameters.LinearLevel.get () in
if subdivnb = 0 || not activated if subdivnb = 0 || not activated
then Eva.evaluate context valuation expr then Eva.evaluate context valuation expr
else subdivide_evaluation context valuation subdivnb expr else subdivide_evaluation context valuation subdivnb expr
......
...@@ -44,7 +44,8 @@ module Make ...@@ -44,7 +44,8 @@ module Make
: sig : sig
val evaluate: val evaluate:
Eva.context -> Valuation.t -> exp -> (Valuation.t * Value.t) evaluated Eva.context -> Valuation.t -> subdivnb:int ->
exp -> (Valuation.t * Value.t) evaluated
val reduce_by_enumeration: val reduce_by_enumeration:
Eva.context -> Valuation.t -> exp -> bool -> Valuation.t or_bottom Eva.context -> Valuation.t -> exp -> bool -> Valuation.t or_bottom
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment