Skip to content

Commit

Permalink
perf: inline the Decidable (Coprime _ _) instance (#1036)
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-wieser authored Nov 12, 2024
1 parent 1bfaec4 commit 12381da
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Batteries/Data/Nat/Gcd.lean
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ See also `nat.coprime_of_dvd` and `nat.coprime_of_dvd'` to prove `nat.Coprime m
/-- `m` and `n` are coprime, or relatively prime, if their `gcd` is 1. -/
@[reducible] def Coprime (m n : Nat) : Prop := gcd m n = 1

instance (m n : Nat) : Decidable (Coprime m n) := inferInstanceAs (Decidable (_ = 1))
-- if we don't inline this, then the compiler computes the GCD even if it already has it
@[inline] instance (m n : Nat) : Decidable (Coprime m n) := inferInstanceAs (Decidable (_ = 1))

theorem coprime_iff_gcd_eq_one : Coprime m n ↔ gcd m n = 1 := .rfl

Expand Down

0 comments on commit 12381da

Please sign in to comment.