Skip to content

Conversation

@ordinarymath
Copy link
Contributor

@ordinarymath ordinarymath commented Oct 27, 2025

Add STRIP_ALL_THEN and CHOOSE_ALL_THEN

Only STRIP_ALL_THEN is exposed in the signature.

STRIP_ALL_THEN should behave like REPEAT_TCL STRIP_THM_THEN
and
CHOOSE_ALL_THEN should behave like REPEAT_TCL CHOOSE_THEN

This change is intended to speedup record construction time
where STRIP_ALL_THEN is being called via STRUCT_CASES_TAC

@ordinarymath ordinarymath force-pushed the CHOOSE_ALL_THEN branch 2 times, most recently from ba12b04 to f254035 Compare October 27, 2025 08:43
Only STRIP_ALL_THEN is exposed in the signature.

STRIP_ALL_THEN should behave like REPEAT_TCL STRIP_THM_THEN
and
CHOOSE_ALL_THEN should behave like REPEAT_TCL CHOOSE_THEN

This change is intended to speedup record construction time
where STRIP_ALL_THEN is being called via STRUCT_CASES_TAC
``?q r. ?r q. (n' = q * m + r) /\ r < m``
In here the front q and r is free and can be ignored
The code previously generated
q r r' q'.
@ordinarymath ordinarymath changed the title Add CHOOSE_ALL_THEN to speedup STRIP_THM_THEN Add STRIP_ALL_THEN and CHOOSE_ALL_THEN Oct 27, 2025
Copy link
Member

@mn200 mn200 left a comment

Choose a reason for hiding this comment

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

Please write a documentation file for STRIP_ALL_THEN in help/Docfiles. Use the template or other examples for formatting.

fun varyAcc v (V, l) = let val v' = gen_variant Parse.is_constname "" V v in (v'::V, v'::l) end
(* There are actual cases where strip_exists differ from this function *)
fun strip_exists1 tm =
let fun dest_exist_opt tm = SOME (dest_exists tm) handle HOL_ERR _ => NONE
Copy link
Member

Choose a reason for hiding this comment

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

The dest_exist_opt function is Lib.total dest_exists.

@ordinarymath
Copy link
Contributor Author

I've figured out why this is way slower than using MP with a induction thm + GENL.

HOL/src/1/Thm_cont.sml

Lines 104 to 133 in a902f2d

(* -------------------------------------------------------------------------*)
(* REVISED 22 Oct 1992 by TFM. Bugfix. *)
(* *)
(* The problem was, for example: *)
(* *)
(* th = |- ?n. ((?n. n = SUC 0) \/ F) /\ (n = 0) *)
(* set_goal ([], "F");; *)
(* expandf (STRIP_ASSUME_TAC th);; *)
(* OK.. *)
(* "F" *)
(* [ "n = SUC 0" ] (n.b. should be n') *)
(* [ "n = 0" ] *)
(* *)
(* let DISJ_CASES_THEN2 ttac1 ttac2 disth :tactic = *)
(* let a1,a2 = dest_disj (concl disth) ? failwith `DISJ_CASES_THEN2` in *)
(* \(asl,w). *)
(* let gl1,prf1 = ttac1 (ASSUME a1) (asl,w) *)
(* and gl2,prf2 = ttac2 (ASSUME a2) (asl,w) *)
(* in *)
(* gl1 @ gl2, *)
(* \thl. let thl1,thl2 = chop_list (length gl1) thl in *)
(* DISJ_CASES disth (prf1 thl1) (prf2 thl2);; *)
(* -------------------------------------------------------------------------*)
(*---------------------------------------------------------------------------
foo needs to return a theorem with M as conclusion, and M as one
of the assumptions, and all of the assumptions of th as well:
foo th M = mk_thm(M::Thm.hyp th, M)
---------------------------------------------------------------------------*)

This bug fix means that the thm passed through the continuation gets bigger and bigger with more hyps and resulting call of CHOOSE has to check for var_occurs for all of the hyps.

@ordinarymath ordinarymath marked this pull request as draft November 12, 2025 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants