Skip to content

Experiment: use push/pull tactic for zpow rewrites#491

Draft
ldct wants to merge 3 commits intoteorth:mainfrom
ldct:ldct-push-experiment
Draft

Experiment: use push/pull tactic for zpow rewrites#491
ldct wants to merge 3 commits intoteorth:mainfrom
ldct:ldct-push-experiment

Conversation

@ldct
Copy link
Copy Markdown
Contributor

@ldct ldct commented Apr 21, 2026

Summary

Experiment replacing rw [← zpow_sub₀ ...] with pull _ ^ _ in Section_1_2_1.lean, using the push/pull tactic from mathlib.

Two replacements were made:

  • rw [← zpow_sub₀ (by norm_num : (2:ℝ) ≠ 0)]pull (disch := norm_num) _ ^ _; rfl

Findings

For single-lemma rewrites, push/pull doesn't clearly win over rw — same length, and the lemma name (zpow_sub₀) is more self-documenting than _ ^ _.

Where push/pull would win (not demonstrated in this codebase):

  1. Multiple rewrites in sequence — push abs replacing rw [abs_mul, abs_neg, abs_div]
  2. Deep nested expressions — push deriv doing product rule + chain rule recursively
  3. Discoverability — push abs is easier to find than remembering abs_mul
  4. Variant collapse — push Int.floor handles floor_add_natCast, floor_add_intCast, floor_add_one, floor_add_ofNat uniformly

Context

This is part of a broader investigation into which mathlib lemmas benefit from @[push] tagging. See companion PRs at ldct/mathlib4 for the tagging work.

🤖 Generated with Claude Code

ldct and others added 3 commits April 21, 2026 12:10
Two replacements in Section_1_2_1.lean showing that pull works but isn't
obviously better than rw for single-lemma applications.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace `rw [← zpow_sub₀ ...]`, `rw [← zpow_add₀ ...]` backward rewrite
calls in Section_1_2_1.lean with `pull (disch := norm_num) _ ^ _; rfl`
(or `congr 1; omega` where the exponents need arithmetic). Forward direction
`rw [zpow_neg, zpow_natCast]` calls kept as-is since `push` left unsolved goals.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace `rw [← rpow_add ...]`, `rw [← rpow_neg ...]`, and
`rw [← rpow_add_one ...]` backward rewrite calls in Section_6_7.lean
and Appendix_B_2.lean with `pull (disch := positivity/norm_num) _ ^ _`
calls. Cases involving `rpow_natCast + rpow_mul` (which mix nat pow
and rpow) are left unchanged as `pull` cannot handle them.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant