Skip to content

Commit

Permalink
chore: add @[simp] for Fin.foldl_zero and Fin.foldr_zero (#820)
Browse files Browse the repository at this point in the history
  • Loading branch information
llllvvuu authored Jun 5, 2024
1 parent 551ff2d commit 3062eb3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Batteries/Data/Fin/Lemmas.lean
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ theorem foldl_loop (f : α → Fin (n+1) → α) (x) (h : m < n+1) :
rw [foldl_loop_lt, foldl_loop_eq, foldl_loop_eq]
termination_by n - m

theorem foldl_zero (f : α → Fin 0 → α) (x) : foldl 0 f x = x := rfl
@[simp] theorem foldl_zero (f : α → Fin 0 → α) (x) : foldl 0 f x = x := rfl

theorem foldl_succ (f : α → Fin (n+1) → α) (x) :
foldl (n+1) f x = foldl n (fun x i => f x i.succ) (f x 0) := foldl_loop ..
Expand All @@ -78,6 +78,8 @@ theorem foldr_loop (f : Fin (n+1) → α → α) (x) (h : m+1 ≤ n+1) :
| zero => simp [foldr_loop_zero, foldr_loop_succ]
| succ m ih => rw [foldr_loop_succ, ih]; rfl

@[simp] theorem foldr_zero (f : Fin 0 → α → α) (x) : foldr 0 f x = x := rfl

theorem foldr_succ (f : Fin (n+1) → α → α) (x) :
foldr (n+1) f x = f 0 (foldr n (fun i => f i.succ) x) := foldr_loop ..

Expand Down

0 comments on commit 3062eb3

Please sign in to comment.