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

Smt changes #70

Merged
merged 101 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
b230794
Replaced test/fast/smt_tests bu unit/ and bugs/
Nov 15, 2022
07f71e4
Made hyp_hint available
Nov 15, 2022
7724ee3
Facts may be named and marked as axioms, hyps,...
Nov 15, 2022
e8c54bc
SMT-LIB patterns
Nov 15, 2022
bbf5f1f
Made ssnoc and app_hyps from Expr.Subst visible
Nov 15, 2022
557bb55
New expression visitors: foldmap and fold
Nov 15, 2022
88a71ae
Option.fold
Nov 15, 2022
291ce04
Sets and Maps of integers
Nov 15, 2022
f93c594
builtin_to_string
Nov 15, 2022
1d7f8ee
Expr.Collect for computing sets of free variables
Nov 15, 2022
289a573
Fixed a bug in smt.ml that made verbosity ignored
Nov 15, 2022
30fed8c
Display obligation number in isabelle output
Nov 15, 2022
2480ac7
Package Type: type system utilities
Nov 15, 2022
b39335b
Package Encode: new SMT and TPTP encoding
Nov 15, 2022
8b13372
New translation to SMT-LIB
Nov 15, 2022
3842f53
New translation to TPTP + Support Zipperposition
Nov 15, 2022
3f08478
FIXUP: SMT translation
Nov 15, 2022
81695a3
Improved obligation display in temp files
Nov 16, 2022
7caaa98
Heuristics for set extensionality (SMT)
Jan 5, 2023
39a981d
Mode "ext" for SMT is default
Jan 10, 2023
8450a8c
Compare all pairs of refinement sets (heuristics)
Jan 10, 2023
7a1f96a
Use flag --smt-logic for new SMT encoding
Jan 17, 2023
0bdb217
Use CVC4 for one regression test
Jan 20, 2023
a97d4f9
Update src/util/util.ml
Mar 24, 2023
c10b19d
Update src/type/t_visit.mlt
Mar 24, 2023
0e323ce
Update src/type/t_visit.mli
Mar 24, 2023
194f684
Update src/encode/n_axioms.ml
Mar 24, 2023
b887a09
Update src/type/t_t.ml
Mar 24, 2023
9835c02
Update src/encode/n_axioms.ml
Mar 24, 2023
d02264d
Update src/encode/n_axioms.mli
Mar 24, 2023
ddfb7a0
Update src/encode/n_axioms.mlt
Mar 24, 2023
e0f2cb5
Update src/type/t_visit.ml
Mar 24, 2023
c38dfea
Update src/type/t_t.mlt
Mar 24, 2023
68e0be8
Update src/type/t_t.mli
Mar 24, 2023
dbfee1b
Update src/type/t_t.mli
Mar 24, 2023
6b92292
Update src/type/t_t.ml
Mar 24, 2023
162ccd6
Update src/type/t_t.ml
Mar 24, 2023
0574dca
Update src/type/t_synth.mlt
Mar 24, 2023
13ca6b7
Update src/type/t_synth.mli
Mar 24, 2023
7590d73
Update src/type/t_synth.ml
Mar 24, 2023
ad5bdd8
Update src/backend/smtlib.ml
Mar 24, 2023
3bdf983
Update src/backend/smtlib.ml
Mar 24, 2023
99958b0
Update src/backend/smtlib.ml
Mar 24, 2023
ee43771
Update src/backend/smtlib.ml
Mar 24, 2023
1bf5947
Update src/backend/smtlib.mli
Mar 24, 2023
946976b
Update src/backend/smtlib.mlt
Mar 24, 2023
9c9e87a
Update src/type.mlt
Mar 24, 2023
25a88a3
Update src/backend/thf.ml
Mar 24, 2023
6def4dc
Update src/backend/thf.mli
Mar 24, 2023
56c9fd2
Update src/backend/thf.mlt
Mar 24, 2023
f3403e9
Update src/encode.ml
Mar 24, 2023
cf20454
Update src/encode.mli
Mar 24, 2023
76b253a
Update src/encode.mlt
Mar 24, 2023
f791c16
Update src/encode/n_axiomatize.ml
Mar 24, 2023
77ed9c2
Update src/encode/n_axiomatize.mlt
Mar 24, 2023
fd4ffbd
Update src/type/t_hyps.mlt
Mar 24, 2023
14395c0
Update src/type/t_collect.mlt
Mar 24, 2023
25b41fd
Really disable option ext by default
Jan 25, 2023
20a4949
Update (first corrections)
Mar 24, 2023
0c32478
Update: copyright dates
Mar 24, 2023
ad0dd83
Update: Two missing axioms
Apr 20, 2023
189902d
Fix: typing of the remainder for SMT
Apr 25, 2023
663ab4b
Some missing axioms/triggers
May 11, 2023
6fad153
Update src/encode/n_flatten.ml
Aug 9, 2023
71ac023
Merge remote-tracking branch 'origin/smt-changes' into smt-changes
Aug 9, 2023
bac315e
Update src/encode/n_rewrite.ml
Aug 9, 2023
1391208
Update src/encode/n_hints.ml
Aug 9, 2023
2232105
Update src/encode/n_hints.ml
Aug 9, 2023
29324d2
Update src/encode/n_rewrite.ml
Aug 9, 2023
0e2eb5c
Update src/encode/n_rewrite.ml
Aug 9, 2023
b58de26
Merge remote-tracking branch 'origin/smt-changes' into smt-changes
Aug 9, 2023
e9d55ab
Some fixes
Aug 9, 2023
70c8eed
Update src/encode/n_axioms.ml
rozlynd Jan 24, 2024
6727f33
Update src/encode/n_data.ml
rozlynd Jan 24, 2024
af76167
Update src/encode/n_data.ml
rozlynd Jan 24, 2024
0a450ad
Update src/encode/n_data.ml
rozlynd Jan 24, 2024
4cf25fc
Update src/type/t_synth.ml
rozlynd Jan 24, 2024
25fdb66
Update src/type/t_synth.ml
rozlynd Jan 24, 2024
3a4c947
Update src/type/t_synth.ml
rozlynd Jan 24, 2024
b5b1a89
Update src/type/t_synth.ml
rozlynd Jan 24, 2024
e1bcb89
Update src/type/t_synth.ml
rozlynd Jan 24, 2024
e0ce4e6
fix laziness
damiendoligez Jan 10, 2024
7c13511
Removed unused module Encode.Hints
rozlynd Nov 10, 2023
159f728
Fixed polarities in Encode.Rewriting
rozlynd Nov 10, 2023
7b76a69
Fix: And/Or lists with one member collapse
rozlynd Nov 24, 2023
54915f6
Clarification that tla_smb_desc is NOT injective
rozlynd Jan 24, 2024
2e2ee94
Fix: Infinity is not a real
rozlynd Jan 24, 2024
fdb9c09
Fix duplicate case in T.Synth
rozlynd Jan 24, 2024
93ca710
Use subclass of Subst.map insteadof duplicate code
rozlynd Jan 25, 2024
01e2e61
Factor special characters replacement in Thf/SMT
rozlynd Nov 10, 2023
198a64a
Fixed contradictory assert in Expr.Subst
rozlynd Jan 25, 2024
11922d8
Factored expansion of set extensionality fcn
rozlynd Jan 25, 2024
378fd47
Set equalities in negative contexts are unchanged
rozlynd Jan 25, 2024
ac759fa
Fixed/Rephrased some comments
rozlynd Jan 25, 2024
035c39d
Fixed exponentation symbol for SMT
rozlynd Jan 26, 2024
86ffa20
Removed global use of debug flags in encode/
rozlynd Jan 26, 2024
f7c1d60
Merge branch 'main' into smt-changes
rozlynd Jan 31, 2024
5f5a285
Change `Pervasives` to `Stdlib` to make the source compatible with OC…
damiendoligez Feb 7, 2024
783df0a
tweak proof in GFX_test.tla
damiendoligez Feb 13, 2024
4f43abb
display more details in case of a failed test
damiendoligez Feb 13, 2024
7a62b05
We don't ship CVC4 in our bundled provers, and nowadays Z3 can handle…
damiendoligez Feb 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 10 additions & 0 deletions library/TLAPS.tla
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ YicesT(X) == TRUE (*{ by (prover:"yices3"; timeout:@) }*)
veriT == TRUE (*{ by (prover: "verit") }*)
veriTT(X) == TRUE (*{ by (prover:"verit"; timeout:@) }*)

(**************************************************************************)
(* Backend pragma: Zipperposition solver *)
(* *)
(* This method translates the proof obligation to TPTP and *)
(* calls Zipperposition. *)
(**************************************************************************)

Zipper == TRUE (*{ by (prover: "zipper") }*)
ZipperT(X) == TRUE (*{ by (prover:"zipper"; timeout:@) }*)

(**************************************************************************)
(* Backend pragma: Z3 SMT solver *)
(* *)
Expand Down
2 changes: 1 addition & 1 deletion src/backend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ module Toolbox = Toolbox
module Zenon = Zenon
module Fingerprints = Fingerprints
module Fpfile = Fpfile
(* module Smtlib = Smtlib *)
module Smtlib = Smtlib
module Prep = Prep
5 changes: 5 additions & 0 deletions src/backend.mli
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,8 @@ module Toolbox: sig
val print_message_url:
string -> string -> unit
end


module Smtlib: sig
val repls: (char * string) list
end
12 changes: 11 additions & 1 deletion src/backend/fpfile.ml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ module V13 = struct
| Cvc33 of floatomega
| Yices3 of floatomega
| Verit of floatomega
| Zipper of floatomega
rozlynd marked this conversation as resolved.
Show resolved Hide resolved
| Spass of floatomega
| Tptp of floatomega
| LS4 of floatomega
Expand Down Expand Up @@ -126,7 +127,7 @@ module V13 = struct
- any number of (Digest.t, sti list) pairs
*)

let version = 13
let version = 14

end

Expand Down Expand Up @@ -229,6 +230,7 @@ and meth_to_Vx m =
| M.Cvc33 tmo -> Cvc33 (floatomega_to_Vx tmo)
| M.Yices3 tmo -> Yices3 (floatomega_to_Vx tmo)
| M.Verit tmo -> Verit (floatomega_to_Vx tmo)
| M.Zipper tmo -> Zipper (floatomega_to_Vx tmo)
| M.Spass tmo -> Spass (floatomega_to_Vx tmo)
| M.Tptp tmo -> Tptp (floatomega_to_Vx tmo)
| M.LS4 tmo -> LS4 (floatomega_to_Vx tmo)
Expand Down Expand Up @@ -269,6 +271,7 @@ type prover =
| Pcvc33
| Pyices3
| Pverit
| Pzipper
| Pspass
| Ptptp
| Pls4
Expand Down Expand Up @@ -299,6 +302,7 @@ let prover_of_method m =
| Cvc33 _ -> Pcvc33
| Yices3 _ -> Pyices3
| Verit _ -> Pverit
| Zipper _ -> Pzipper
| Spass _ -> Pspass
| Tptp _ -> Ptptp
| LS4 _ -> Pls4
Expand Down Expand Up @@ -328,6 +332,7 @@ let normalize m =
| Cvc33 (Omega) -> Cvc33 (F infinity)
| Yices3 (Omega) -> Yices3 (F infinity)
| Verit (Omega) -> Verit (F infinity)
| Zipper (Omega) -> Zipper (F infinity)
| Spass (Omega) -> Spass (F infinity)
| Tptp (Omega) -> Tptp (F infinity)
| LS4 (Omega) -> LS4 (F infinity)
Expand Down Expand Up @@ -723,6 +728,10 @@ let print_sti_13 (st, d, pv, zv, iv) =
printf "Verit (";
print_floatomega tmo;
printf ")";
| V13.Zipper tmo ->
printf "Zipper (";
print_floatomega tmo;
printf ")";
| V13.Spass tmo ->
printf "Spass (";
print_floatomega tmo;
Expand Down Expand Up @@ -927,6 +936,7 @@ and vx_to_meth m =
| Cvc33 tmo -> Some (M.Cvc33 (vx_to_floatomega tmo))
| Yices3 tmo -> Some (M.Yices3 (vx_to_floatomega tmo))
| Verit tmo -> Some (M.Verit (vx_to_floatomega tmo))
| Zipper tmo -> Some (M.Zipper (vx_to_floatomega tmo))
| Spass tmo -> Some (M.Spass (vx_to_floatomega tmo))
| Tptp tmo -> Some (M.Tptp (vx_to_floatomega tmo))
| LS4 tmo -> Some (M.LS4 (vx_to_floatomega tmo))
Expand Down
1 change: 1 addition & 0 deletions src/backend/isabelle.ml
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ let thy_temp ob tac tempname thyout =
thy_header ~verbose:false tempname thyout;
let obid = Option.get ob.id in
let obfp = Option.default "no fingerprint" ob.fingerprint in
Printf.fprintf thyout "(* Generated from %s *)\n" (Util.location ~cap:false ob.obl);
Printf.fprintf thyout "lemma ob'%d: (* %s *)\n" obid obfp;
let ff = Format.formatter_of_out_channel thyout in
begin try
Expand Down
89 changes: 79 additions & 10 deletions src/backend/prep.ml
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,58 @@ let isabelle_prove ob org_ob tmo tac res_cont =
Schedule.Immediate (res_cont w (Method.NotTried msg) None)


let zipper_unsat_re = Str.regexp "SZS status Theorem";;

let zipper_prove ob org_ob time res_cont =
let cleanup = ref (fun () -> ()) in
try
let (inf, inc, outf, outc) = mk_temps cleanup ".p" in
let zcmd =
Printf.sprintf "%s >%s" (Params.solve_cmd Params.zipper inf) outf
in
let in_text =
ignore (Format.flush_str_formatter ());
Thf.pp_print_obligation Format.str_formatter ob;
Format.flush_str_formatter ()
in
output_string inc in_text;
flush inc;
let warnings = Errors.get_warnings () in
let finished time_used =
let zinput =
let header = "\n(* BEGIN ZIPPERPOSITION INPUT\n" in
let footer = "\nEND ZIPPERPOSITION INPUT *)\n" in
Printf.sprintf "%s;; %s\n%s%s" header zcmd in_text footer
in
let result = Std.input_all outc in
!cleanup ();
let success =
try ignore (Str.search_forward zipper_unsat_re result 0); true
with Not_found -> false
in
if success then
res_cont warnings (Method.Proved (zinput ^ result)) time_used
else
let msg = "" in
res_cont warnings (Method.Failed msg) time_used
in
let done_cont = mk_donec finished cleanup res_cont warnings in
let timo = Printf.sprintf "(%g s)" time in
let
time_cont = mk_timec ob org_ob warnings time (Some "zipper", Some timo)
in
Schedule.Todo {
Schedule.line = zcmd;
Schedule.timeout = float_of_int !Params.wait;
Schedule.timec = time_cont;
Schedule.donec = done_cont;
}
with Failure msg ->
!cleanup ();
let w = Errors.get_warnings () in
Schedule.Immediate (res_cont w (Method.NotTried msg) None)
;;

(****************************************************************************)

let print_obligation ob =
Expand Down Expand Up @@ -361,13 +413,13 @@ let print_obl_and_msg


let pp_print_ob ?comm:(c=";;") chan ob =
output_string chan (Printf.sprintf "%s Proof obligation:\n%s" c c);
output_string chan (Printf.sprintf "%s Proof obligation:\n" c);
let ob_buf = Buffer.create 2000 in
let fmt = Format.formatter_of_buffer ob_buf in
Proof.Fmt.pp_print_obligation fmt ob;
Format.pp_print_flush fmt ();
let replace inp out = Str.global_replace (Str.regexp_string inp) out in
let ob_str = replace "\n" ("\n"^c^" ") (Buffer.contents ob_buf) in
let pat = Str.regexp "^" in
let ob_str = Str.global_replace pat (c ^ "\t") (Buffer.contents ob_buf) in
output_string chan ob_str;
output_string chan "\n"

Expand Down Expand Up @@ -442,38 +494,48 @@ let gen_smt_solve suffix exec desc fmt_expr meth ob org_ob f res_cont comm =
Schedule.Immediate (res_cont w (Method.NotTried msg) None)


(* FIXME Remove all the oldsmt code *)
let get_encode_smtlib () =
if Params.debugging "oldsmt" then Smt.encode_smtlib
else Smtlib.pp_print_obligation

(* FIXME *)
let get_encode_fof () =
if Params.debugging "oldsmt" then Smt.encode_fof
else Smtlib.pp_print_obligation ~solver:"fof"

let smt_solve ob org_ob f res_cont =
gen_smt_solve ".smt" Params.smt "default SMT solver" Smt.encode_smtlib
gen_smt_solve ".smt" Params.smt "default SMT solver" (get_encode_smtlib ())
(Method.Smt3 f) ob org_ob f res_cont ";;"


let cvc3_solve ob org_ob f res_cont =
gen_smt_solve ".smt" Params.cvc4 "CVC4" Smt.encode_smtlib
gen_smt_solve ".smt" Params.cvc4 "CVC4" (get_encode_smtlib () ~solver:"CVC4")
(Method.Cvc33 f) ob org_ob f res_cont ";;"


let yices_solve ob org_ob f res_cont =
gen_smt_solve ".ys" Params.yices "Yices" Smt.encode_smtlib
gen_smt_solve ".ys" Params.yices "Yices" (get_encode_smtlib ())
(Method.Yices3 f) ob org_ob f res_cont ";;"


let z3_solve ob org_ob f res_cont =
gen_smt_solve ".smt2" Params.z3 "Z3" (Smt.encode_smtlib ~solver:"Z3")
gen_smt_solve ".smt2" Params.z3 "Z3" ((get_encode_smtlib ()) ~solver:"Z3")
(Method.Z33 f) ob org_ob f res_cont ";;"


let verit_solve ob org_ob f res_cont =
gen_smt_solve ".smt2" Params.verit "veriT" Smt.encode_smtlib
gen_smt_solve ".smt2" Params.verit "veriT" (get_encode_smtlib () ~solver:"veriT")
(Method.Verit f) ob org_ob f res_cont ";;"


let spass_solve ob org_ob f res_cont =
gen_smt_solve ".tptp" Params.spass_tptp "Spass" Smt.encode_fof
gen_smt_solve ".tptp" Params.spass_tptp "Spass" (get_encode_fof ())
(Method.Spass f) ob org_ob f res_cont "%%"


let tptp_solve ob org_ob f res_cont =
gen_smt_solve ".tptp" Params.eprover "Tptp" Smt.encode_fof
gen_smt_solve ".tptp" Params.eprover "Tptp" (get_encode_fof ())
(Method.Tptp f) ob org_ob f res_cont "% "


Expand Down Expand Up @@ -571,6 +633,7 @@ let get_prover_name m =
| Method.Cvc33 _ -> "CVC33"
| Method.Yices3 _ -> "Yices3"
| Method.Verit _ -> "Verit"
| Method.Zipper _ -> "Zipperposition"
| Method.Spass _ -> "Spass"
| Method.Tptp _ -> "TPTP"
| Method.ExpandENABLED -> "ExpandENABLED"
Expand Down Expand Up @@ -733,6 +796,9 @@ let prove_with ob org_ob meth save = (* FIXME add success fuction *)
| Method.Verit f ->
vprintf "(* ... using Verit *)\n" ;
verit_solve ob org_ob f res_cont
| Method.Zipper f ->
vprintf "(* ... using Zipperposition *)\n" ;
zipper_prove ob org_ob f res_cont
| Method.Spass f ->
vprintf "(* ... using Spass *)\n" ;
spass_solve ob org_ob f res_cont
Expand Down Expand Up @@ -1167,6 +1233,9 @@ let compute_meth def args usept =
| Some "verit" ->
let tmo = Option.default Method.default_smt2_timeout !timeout in
Method.Verit tmo
| Some "zipper" ->
let tmo = Option.default Method.default_zipper_timeout !timeout in
Method.Zipper tmo
| Some "spass" ->
let tmo = Option.default Method.default_spass_timeout !timeout in
Method.Spass tmo
Expand Down
16 changes: 8 additions & 8 deletions src/backend/smt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -720,14 +720,6 @@ let reset () =
Smt.ctr := 0;
E.ctr_types := 0;
T.ctr_funarg := 0;
Smt.typesystem_mode := begin
if Params.debugging "notypes" then 0 (** Untyped *)
else if Params.debugging "types0" then 0 (** Untyped *)
else if Params.debugging "types1" then 1 (** Elementary type system *)
else if Params.debugging "types2" then 2 (** Refinement type system *)
else 1
end;
Smt.ifprint 1 "** Type system mode = %d" !Smt.typesystem_mode;
Smt.verbosity := begin
if Params.debugging "verbose0" then 0
else if Params.debugging "verbose1" then 1
Expand All @@ -736,6 +728,14 @@ let reset () =
else if Params.debugging "verbose4" then 4
else 0
end;
Smt.typesystem_mode := begin
if Params.debugging "notypes" then 0 (** Untyped *)
else if Params.debugging "types0" then 0 (** Untyped *)
else if Params.debugging "types1" then 1 (** Elementary type system *)
else if Params.debugging "types2" then 2 (** Refinement type system *)
else 1
end;
Smt.ifprint 1 "** Type system mode = %d" !Smt.typesystem_mode;
abstract_func := begin
if Params.debugging "abstract1" then Preprocess.abstract
else if Params.debugging "abstract2" then Preprocess.abstract2
Expand Down
Loading
Loading