Skip to content

Conversation

@ordinarymath
Copy link
Contributor

Note that reusing set from hyp_frees is actually slower.
times using time bin/build
before
real 10m37.510s
user 21m43.869s
sys 3m12.949s
reusing set from hyp_frees
real 10m40.847s
user 21m49.628s
sys 3m16.913s
without reusing set from hyp_frees
real 10m29.285s
user 21m9.849s
sys 3m10.606s
note depends on #1623

@ordinarymath
Copy link
Contributor Author

I think why reusing the set from hyp_frees is slower is that the vars from strip_forall is already guaranteed to be fresh in the term and that sorting the list makes it so that the loop check here https://github.com/HOL-Theorem-Prover/HOL/blob/24e40cd1c7f7e235a5c9f32f692c0d9ae04ddb2b/src/0/Term.sml#L345C1-L347C25 is slower

@ordinarymath
Copy link
Contributor Author

note time from docker-ci stdknl 3076.5s

@ordinarymath ordinarymath marked this pull request as draft August 25, 2025 04:08
Note that reusing set from hyp_frees is actually slower.
times using `time bin/build`
before
real 10m37.510s
user 21m43.869s
sys 3m12.949s
reusing set from hyp_frees
real 10m40.847s
user    21m49.628s
sys     3m16.913s
without reusing set from hyp_frees
real    10m29.285s
user    21m9.849s
sys 3m10.606s
@ordinarymath
Copy link
Contributor Author

I wanted to see if I could speed it up even more by using gen_variant with a predicate check but the issue is that you can't lookup a string using the HOLset produced by FVL and recreating a new set is slower. #1642 is going to be needed for the further improvement.

@ordinarymath ordinarymath marked this pull request as ready for review September 6, 2025 07:44
@ordinarymath ordinarymath requested a review from mn200 September 8, 2025 03:31
@mn200
Copy link
Member

mn200 commented Oct 27, 2025

It seems as if this code should actually be using thm_frees : thm -> term list entrypoint, perhaps after modifying the implementation of that to use FVL internally.

@ordinarymath
Copy link
Contributor Author

reusing the same set from hyp_frees is actually slower

@ordinarymath
Copy link
Contributor Author

I still suspect the same thing

I think why reusing the set from hyp_frees is slower is that the vars from strip_forall is already guaranteed to be fresh in the term and that sorting the list makes it so that the loop check here https://github.com/HOL-Theorem-Prover/HOL/blob/24e40cd1c7f7e235a5c9f32f692c0d9ae04ddb2b/src/0/Term.sml#L345C1-L347C25 is slower

@mn200
Copy link
Member

mn200 commented Oct 28, 2025

But the "new" code is calling hyp_frees.

@ordinarymath
Copy link
Contributor Author

Making it call thm_frees as the vars in the hyps and thm mix when they end up sorted from HOLset.listItems and it will be slower. making it call hyp_frees is faster

@mn200
Copy link
Member

mn200 commented Nov 3, 2025

I suspect it doesn't help that thm_frees is not using FVL. Perhaps worse, the fold over prim_variant is gross as well because each call to prim_variant involves a new calculation of the free names of the list, using a list again. The kernel should provide a gen/prim_variants function.

@mn200 mn200 merged commit 03ff3ca into HOL-Theorem-Prover:develop Nov 3, 2025
4 checks passed
@ordinarymath
Copy link
Contributor Author

A better way would be if strip_forall has a additional parameter for names it should avoid.

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