Skip to content

Commit

Permalink
remove some obviously quadratic list concatenations in SMTEncoding.En…
Browse files Browse the repository at this point in the history
…code
  • Loading branch information
nikswamy committed Oct 16, 2024
1 parent 09f51ec commit 738fbc0
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 43 deletions.
82 changes: 43 additions & 39 deletions ocaml/fstar-lib/generated/FStarC_SMTEncoding_Encode.ml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions src/smtencoding/FStarC.SMTEncoding.Encode.fst
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ let prims =
let app = mk_Apply app [var] in
let vars = vars @ [var] in
let axiom_name = axiom_name ^ "." ^ (string_of_int (vars |> List.length)) in
axioms @ [Util.mkAssume (mkForall rng ([[app]], vars, mk_IsTotFun app), None, axiom_name)],
Util.mkAssume (mkForall rng ([[app]], vars, mk_IsTotFun app), None, axiom_name) :: axioms,
app,
vars
) ([tot_fun_axiom_for_x], xtok, []) all_vars_but_one
in
axioms
List.rev axioms
in

let rel_body =
Expand Down Expand Up @@ -598,9 +598,12 @@ let encode_top_level_val uninterpreted env us fv t quals =
else decls, env

let encode_top_level_vals env bindings quals =
let decls, env =
bindings |> List.fold_left (fun (decls, env) lb ->
let decls', env = encode_top_level_val false env lb.lbunivs (BU.right lb.lbname) lb.lbtyp quals in
decls@decls', env) ([], env)
List.rev_append decls' decls, env) ([], env)
in
List.rev decls, env

exception Let_rec_unencodeable

Expand Down Expand Up @@ -1954,9 +1957,12 @@ let encode_modul tcenv modul =
then BU.print2 "+++++++++++Encoding externals for %s ... %s declarations\n" name (List.length modul.declarations |> string_of_int);
let env = get_env modul.name tcenv |> reset_current_module_fvbs in
let encode_signature (env:env_t) (ses:sigelts) =
let g', env =
ses |> List.fold_left (fun (g, env) se ->
let g', env = encode_top_level_facts env se in
g@g', env) ([], env)
List.rev_append g' g, env) ([], env)
in
List.rev g', env
in
let decls, env = encode_signature ({env with warn=false}) modul.declarations in
give_decls_to_z3_and_set_env env name decls;
Expand Down

1 comment on commit 738fbc0

@mtzguido
Copy link
Member

@mtzguido mtzguido commented on 738fbc0 Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to mention this yesterday but we could consider switching to this: https://github.com/FStarLang/FStar/blob/master/src/data/FStarC.Compiler.CList.fsti

Please sign in to comment.