Skip to content

Conversation

@alok
Copy link
Contributor

@alok alok commented Jan 7, 2026

This PR adds typeclass instances for common types in the Lean library to enable standard syntax for append, ordering, set operations, membership, and iteration.

Summary

Append instances

  • SubExpr.Pos - enables using ++ to concatenate subexpression positions
  • Meta.FVarSubst - enables using ++ to compose free variable substitutions
  • RBTree - enables using ++ to union red-black trees
  • NameHashSet - enables using ++ to union name hash sets

LT/LE/Ord instances

  • TransparencyMode - LT, LE, Ord, Decidable (a < b), BEq
  • Position - LT, Decidable (a < b), Ord, LE
  • ReducibilityHints - LT, LE, Decidable (a < b)

Set operation instances (RBTree)

  • Union - enables s ∪ t syntax
  • SDiff - enables s \\ t syntax
  • Inter - enables s ∩ t syntax
  • Singleton - enables {a} syntax

Membership instances

  • RBTree - enables syntax for membership testing
  • PersistentHashSet - enables syntax for membership testing
  • NameSet - enables syntax for membership testing
  • NameSSet - enables syntax for membership testing
  • NameHashSet - enables syntax for membership testing
  • SSet - enables syntax for membership testing

ForIn instances

  • SSet - enables for x in s do ... iteration
  • NameSSet - enables for x in s do ... iteration

Other instances

  • NameHashSet - Singleton, Union

All types already had the corresponding methods defined; this simply adds the typeclass instances to enable standard syntax.

Total: 27 new typeclass instances across 9 files

Test plan

  • Build succeeds with make -j -C build/release
  • All new instances verified with #synth

alok and others added 2 commits January 6, 2026 20:24
This PR adds `Append` typeclass instances for `SubExpr.Pos` and
`Meta.FVarSubst`, enabling the use of the `++` operator for these types.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add the following instances:
- LT, Decidable (a < b), BEq for TransparencyMode
- LT, Decidable (a < b), Ord for Position
- LT, Decidable (a < b) for ReducibilityHints
- Append for RBTree
- Membership for RBTree
- Membership for PersistentHashSet
- Append, Singleton, Union, Membership for NameHashSet
- Membership for NameSet

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@alok alok changed the title feat: add Append instances for SubExpr.Pos and FVarSubst feat: add typeclass instances for common types Jan 7, 2026
alok and others added 3 commits January 6, 2026 21:15
Add Union, SDiff, Singleton, and Inter instances for RBTree.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Jan 7, 2026
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase ff87bcb8e57caeee38aa1dd05a212c0b2c51a902 --onto 0f866236c7c2e77e8d12ff61d08ef48694a0cbfb. You can force Mathlib CI using the force-mathlib-ci label. (2026-01-07 06:22:24)

@leanprover-bot
Copy link
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase ff87bcb8e57caeee38aa1dd05a212c0b2c51a902 --onto 0f866236c7c2e77e8d12ff61d08ef48694a0cbfb. You can force reference manual CI using the force-manual-ci label. (2026-01-07 06:22:26)

@kim-em
Copy link
Collaborator

kim-em commented Jan 9, 2026

TransparencyMode and ReducibilityHints could have LE and Ord while we're here.

@kim-em
Copy link
Collaborator

kim-em commented Jan 9, 2026

PR descriptions must start with "This PR", otherwise the automatic changelog scripts will get confused. I'm surprised CI didn't tell you this!

(edit: not all CI checks run on drafts)

@kim-em kim-em added the awaiting-author Waiting for PR author to address issues label Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-author Waiting for PR author to address issues toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants