Skip to content

Make MESON faster - #216

Merged
jrh13 merged 2 commits into
jrh13:masterfrom
aqjune-aws:meson
Nov 26, 2026
Merged

jrh13 merged 2 commits into
jrh13:masterfrom
aqjune-aws:meson

Conversation

@aqjune-aws

@aqjune-aws aqjune-aws commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Speedups, with the search and its results unchanged (same inference counts
and same theorems):

  • Polymorphic comparison is replaced in the inner loops by monomorphic
    versions: lookups of instantiations, unification, the continuation cache
    and the ancestor checks; equality of instantiations first checks for
    physical equality, since they share long tails.
  • The input clauses are kept in an array indexed by predicate code instead
    of an association list, and the clauses within the size bound are taken
    as a prefix of the already-sorted list.
  • Duplicate clauses are removed by hashing instead of a quadratic number of
    comparisons, and the variable/constant stores use hash tables for lookup.

The instantiations stay association lists: on the goals below they never
exceed 18 entries (about 3 are scanned per lookup), and a Map version was
about 33% slower and changed the search slightly.

On 5554 goals recorded from MESON calls in Library/card.ml, rstc.ml,
Multivariate/misc.ml, Library/{permutations,products,floor,prime,
pocklington}.ml and Examples/{inverse_bug_puzzle_tac,forster,mizar}.ml, the
time in PURE_MESON_TAC goes from 37.8s to 28.5s (1.33x).

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

@aqjune-aws
aqjune-aws marked this pull request as draft November 23, 2026 21:51
@aqjune-aws aqjune-aws changed the title Make MESON domain-safe and faster Make MESON faster Nov 23, 2026
Speedups, with the search and its results unchanged (same inference counts
and same theorems):

- Polymorphic comparison is replaced in the inner loops by monomorphic
  versions: lookups of instantiations, unification, the continuation cache
  and the ancestor checks; equality of instantiations first checks for
  physical equality, since they share long tails.
- The input clauses are kept in an array indexed by predicate code instead
  of an association list, and the clauses within the size bound are taken
  as a prefix of the already-sorted list.
- Duplicate clauses are removed by hashing instead of a quadratic number of
  comparisons, and the variable/constant stores use hash tables for lookup.

The instantiations stay association lists: on the goals below they never
exceed 18 entries (about 3 are scanned per lookup), and a Map version was
about 33% slower and changed the search slightly.

On 5554 goals recorded from MESON calls in Library/card.ml, rstc.ml,
Multivariate/misc.ml, Library/{permutations,products,floor,prime,
pocklington}.ml and Examples/{inverse_bug_puzzle_tac,forster,mizar}.ml, the
time in PURE_MESON_TAC goes from 37.8s to 28.5s (1.33x).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aqjune-aws
aqjune-aws marked this pull request as ready for review November 25, 2026 13:23
@aqjune-aws

Copy link
Copy Markdown
Contributor Author

fol_of_hol_clauses concatenated all contrapositives and then ran a
non-tail-recursive fold over the flat list, so stack use grew with the
total number of generated rules (overflowing on e.g. thousands of
duplicate 24-literal disjunctions that the original code handled).
Fold over the theorems and then over each theorem's rules instead,
sharing one hash table. This keeps the same surviving rules in the same
order, and also restores the original right-to-left translation order
so fresh symbol codes match the pre-speedup numbering.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aqjune-aws

Copy link
Copy Markdown
Contributor Author

@jrh13 jrh13 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Great improvement thank you! This helps the performance of almost all proofs.

@jrh13
jrh13 merged commit 1cd9471 into jrh13:master Nov 26, 2026
3 checks passed
jargh pushed a commit to jargh/hol-light-dev that referenced this pull request Nov 27, 2026
Brought the changes of pull request jrh13#216, merged upstream as 1cd9471, into
this series: monomorphic comparisons in MESON's inner loops, the input
clauses in an array indexed by predicate code, the removal of duplicate
clauses by hashing, folded per theorem, and hash tables for the variable
and constant stores, with the search and its results unchanged. Adapted
to this series, which removes genvar from meson.ml: the variable store
keeps jrh13#216's hash table and loses its global store of genvars for bumped
variables, which meson_to_hol now names locally.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jargh added a commit to jargh/hol-light-dev that referenced this pull request Nov 27, 2026
…ries and added one for pull request jrh13#216

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jargh added a commit to jargh/hol-light-dev that referenced this pull request Nov 27, 2026
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