Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring models representation #925

Merged
merged 48 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
f9df34d
Refactoring model
Halbaroth Sep 12, 2023
56f52b9
Creating a module for identifiers
Halbaroth Nov 6, 2023
eaac1df
Clean-up printers
Halbaroth Nov 6, 2023
af9bb98
Reset the cache at the start of generation model
Halbaroth Nov 6, 2023
3ffc4d5
Produce an abstract value for abstract type.
Halbaroth Nov 6, 2023
8792459
Restoring record model generation
Halbaroth Nov 7, 2023
5c68b22
Print the same abstract value of equal semantic values.
Halbaroth Nov 7, 2023
b7fc10b
Prefix unused arguments of model values
Halbaroth Nov 8, 2023
e4c30c3
Restoring objectives in interpretation
Halbaroth Nov 8, 2023
74188e5
Restoring assertion mode for models and clean-up
Halbaroth Nov 8, 2023
5112b25
Use `Seq.is_empty` from `stdcompat`
Halbaroth Nov 8, 2023
b70d5ad
Cleanup and a bit of documentation
Halbaroth Nov 8, 2023
76e6cbe
Promote tests
Halbaroth Nov 8, 2023
0a0351f
Linter
Halbaroth Nov 8, 2023
085544d
Update src/lib/structures/modelMap.ml
Halbaroth Nov 9, 2023
03e13d3
Update src/lib/util/util.mli
Halbaroth Nov 9, 2023
405adf6
Update src/lib/reasoners/uf.ml
Halbaroth Nov 9, 2023
5f0be39
Update src/lib/reasoners/uf.ml
Halbaroth Nov 9, 2023
2feb283
Review changes
Halbaroth Nov 9, 2023
128a212
Unused argument in the test
Halbaroth Nov 9, 2023
0e33875
Promote tests
Halbaroth Nov 9, 2023
f359bba
Models for functions returning records
Halbaroth Nov 9, 2023
24111ab
Improve the type of `ModelMap.Value`
Halbaroth Nov 10, 2023
7955722
Change review
Halbaroth Nov 13, 2023
d5e9152
rebase artefact
Halbaroth Nov 30, 2023
e12e184
Use `Expr.t` to store model values
Halbaroth Dec 4, 2023
c050998
Poetry
Halbaroth Dec 6, 2023
9e71065
Hide the caches in the closure of `compute_concrete_model`
Halbaroth Dec 6, 2023
ca9d11c
Fix `to_const_term` in BV theory
Halbaroth Dec 7, 2023
c3ea720
Documentation in UF and fix BV symbols
Halbaroth Dec 7, 2023
a553e60
Documentation of the type sy
Halbaroth Dec 7, 2023
1bbb92a
documentation
Halbaroth Dec 7, 2023
aa398cf
restoring the constraint printer
Halbaroth Dec 7, 2023
6c6caab
Incorrect `is_internal` predicate
Halbaroth Dec 8, 2023
c8fa336
Simpler `to_const_term` in BV theory
Halbaroth Dec 8, 2023
a484906
rename `terms_values` to `term_values`
Halbaroth Dec 11, 2023
7dd8a1c
rebase artefact in models.ml
Halbaroth Dec 11, 2023
eb44271
Use Dolmen to quote identifiers
Halbaroth Dec 11, 2023
e13e2fb
Rename `is_const_term` to `is_model_term`
Halbaroth Dec 11, 2023
b418963
Remove brackets in `ArrayEx.select`
Halbaroth Dec 11, 2023
37e1038
Clarify `X.is_constant` implementation
Halbaroth Dec 11, 2023
8317514
Simplify `model_repr_of_term`
Halbaroth Dec 11, 2023
161e126
Rename `to_const_term` to `to_model_term`
Halbaroth Dec 11, 2023
3f27b6f
Only use `Expr.t` to store model values
Halbaroth Dec 11, 2023
16007ee
Remove warning message for models in presence of FPA symbols
Halbaroth Dec 12, 2023
392cb61
bvor, bvand and bvxor aren't suspicious anymore
Halbaroth Dec 19, 2023
2e12636
prefix model error
Halbaroth Dec 19, 2023
945adc2
Poetry
Halbaroth Dec 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions alt-ergo-lib.opam
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ depends: [
"fmt" {>= "0.9.0"}
"stdlib-shims"
"ppx_blob" {>= "0.7.2"}
"ppx_deriving"
"camlzip" {>= "1.07"}
"odoc" {with-doc}
"ppx_deriving"
Expand Down
1 change: 1 addition & 0 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ See more details on http://alt-ergo.ocamlpro.com/"
(fmt (>= 0.9.0))
stdlib-shims
(ppx_blob (>= 0.7.2))
ppx_deriving
(camlzip (>= 1.07))
(odoc :with-doc)
ppx_deriving
Expand Down
9 changes: 6 additions & 3 deletions src/bin/common/solving_loop.ml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ let main () =
begin
let mdl = Model ((module SAT), partial_model) in
if Options.(get_interpretation () && get_dump_models ()) then begin
FE.print_model (Options.Output.get_fmt_models ()) partial_model
Fmt.pf (Options.Output.get_fmt_models ()) "%a@."
FE.print_model partial_model
end;
Sat mdl
end
Expand All @@ -193,7 +194,8 @@ let main () =
Printer.print_fmt (Options.Output.get_fmt_diagnostic ())
"@[<v 0>Returned unknown reason = %a@]"
Sat_solver_sig.pp_ae_unknown_reason_opt ur;
FE.print_model (Options.Output.get_fmt_models ()) partial_model
Fmt.pf (Options.Output.get_fmt_models ()) "%a@."
FE.print_model partial_model
end;
Unknown (Some mdl)
end
Expand Down Expand Up @@ -927,7 +929,8 @@ let main () =
let () = match State.get partial_model_key st with
| Some (Model ((module SAT), env)) ->
let module FE = Frontend.Make (SAT) in
FE.print_model (Options.Output.get_fmt_regular ()) env
Fmt.pf (Options.Output.get_fmt_regular ()) "%a@."
FE.print_model env
| None ->
(* TODO: add the location of the statement. *)
recoverable_error "No model produced."
Expand Down
2 changes: 1 addition & 1 deletion src/lib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
; structures
Commands Errors Explanation Fpa_rounding
Parsed Profiling Satml_types Symbols
Expr Var Ty Typed Xliteral ModelMap Objective
Expr Var Ty Typed Xliteral ModelMap Id Objective
; util
Emap Gc_debug Hconsing Hstring Heap Lists Loc
MyUnix Numbers
Expand Down
40 changes: 20 additions & 20 deletions src/lib/frontend/d_cnf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ module SM = Sy.Map

module DE = DStd.Expr
module DT = DE.Ty
module Id = DStd.Id
module B = DStd.Builtin

let unsupported msg =
Expand Down Expand Up @@ -194,7 +193,7 @@ let builtin_term t = Dl.Typer.T.builtin_term t
let builtin_ty t = Dl.Typer.T.builtin_ty t

let ty name ty =
Id.Map.add { name = DStd.Name.simple name; ns = Sort } @@
DStd.Id.Map.add { name = DStd.Name.simple name; ns = Sort } @@
fun env s ->
builtin_ty @@
Dolmen_type.Base.app0 (module Dl.Typer.T) env s ty
Expand All @@ -214,10 +213,11 @@ let builtin_enum = function
let add_cstrs map =
List.fold_left (fun map ((c : DE.term_cst), _) ->
let name = get_basename c.path in
Id.Map.add { name = DStd.Name.simple name; ns = Term } (fun env _ ->
builtin_term @@
Dolmen_type.Base.term_app_cst
(module Dl.Typer.T) env c) map)
DStd.Id.Map.add { name = DStd.Name.simple name; ns = Term }
(fun env _ ->
builtin_term @@
Dolmen_type.Base.term_app_cst
(module Dl.Typer.T) env c) map)
map cstrs
in
Cache.store_ty (DE.Ty.Const.hash ty_cst) ty_;
Expand All @@ -238,19 +238,19 @@ module Const = struct
let bv2nat =
with_cache (fun n ->
let name = "bv2nat" in
Id.mk ~name ~builtin:(BV2Nat n)
DE.Id.mk ~name ~builtin:(BV2Nat n)
(DStd.Path.global name) Ty.(arrow [bitv n] int))

let int2bv =
with_cache (fun n ->
let name = "int2bv" in
Id.mk ~name ~builtin:(Int2BV n)
DE.Id.mk ~name ~builtin:(Int2BV n)
(DStd.Path.global name) Ty.(arrow [int] (bitv n)))

let smt_round =
with_cache (fun (n, m) ->
let name = "ae.round" in
Id.mk
DE.Id.mk
~name
~builtin:(AERound (n, m))
(DStd.Path.global name)
Expand Down Expand Up @@ -299,7 +299,7 @@ let bv_builtins env s =
equivalent *)
let inject_ae_to_smt2 id =
match id with
| Id.{name = Simple n; _} ->
| DStd.Id.{name = Simple n; _} ->
begin
if String.equal n Fpa_rounding.fpa_rounding_mode_ae_type_name then
(* Injecting the type name as the SMT2 Type name. *)
Expand All @@ -322,15 +322,15 @@ let inject_ae_to_smt2 id =
let ae_fpa_builtins =
let (->.) args ret = (args, ret) in
let dterm name f =
Id.Map.add { name = DStd.Name.simple name; ns = Term } @@
DStd.Id.Map.add { name = DStd.Name.simple name; ns = Term } @@
fun env s ->
builtin_term @@
Dolmen_type.Base.term_app1 (module Dl.Typer.T) env s f
in
let op ?(tyvars = []) name builtin (args, ret) =
let ty = DT.pi tyvars @@ DT.arrow args ret in
let cst = DE.Id.mk ~name ~builtin (DStd.Path.global name) ty in
Id.Map.add { name = DStd.Name.simple name; ns = Term } @@
DStd.Id.Map.add { name = DStd.Name.simple name; ns = Term } @@
fun env _ ->
builtin_term @@
Dolmen_type.Base.term_app_cst
Expand Down Expand Up @@ -358,13 +358,13 @@ let ae_fpa_builtins =
let float64 = float (DE.Term.int "53") (DE.Term.int "1074") in
let float64d x = float64 (mode "NearestTiesToEven") x in
let partial1 name f =
Id.Map.add { name = DStd.Name.simple name; ns = Term } @@
DStd.Id.Map.add { name = DStd.Name.simple name; ns = Term } @@
fun env s ->
builtin_term @@
Dolmen_type.Base.term_app1 (module Dl.Typer.T) env s f
in
let partial2 name f =
Id.Map.add { name = DStd.Name.simple name; ns = Term } @@
DStd.Id.Map.add { name = DStd.Name.simple name; ns = Term } @@
fun env s ->
builtin_term @@
Dolmen_type.Base.term_app2 (module Dl.Typer.T) env s f
Expand All @@ -380,7 +380,7 @@ let ae_fpa_builtins =
in
let fpa_builtins =
let open DT in
Id.Map.empty
DStd.Id.Map.empty

|> add_rounding_modes

Expand Down Expand Up @@ -454,7 +454,7 @@ let ae_fpa_builtins =
fun env s ->
let search_id id =
try
Id.Map.find_exn id fpa_builtins env s
DStd.Id.Map.find_exn id fpa_builtins env s
with Not_found -> `Not_found
in
match s with
Expand All @@ -469,7 +469,7 @@ let smt_fpa_builtins =
Dolmen_type.Base.term_app2 (module Dl.Typer.T) env s f
in
let other_builtins =
Id.Map.empty
DStd.Id.Map.empty
|> add_rounding_modes
in
fun env s ->
Expand All @@ -487,7 +487,7 @@ let smt_fpa_builtins =
| exception Failure _ -> `Not_found
end
| Dl.Typer.T.Id id -> begin
match Id.Map.find_exn id other_builtins env s with
match DStd.Id.Map.find_exn id other_builtins env s with
| e -> e
| exception Not_found -> `Not_found
end
Expand Down Expand Up @@ -1876,7 +1876,7 @@ let make dloc_file acc stmt =
let ns = DStd.Namespace.Decl in
let name = Ty.fresh_hypothesis_name goal_sort in
let decl: _ Typer_Pipe.stmt = {
id = Id.mk ns name;
id = DStd.Id.mk ns name;
contents = `Hyp t; loc; attrs; implicit
}
in
Expand All @@ -1893,7 +1893,7 @@ let make dloc_file acc stmt =
assert false

(* Axiom definitions *)
| { id = Id.{name = Simple name; _}; contents = `Hyp t; loc; attrs;
| { id = DStd.Id.{name = Simple name; _}; contents = `Hyp t; loc; attrs;
implicit=_ } ->
let dloc = DStd.Loc.(loc dloc_file stmt.loc) in
let aloc = DStd.Loc.lexing_positions dloc in
Expand Down
2 changes: 1 addition & 1 deletion src/lib/frontend/frontend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -520,5 +520,5 @@ module Make(SAT : Sat_solver_sig.S) : S with type sat_env = SAT.t = struct
Sat_solver_sig.pp_ae_unknown_reason_opt ur;

| Some model ->
Models.output_concrete_model ppf model
Models.pp ppf model
end
Loading
Loading