Skip to content

perf(FieldTheory/PurelyInseparable): golf proof#41664

Open
kbuzzard wants to merge 1 commit into
leanprover-community:masterfrom
kbuzzard:kbuzzard-perfect-closure-golf
Open

perf(FieldTheory/PurelyInseparable): golf proof#41664
kbuzzard wants to merge 1 commit into
leanprover-community:masterfrom
kbuzzard:kbuzzard-perfect-closure-golf

Conversation

@kbuzzard

Copy link
Copy Markdown
Member

This one proof was taking a huge amount of time to typecheck, presumably because of some defeq abuse. Fixing this up gives a nice speedup in this file.


Open in Gitpod

Claude says: The old proof transported Algebra.IsSeparable M L across the definitional equality between (inclusion hi).toAlgebra and the canonical Algebra instance on extendScalars hi. Checking that single instance defeq costs the kernel ~460ms (~80% of the file's kernel type-checking time), and it is paid twice if the haveI there is replaced by have (the cause of the 13.6% instruction-count regression radar reported on #41615).

What Claude says looks reasonable to me.

…Char_pow_of_isSeparable proof

The old proof transported `Algebra.IsSeparable M L` across the definitional
equality between `(inclusion hi).toAlgebra` and the canonical `Algebra`
instance on `extendScalars hi`. Checking that single instance defeq costs
the kernel ~460ms (~80% of the file's kernel type-checking time), and it is
paid twice if the `haveI` there is replaced by `have` (the cause of the
13.6% instruction-count regression radar reported on leanprover-community#41615).

The new elementwise proof stays on canonical instances throughout: kernel
type-checking of this declaration drops from 580ms to 22ms and the whole
file compiles ~20% faster.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kbuzzard

Copy link
Copy Markdown
Member Author

!radar

@leanprover-radar

leanprover-radar commented Jul 12, 2026

Copy link
Copy Markdown

Benchmark results for 23363c2 against 4694604 are in. No significant results found. @kbuzzard

Warning

These warnings may indicate that the benchmark results are not directly comparable, for example due to changes in the runner configuration or hardware.

  • Bench repo commit hashes for run main differ between commits.
  • build//instructions: -187.7G (-0.12%)

Medium changes (1✅)

  • build/module/Mathlib.FieldTheory.PurelyInseparable.PerfectClosure//instructions: -6.6G (-20.55%)

Small changes (1✅)

1 hidden

@github-actions

github-actions Bot commented Jul 12, 2026

Copy link
Copy Markdown

PR summary 23363c2bd3

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

No declarations were harmed in the making of this PR! 🐙

You can run this locally as follows
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.

Declarations diff (Lean)

Lean-aware diff — post-build, computed from the Lean environment (commit 23363c2).

  • +0 new declarations
  • −0 removed declarations

No declaration differences.


No changes to strong technical debt.

No changes to weak technical debt.

Current commit 23363c2bd3
Reference commit 4694604756

This script lives in the mathlib-ci repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@github-actions github-actions Bot added the t-algebra Algebra (groups, rings, fields, etc) label Jul 12, 2026
@kbuzzard

Copy link
Copy Markdown
Member Author

I think the 187G figure must be bogus but the 20% speedup in the file I'm editing is genuine.

rintro _ ⟨y, hy, rfl⟩
have := expChar_of_injective_algebraMap (algebraMap F M).injective q
refine le_antisymm (adjoin_le_iff.2 fun x hx ↦ ?_) (adjoin_le_iff.2 ?_)
· have : Algebra.IsSeparable M (adjoin M {x}) :=

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
· have : Algebra.IsSeparable M (adjoin M {x}) :=
· have : Algebra.IsSeparable M M⟮x⟯ :=

Maybe this looks better (untested) Same as two adjoin M {x} below.

@jcommelin jcommelin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

bors d+

@mathlib-bors

mathlib-bors Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

✌️ kbuzzard can now approve this pull request until 2026-07-27 09:36 UTC (in 2 weeks). To approve and merge, reply with bors r+. More detailed instructions are available here.

⚠️ This delegation only covers changes within Archive/**, Counterexamples/**, docs/**, DownstreamTest/**, Mathlib/**, MathlibTest/**, widget/**, Archive.lean, Counterexamples.lean, docs.lean, Mathlib.lean; an author commit touching anything else will revoke it. Bors also revokes it if a later push changes too many files for it to check the full list — even if it stays within scope.

@mathlib-bors mathlib-bors Bot added the delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). label Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). t-algebra Algebra (groups, rings, fields, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants