Skip to content

Commit

Permalink
chore(Data/Nat/Bits): do not use tactic to make definitions (#17926)
Browse files Browse the repository at this point in the history
  • Loading branch information
FR-vdash-bot committed Oct 18, 2024
1 parent df601e3 commit abad5bb
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Mathlib/Data/Nat/Bits.lean
Original file line number Diff line number Diff line change
Expand Up @@ -375,20 +375,22 @@ def binaryRec' {motive : ℕ → Sort*} (z : motive 0)
∀ n, motive n :=
binaryRec z fun b n ih =>
if h : n = 0 → b = true then f b n h ih
else by
convert z
rw [bit_eq_zero_iff]
simpa using h
else
have : bit b n = 0 := by
rw [bit_eq_zero_iff]
cases n <;> cases b <;> simp at h ⊢
congrArg motive this ▸ z

/-- The same as `binaryRec`, but special casing both 0 and 1 as base cases -/
@[elab_as_elim]
def binaryRecFromOne {motive : ℕ → Sort*} (z₀ : motive 0) (z₁ : motive 1)
(f : ∀ b n, n ≠ 0 → motive n → motive (bit b n)) :
∀ n, motive n :=
binaryRec' z₀ fun b n h ih =>
if h' : n = 0 then by
rw [h', h h']
exact z₁
if h' : n = 0 then
have : bit b n = bit true 0 := by
rw [h', h h']
congrArg motive this ▸ z₁
else f b n h' ih

@[simp]
Expand Down

0 comments on commit abad5bb

Please sign in to comment.