Skip to content

Commit

Permalink
Add Lattice ℤ instance for computability (#9946)
Browse files Browse the repository at this point in the history
The file `Data.Int.ConditionallyCompleteOrder` defines a noncomputable instance of `ConditionallyCompleteLinearOrder` on `ℤ`.

This noncomputable instance is picked up by the typeclass search when looking for a `Lattice` instance on `ℤ`, making, for instance, `abs` noncomputable on `ℤ`.

This PR restores the computability of `Lattice ℤ`.

[Zulip discussion](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/No.20more.20.60Abs.60.3F/near/417546479)
  • Loading branch information
adomani committed Jan 24, 2024
1 parent 6694f75 commit e61934e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Mathlib/Data/Int/ConditionallyCompleteOrder.lean
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ The integers form a conditionally complete linear order.

open Int

open Classical

noncomputable section
open Classical

instance : ConditionallyCompleteLinearOrder ℤ :=
{ Int.linearOrderedCommRing,
Expand Down Expand Up @@ -106,3 +106,9 @@ theorem csInf_mem {s : Set ℤ} (h1 : s.Nonempty) (h2 : BddBelow s) : sInf s ∈
#align int.cInf_mem Int.csInf_mem

end Int

end

-- this example tests that the `Lattice ℤ` instance is computable;
-- i.e., that is is not found via the noncomputable instance in this file.
example : Lattice ℤ := inferInstance
1 change: 1 addition & 0 deletions Mathlib/Order/Lattice.lean
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,7 @@ instance (priority := 100) {α : Type u} [LinearOrder α] :
| Or.inr h => inf_le_of_right_le <| sup_le_sup_left (le_inf h (le_refl c)) _

instance : DistribLattice ℕ := inferInstance
instance : Lattice ℤ := inferInstance

/-! ### Dual order -/

Expand Down

0 comments on commit e61934e

Please sign in to comment.