Skip to content

Commit aa2c43f

Browse files
committed
feat: add wf_preprocess theorems for List.any
1 parent 8ace95f commit aa2c43f

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/Init/Data/List/Attach.lean

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,4 +867,13 @@ and simplifies these to the function directly taking the value.
867867
binderNameHint x f <| binderNameHint h () <| f (wfParam x) := by
868868
simp [wfParam]
869869

870+
@[wf_preprocess] theorem any_wfParam {xs : List α} {f : α → Bool} :
871+
(wfParam xs).any f = xs.attach.unattach.any f := by
872+
simp [wfParam]
873+
874+
@[wf_preprocess] theorem any_unattach {P : α → Prop} {xs : List (Subtype P)} {f : α → Bool} :
875+
xs.unattach.any f = xs.any fun ⟨x, h⟩ =>
876+
binderNameHint x f <| binderNameHint h () <| f (wfParam x) := by
877+
simp [wfParam]
878+
870879
end List

tests/lean/run/wf_preprocess.lean

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,4 +361,12 @@ theorem Tree.map2.eq_1.{u_1, u_2, u_3} : ∀ {α : Type u_1} {β : Type u_2} {γ
361361
#guard_msgs in
362362
#print equations Tree.map2
363363

364+
#guard_msgs in
365+
def Tree.any (f : α → Bool) (t : Tree α) : Bool :=
366+
if f t.val
367+
then true
368+
else t.cs.any fun c => any f c
369+
termination_by t
370+
decreasing_by cases t; decreasing_tactic
371+
364372
end Binary

0 commit comments

Comments
 (0)