Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: simproc for functions out of Subtype #5477

Closed
wants to merge 1 commit into from
Closed

Conversation

kim-em
Copy link
Collaborator

@kim-em kim-em commented Sep 26, 2024

Adds a simproc that will replace l.map f, where l : {x // p x} and f syntactically only depends on the value, with l.map (f' ∘Subtype.val).

In combination with

@[simp] theorem map_attach_comp_subtype_val {l : List α} :
    l.attach.map (f ∘ Subtype.val) = l.map f := by
  simp [map_attach]

this allows us to automatically clear attach:

inductive Tree where | node : List Tree → Tree

def Tree.rev : Tree → Tree
  | node ts => .node (ts.attach.reverse.map (fun ⟨t, _⟩ => t.rev))

@[simp] theorem Tree.rev_def (ts : List Tree) :
    Tree.rev (.node ts) = .node (ts.reverse.map rev) := by
  simp [Tree.rev]

(Credit to David and Joachim for suggesting this!)


TODO: add simprocs and simp lemmas for other higher order operations besides map.

feat: simproc for functions out of Subtype
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc September 26, 2024 02:35 Inactive
@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 Sep 26, 2024
@leanprover-community-mathlib4-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 90cb6e5da857f8d8c361dbef910206bb7c1cfe6d --onto 7845a05cf1094f24a5c4a51c32dd84bf4ff31a54. (2024-09-26 02:38:54)

@kim-em
Copy link
Collaborator Author

kim-em commented Sep 29, 2024

Closing in favour of #5479

@nomeata nomeata closed this Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

3 participants