Skip to content

Commit

Permalink
added semireducible attribute to all inner loops
Browse files Browse the repository at this point in the history
  • Loading branch information
quangvdao committed Dec 2, 2024
1 parent a67ab9c commit 84b4d68
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Batteries/Data/Fin/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ alias list := List.finRange
pure xₙ
```
-/
loop (i : Nat) (h : i < n + 1) (x : α ⟨i, h⟩) : m (α (last n)) :=
@[semireducible] loop (i : Nat) (h : i < n + 1) (x : α ⟨i, h⟩) : m (α (last n)) :=
if h' : i < n then
(f ⟨i, h'⟩ x) >>= loop (i + 1) (Nat.succ_lt_succ h')
else
Expand All @@ -52,7 +52,7 @@ alias list := List.finRange
pure x₀
```
-/
loop (i : Nat) (h : i < n + 1) (x : α ⟨i, h⟩) : m (α 0) :=
@[semireducible] loop (i : Nat) (h : i < n + 1) (x : α ⟨i, h⟩) : m (α 0) :=
if h' : i > 0 then
(f ⟨i - 1, by omega⟩ (by simpa [Nat.sub_one_add_one_eq_of_pos h'] using x))
>>= loop (i - 1) (by omega)
Expand All @@ -78,7 +78,7 @@ alias list := List.finRange
loop n (Nat.lt_succ_self n) init where
/-- Inner loop for `Fin.dfoldr`.
`Fin.dfoldr.loop n α f i h x = f 0 (f 1 (... (f i x)))` -/
loop (i : Nat) (h : i < n + 1) (x : α ⟨i, h⟩) : α 0 :=
@[semireducible] loop (i : Nat) (h : i < n + 1) (x : α ⟨i, h⟩) : α 0 :=
if h' : i > 0 then
loop (i - 1) (by omega) (f ⟨i - 1, by omega⟩
(by simpa [Nat.sub_one_add_one_eq_of_pos h'] using x))
Expand Down

0 comments on commit 84b4d68

Please sign in to comment.