Skip to content

Beta-eta reduction improvements - #1011

Merged
mezpusz merged 11 commits into
masterfrom
beta-reduction-improvements
Oct 7, 2026
Merged

mezpusz merged 11 commits into
masterfrom
beta-reduction-improvements

Conversation

@mezpusz

@mezpusz mezpusz commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Apply some optimizations to beta-eta reductions:

  1. Make beta reduction innermost using BottomUpTermTransformer and avoids creating intermediate terms over and over again.
  2. Fix some edge cases in BottomUpTermtransformer.
  3. Count beta reductions only in debug mode.
  4. TermShifter shifts free DB indices by an integer amount and gets the index of the minimal DB index at the same time, but the functionality is never used together. Factor out the latter part and simplify it.
  5. Remove ToPlaceholders which is not going to be used anymore due to the UWA HOL unification implementation.

I only used Claude to generate unit tests.

HOL TPTP Discount:

Only beta improvements:

master unsat: 2104 (0) sat: 1 (0) cputime: 10070.68 s instructions: 49939702 Mi memory: 196318.64 MB
branch unsat: 2111 (7) sat: 1 (0) cputime: 10092.84 s instructions: 49803051 Mi memory: 197046.09 MB

Beta-eta improvements:

master unsat: 2106 (0) sat: 1 (0) cputime: 10133.06 s instructions: 49911393 Mi memory: 200420.11 MB
branch unsat: 2118 (12) sat: 1 (0) cputime: 10167.87 s instructions: 49687596 Mi memory: 209745.55 MB

HOL TPTP Otter:

Only beta improvements:

master unsat: 2083 (0) sat: 1 (0) cputime: 10309.42 s instructions: 50375500 Mi memory: 246390.01 MB
branch unsat: 2087 (4) sat: 1 (0) cputime: 10336.92 s instructions: 50289588 Mi memory: 261380.23 MB

Beta-eta improvements:

master unsat: 2084 (0) sat: 1 (0) cputime: 10320.71 s instructions: 50342125 Mi memory: 251330.52 MB
branch unsat: 2091 (7) sat: 1 (0) cputime: 10336.29 s instructions: 50189498 Mi memory: 276181.34 MB

FOL TPTP has no regression change.

@quickbeam123

Copy link
Copy Markdown
Collaborator

Can you please explain a bit the changes in Kernel/TermTransformer.cpp? Are they meant to be semantics-changing (modulo transformSorts) or just a reorganization?

Comment thread Kernel/TermTransformer.cpp
Comment thread Kernel/TermTransformer.cpp
Comment thread Kernel/TermTransformer.cpp
Comment thread Kernel/TermTransformer.cpp
Comment thread Kernel/TermTransformer.cpp
@mezpusz

mezpusz commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

I tried to comment inline the places where something not related to transforming sorts.

quickbeam123 and others added 3 commits October 7, 2026 14:18
…r term

BottomUpTermTransformer::transform(TermList) now calls transformSubterm on
the root itself, so the extra transformSubterm in transformTermList ran it a
second time. That function is not a pure lookup: for a recursive term it
allocates a Function and introduces a fresh symbol, and for the synthesis ITE
symbol it builds a special $ite term, which the second pass then received.
The repeat happened to be the identity on the cases traced, but only by luck.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
transform(TermList) now applies transformSubterm to the root, which is what
transformSpecial uses for ITE branches, the LET body and MATCH arguments. When
such a component is itself special (e.g. the inner $ite of
$ite(c, $ite(d, a, b), e), or a $formula{...} branch), transformSubterm
received a special term. The main loop of transform(Term*) never does that,
and subclasses are not written for it: InterpretedLiteralEvaluator would call
getEvaluator with a functor near UINT_MAX and expand its DArray to that size.

Short-circuit special terms to transformSpecial, as the main loop does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
transform(Formula*) held a static BottomUpTermTransformerFormulaTransformer
built from *this. A static local is initialised once, so every later
BottomUpTermTransformer instance went on transforming its formulas (inside
$ite conditions, $let bindings, $formula{...}) through the first instance
that ever got there, which is a use-after-free once that instance is gone.
The adapter only holds a reference, so construct it per call, as
TermTransformer::transform(Formula*) already does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mezpusz
mezpusz merged commit ae4adea into master Oct 7, 2026
1 check passed
@mezpusz
mezpusz deleted the beta-reduction-improvements branch October 14, 2026 10:52
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