Skip to content

Commit 04123cc

Browse files
committed
update for Isabelle2025.
1 parent 43bd4e2 commit 04123cc

File tree

5 files changed

+48
-52
lines changed

5 files changed

+48
-52
lines changed

Abduction/Abduction.thy

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,7 @@ val long_keyword =
9090
val long_statement =
9191
Scan.optional (Parse_Spec.opt_thm_name ":" --| Scan.ahead long_keyword) Binding.empty_atts --
9292
Scan.optional Parse_Spec.includes [] -- Parse_Spec.long_statement
93-
>> (fn ((binding, includes), (elems, concl)) => (true, binding, includes, elems, concl))
94-
: Token.T list ->
95-
(bool * Attrib.binding * (xstring * Position.T) list *
96-
Element.context list * Element.statement)
97-
*
98-
Token.T list;
93+
>> (fn ((binding, includes), (elems, concl)) => (true, binding, includes, elems, concl));
9994
10095
val short_statement =
10196
Parse_Spec.statement -- Parse_Spec.if_statement -- Parse.for_fixes

PSL/Subtool.ML

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fun nontac (timeout:real) (state:Proof.state) =
4343
fun trace_cexm _ = show_trace "Quickcheck.quickcheck found a counterexample";
4444
fun trace_scexn _ = show_trace ("Quickcheck.quickcheck found a potentially spurious " ^
4545
"counterexample due to underspecified functions");
46-
fun trace_to to = show_trace ("Quickcheck timed out after " ^ Timeout.print to);
46+
fun trace_to to = show_trace ("Quickcheck timed out after " ^ Timeout.message to);
4747
val timeout = Isabelle_Utils.timeout_apply (seconds timeout);
4848
fun get_result _ = (case timeout (quickcheck [] 1) state of
4949
NONE => (trace_no_cexm (); single)
@@ -69,7 +69,7 @@ fun state_stttac (timeout:real) (state:Proof.state) (log:Dynamic_Utils.log) =
6969
val timeout = Isabelle_Utils.timeout_apply (seconds timeout);
7070
val do_trace = false;
7171
fun show_trace text = if do_trace then tracing text else ();
72-
fun trace_to to = show_trace ("Nitpick timed out after " ^ Timeout.print to);
72+
fun trace_to to = show_trace ("Nitpick timed out after " ^ Timeout.message to);
7373
fun nitpick_result' _ = Nitpick.pick_nits_in_subgoal state params Nitpick.Normal 1 1;
7474
val nitpick_result = timeout nitpick_result' () handle Timeout.TIMEOUT to => (trace_to to; ("timeout", []));
7575
(*"genuine" means "genuine counter-example".*)
@@ -198,13 +198,13 @@ fun hammer_logtac (timeout:real) (pstate:Proof.state): (Dynamic_Utils.log * Proo
198198
fun did_smt_timeout (out::timed::_) = (Utils.are_same ("out)", out)) andalso
199199
(Utils.are_same ("timed", timed))
200200
| did_smt_timeout _ = error "Something went wrong in Subtool.ML";
201-
val one_line_apply = orig_string <$> space_explode " "
201+
val one_line_apply = orig_string <$> Isabelle_Utils.YXML_content_of <$> space_explode " "
202202
<$> drop 2 (* drop "Try this:"*)
203203
<$> rev <$> (fn tokens =>
204204
if did_smt_timeout tokens then drop 5 tokens else drop 2 tokens)
205205
<$> rev (* drop "(0.1 ms)." and such.*)
206206
<$> String.concatWith " " : string option;
207-
val apply_script_cntnt = omap YXML.content_of one_line_apply : string option;
207+
val apply_script_cntnt = omap Isabelle_Utils.YXML_content_of one_line_apply : string option;
208208
val sh_returned = if is_some apply_script_cntnt
209209
then valOf result |> fst else false : bool;
210210
in

README.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
# Note on Isabelle2024 and its Sledgehammer
2-
This repository has been updated to Isabelle2024. However, we have received reports that the integration of Sledgehammer with this repository is now less stable under Isabelle2024. Therefore, although we have confirmed that the Abduction Prover works in some cases, its performance may currently be suboptimal. We are working to resolve this issue as quickly as possible. 🙇
3-
4-
For users seeking the best performance, we recommend using Isabelle2023 and [this version of the Abduction Prover (v0.2.7-alpha)](https://github.com/data61/PSL/releases/tag/v0.2.7-alpha), which was developed specifically for Isabelle2023."
5-
61
# News
7-
- We updated this repository to Isabelle2024.
2+
- We updated this repository to Isabelle2025.
83
- _NEW_: The introduction of **Abduction Prover**. You can watch a demo of Abduction Prover in [our YouTube channel](https://youtu.be/d7IXk0vB2p0).
94
- LiFtEr and Smart_Induct are no-longer supported, since their successors, SeLFiE and sem_ind, have shown superior performance.
105
- _PaMpeR is currently not supported either,_ since we want to minimise the cost necessary to maintain this repository.
@@ -15,7 +10,7 @@ For users seeking the best performance, we recommend using Isabelle2023 and [thi
1510

1611
This repository contains various tools to support interactive theorem proving in Isabelle/HOL using artificial intelligence.
1712
This repository contains the implementation of *proof strategy language (PSL)* and its default strategy,
18-
**try_hard**, for [Isabelle2024](https://isabelle.in.tum.de). Past versions of Isabelle, such as Isabelle2022-1, are no longer supported.
13+
**try_hard**, for [Isabelle2025](https://isabelle.in.tum.de). Past versions of Isabelle, such as Isabelle2022-1, are no longer supported.
1914

2015
## YouTube
2116

@@ -25,19 +20,19 @@ We opened [a YouTube channel](https://www.youtube.com/channel/UCjnY6hIaryOEgG92u
2520

2621

2722
## Installation (of SeLFiE, PSL, and sem_ind in one go) (for MacOS/Lunux users)
28-
1. Install [Isabelle2024](https://isabelle.in.tum.de).
23+
1. Install [Isabelle2025](https://isabelle.in.tum.de).
2924
2. Download or clone this repository (git clone https://github.com/data61/PSL.git).
3025
3. Open Isabelle/jEdit with PSL and all that. You can do this by opening Isabelle/jEdit as following:
3126
* `(path to the Isabelle binary)isabelle jedit -d (path to the directory that contains this README file) -l Smart_Isabelle`
3227
* If you are a MacOS user and your current directory is this one with this README.md, probably you should type something like this in Terminal:
33-
* `/Applications/Isabelle2024.app/bin/isabelle jedit -d . -l Smart_Isabelle`
28+
* `/Applications/Isabelle2025.app/bin/isabelle jedit -d . -l Smart_Isabelle`
3429
4. Then, You can use SeLFiE/PSL/sem_ind to your theory files
3530
with the Isabelle keyword, **imports** as ``imports "Smart_Isabelle.Smart_Isabelle"``.
3631
5. Open `Example/Example.thy` to see if the installation is successful.
3732

3833
### Note on installation for Windows users
3934
The basic steps are the same as MacOS and Linux.
40-
However, instead of using the binary file directly, use `Isabelle2024\Cygwin-Terminal` in Command Prompt. Once you start `Isabelle2024\Cygwin-Terminal`, you can install our tools by typing `isabelle jedit -d (path to the directory that contains this README file) -l Smart_Isabelle`. Note that once you started `Isabelle2024\Cygwin-Terminal`, you should not specify the path to the Isabelle binary file. Therefore, the command you need after starting `Isabelle2024\Cygwin-Terminal` is something like `isabelle jedit -d . -l Smart_Isabelle`, assuming that your current directory is this one with this README.md/
35+
However, instead of using the binary file directly, use `Isabelle2025\Cygwin-Terminal` in Command Prompt. Once you start `Isabelle2025\Cygwin-Terminal`, you can install our tools by typing `isabelle jedit -d (path to the directory that contains this README file) -l Smart_Isabelle`. Note that once you started `Isabelle2025\Cygwin-Terminal`, you should not specify the path to the Isabelle binary file. Therefore, the command you need after starting `Isabelle2025\Cygwin-Terminal` is something like `isabelle jedit -d . -l Smart_Isabelle`, assuming that your current directory is this one with this README.md/
4136

4237
![Screenshot](./image/screen_shot_import.png)
4338

SeLFiE/Util.ML

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ sig
488488
val strip_atyp : term -> term;
489489
val takes_n_arguments : term -> int -> bool;
490490
val read_term_then_check_term : Proof.context -> string -> (term -> bool) -> bool;
491+
val YXML_content_of : string -> string;
491492
end;
492493

493494
(*** Isabelle_Utils : Utility functions specific to Isabelle/HOL. ***)
@@ -707,7 +708,7 @@ fun is_in_Main (ctxt:Proof.context) (thm:thm) =
707708
val thy_names_in_main = Context.get_theory {long=false} this_thy "Main"
708709
|> Theory.ancestors_of
709710
|> map (Context.theory_name {long=true}):strings;
710-
fun get_theory_name (thm:thm) = thm |> Thm.get_name_hint |> fst_qualifier;
711+
fun get_theory_name (thm:thm) = thm |> Thm.get_name_hint |> Thm_Name.short |> fst_qualifier;
711712
val thy_name = get_theory_name thm;
712713
val result = exists (equal thy_name) thy_names_in_main;
713714
in
@@ -926,14 +927,18 @@ fun normalize_trm_as_string (ctxt:Proof.context) (trm_as_string:string) =
926927
Syntax.read_term ctxt trm_as_string |> trm_to_string ctxt: string;
927928

928929
(*This contract_abbrevs is a modified version of contract_abbrevs in Pure/Isar/proof_context.ML.*)
929-
fun contract_abbrevs (ctxt:Proof.context) (t:term) =
930+
fun contract_abbrevs ctxt tm =
930931
let
931-
val thy = Proof_Context.theory_of ctxt;
932-
val consts = Proof_Context.consts_of ctxt;
933-
val retrieve = Consts.retrieve_abbrevs consts (print_mode_value () @ [""]);
934-
fun match_abbrev u = Option.map #1 (get_first (Pattern.match_rew thy u) (retrieve u));
932+
val thy = Proof_Context.theory_of ctxt;
933+
val consts = Proof_Context.consts_of ctxt;
934+
val inst = #1 (Variable.import_inst true [tm] ctxt);
935+
val nets = Consts.revert_abbrevs consts (print_mode_value () @ [""]);
936+
val rew = Option.map #1 oo Pattern.match_rew thy;
937+
fun match_abbrev t = get_first (fn net => get_first (rew t) (Item_Net.retrieve net t)) nets;
935938
in
936-
Pattern.rewrite_term_top thy [] [match_abbrev] t
939+
Term_Subst.instantiate inst tm
940+
|> Pattern.rewrite_term_yoyo thy [] [match_abbrev]
941+
|> Term_Subst.instantiate_frees (Variable.import_inst_revert inst)
937942
end;
938943

939944
val strip_atyp = Term.map_types (map_atyps (K dummyT)): term -> term;
@@ -945,6 +950,8 @@ fun read_term_then_check_term (ctxt:Proof.context) (print:string) (checker: term
945950
<$> checker
946951
|> Utils.is_some_true
947952

953+
val YXML_content_of = YXML.parse_body #> XML.content_of;
954+
948955
end;
949956

950957
(*** FIND_THEOREMS2: provides an interface of find_theorem for PSL. ***)
@@ -956,8 +963,7 @@ signature FIND_THEOREMS2 =
956963
sig
957964
include FIND_THEOREMS;
958965
type context;
959-
type ref;
960-
type get_rules = context -> thm -> (ref * thm) list;
966+
type get_rules = context -> thm -> (string * thm) list;
961967
type get_rule_names = context -> thm -> strings;
962968
type pstate_to_thms = Proof.state -> thms;
963969
type pstate_to_thm_names = Proof.state -> strings;
@@ -997,8 +1003,8 @@ fun (m liftM f) = Option.map f m;
9971003
open Find_Theorems;
9981004

9991005
type context = Proof.context;
1000-
type ref = Facts.ref;
1001-
type get_rules = context -> thm -> (ref * thm) list;
1006+
type fact_name = string;
1007+
type get_rules = context -> thm -> (fact_name * thm) list;
10021008
type get_rule_names = context -> thm -> strings;
10031009
type pstate_to_thms = Proof.state -> thms;
10041010
type pstate_to_thm_names = Proof.state -> strings;
@@ -1007,17 +1013,18 @@ fun get_criterion kind_name ([]:strings) = [(true, Name kind_name)]
10071013
| get_criterion kind_name (name::names:strings) = (true, Name name)::get_criterion kind_name names;
10081014

10091015
fun all_names_to_rules kind_name (names:strings) ctxt (_(*just for type checking*):thm) =
1010-
try (find_theorems ctxt NONE NONE true) (get_criterion kind_name names) liftM snd |> Utils.is_some_null;
1016+
try (find_theorems ctxt NONE NONE true) (get_criterion kind_name names) liftM snd |> Utils.is_some_null
1017+
|> map (apfst Thm_Name.print);
10111018

1012-
fun some_names_to_rules kind_name names ctxt goal = names
1013-
|> map (fn name:string => all_names_to_rules kind_name [name] ctxt goal)
1019+
fun some_names_to_rules kind_name names ctxt goal: (string * thm) list = names
1020+
|> map (fn name:string => all_names_to_rules kind_name [name] ctxt goal: (string * thm) list)
10141021
|> flat
10151022
|> distinct (Thm.eq_thm o Utils.map_pair snd);
10161023

1017-
fun get_rule_names (get_rules:context -> thm -> (ref * thm) list) ctxt goal =
1024+
fun get_rule_names (get_rules:context -> thm -> (string * thm) list) ctxt goal =
10181025
let
10191026
val related_rules = get_rules ctxt goal;
1020-
val related_rule_names = map (Facts.string_of_ref o fst) related_rules;
1027+
val related_rule_names = map fst related_rules;
10211028
fun get_thm thm_nm = SOME (Proof_Context.get_thm ctxt thm_nm) handle ERROR _ => NONE;
10221029
fun get_thms thm_nm = SOME (Proof_Context.get_thms ctxt
10231030
(Utils.rm_parentheses_with_contents_in_the_end thm_nm)) handle ERROR _ => NONE;
@@ -1032,12 +1039,12 @@ fun get_rule_names (get_rules:context -> thm -> (ref * thm) list) ctxt goal =
10321039
fun get_simp_rules (ctxt:context) (goal:thm) =
10331040
let
10341041
val cnames = Isabelle_Utils.get_cnames_in_1st_subg goal;
1035-
val related_rules = some_names_to_rules "" cnames ctxt goal;
1042+
val related_rules = some_names_to_rules "" cnames ctxt goal: (string * thm) list;
10361043
val simpset_thms = ctxt |> simpset_of |> Raw_Simplifier.dest_ss |> #simps |> map snd;
10371044
fun eq_test (thm1, (_, thm2)) = Thm.eq_thm (thm1, thm2);
10381045
val unique_rules = subtract eq_test simpset_thms related_rules;
10391046
in
1040-
unique_rules : (Facts.ref * thm) list
1047+
unique_rules : (string * thm) list
10411048
end;
10421049

10431050
fun get_simp_rule_names ctxt goal = get_rule_names get_simp_rules ctxt goal : strings;
@@ -1047,7 +1054,7 @@ fun get_induct_rules (ctxt:context) (goal:thm) =
10471054
val cnames = Isabelle_Utils.get_cnames_in_1st_subg goal : strings;
10481055
val induct_rules = some_names_to_rules ".induct" cnames ctxt goal;
10491056
in
1050-
induct_rules : (Facts.ref * thm) list
1057+
induct_rules : (string * thm) list
10511058
end;
10521059

10531060
fun get_induct_rule_names ctxt goal = get_rule_names get_induct_rules ctxt goal : strings;
@@ -1101,14 +1108,16 @@ fun get_coinduction_rules (ctxt:context) (goal:thm) =
11011108
val coinduct_rules1 = get_coinduct_rules ".coinduct";
11021109
val coinduct_rules2 = get_coinduct_rules ".coinduct_strong";
11031110
in
1104-
coinduct_rules1 @ coinduct_rules2: (Facts.ref * thm) list
1111+
coinduct_rules1 @ coinduct_rules2: (string * thm) list
11051112
end;
11061113

11071114
fun get_coinduction_rule_names ctxt goal = get_rule_names get_coinduction_rules ctxt goal : strings;
11081115

1109-
fun get_elim_rules ctxt goal = find_theorems ctxt (SOME goal) NONE true [(true, Elim)] |> snd;
1110-
fun get_intro_rules ctxt goal = find_theorems ctxt (SOME goal) (SOME 100) true [(true, Intro)] |> snd;
1111-
fun get_dest_rules ctxt goal = find_theorems ctxt (SOME goal) (SOME 100) true [(true, Dest)] |> snd;
1116+
fun post_proc (_, pairs: (Thm_Name.T * thm) list) = map (apfst Thm_Name.print) pairs: (string * thm) list;
1117+
1118+
fun get_elim_rules ctxt goal = find_theorems ctxt (SOME goal) NONE true [(true, Elim)] |> post_proc;
1119+
fun get_intro_rules ctxt goal = find_theorems ctxt (SOME goal) (SOME 100) true [(true, Intro)] |> post_proc;
1120+
fun get_dest_rules ctxt goal = find_theorems ctxt (SOME goal) (SOME 100) true [(true, Dest)] |> post_proc;
11121121

11131122
fun get_elim_rule_names ctxt goal = get_rule_names get_elim_rules ctxt goal : strings;
11141123
fun get_intro_rule_names ctxt goal = get_rule_names get_intro_rules ctxt goal : strings;
@@ -1120,7 +1129,7 @@ fun get_split_rules ctxt goal =
11201129
val used_typ_names = Isabelle_Utils.get_typ_names_in_1st_subg goal;
11211130
val related_rules = some_names_to_rules "split" used_typ_names ctxt goal
11221131
in
1123-
related_rules : (Facts.ref * thm) list
1132+
related_rules : (string * thm) list
11241133
end;
11251134

11261135
fun get_split_rule_names ctxt goal = get_rule_names get_split_rules ctxt goal;

TBC/TBC.thy

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,18 @@ type pnodes = pnode list;
175175
val proof_id_counter = Unsynchronized.ref 0: int Unsynchronized.ref;
176176
177177
fun statement_to_conjecture (pst:Proof.state) (Element.Shows [((binding, _), [(stmt:string, _(*assumptions_maybe*))])]) =
178+
(tracing ("TBC.thy stmt is: " ^ stmt);
179+
tracing ("TBC.thy content is: " ^ Isabelle_Utils.YXML_content_of stmt);
178180
{
179181
is_final_goal = true,
180182
lemma_name = mk_lemma_name (Proof.context_of pst) Original_Goal "": string,
181-
lemma_stmt = stmt |> YXML.content_of |> String.explode |> Utils.init |> tl |> String.implode,
183+
lemma_stmt = stmt |> Isabelle_Utils.YXML_content_of |> String.explode |> Utils.init |> tl |> String.implode,
182184
proof = NONE,
183185
proof_id = NONE,
184186
refuted = false,(*we assume the final goal is a true statement.*)
185187
proved_wo_assmng_cnjctr = false,
186188
proved_in_nth_round = NONE
187-
}: pnode
189+
}): pnode
188190
| statement_to_conjecture _ _ = error "statement_to_conjecture failed for the final goal.";
189191
190192
fun sort_pnodes (pnodes:pnodes): pnodes =
@@ -2065,12 +2067,7 @@ val long_keyword =
20652067
val long_statement =
20662068
Scan.optional (Parse_Spec.opt_thm_name ":" --| Scan.ahead long_keyword) Binding.empty_atts --
20672069
Scan.optional Parse_Spec.includes [] -- Parse_Spec.long_statement
2068-
>> (fn ((binding, includes), (elems, concl)) => (true, binding, includes, elems, concl))
2069-
: Token.T list ->
2070-
(bool * Attrib.binding * (xstring * Position.T) list *
2071-
Element.context list * Element.statement)
2072-
*
2073-
Token.T list;
2070+
>> (fn ((binding, includes), (elems, concl)) => (true, binding, includes, elems, concl));
20742071
20752072
val short_statement =
20762073
Parse_Spec.statement -- Parse_Spec.if_statement -- Parse.for_fixes

0 commit comments

Comments
 (0)