leanprover-community / leanprover-community/mathlib4

Special-case Prop-valued fields in `simps`

Open
#8,275 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement t-meta
Dominant language
Lean
Stars
4.2k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

simps does not consider whether a field of a structure is Prop-valued or not. This means the lemmas it generates don't follow the convention in three ways:

  • The name use UpperCamelCase instead of lowerCamelCase. This can be solved on a case-by-case basis using initialize_simps_projection, but hopefully we can just change the default behavior.
  • The lemma is stated using =, not .
  • The lemma is stated with too many explicit arguments.

In the following example, simps handles bar correctly but not Baz.

import Mathlib.Tactic.Simps.Basic

structure Foo where
  bar : Nat
  Baz : Prop

@[simps]
def myFoo (n : Nat) : Foo where
  bar := n
  Baz := False

#check myFoo_bar
-- myFoo_Bar (n : Nat) : (myFoo n).Bar = n
#check myFoo_Baz
-- myFoo_Baz (n : Nat) : (myFoo n).Baz = False
-- We instead want:
-- myFoo_baz {n : Nat} : (myFoo n).Baz ↔ False

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Mathlib.Tactic.Simps.Basic module and the simps behavior shown in the example. Compare the generated declarations for the bar : Nat and Baz : Prop fields, and inspect initialize_simps_projection for the existing special-case behavior. Done means Prop-valued fields use lowerCamelCase names, , and implicit arguments by default.

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.