Skip to content

Commit a978d17

Browse files
committed
chore(Tactic/Linarith): put linarith declarations into Mathlib.Tactic namespace (#25955)
The `Name.isMetaProgramming` function is used to exclude lemmas from library search tactics. Thus, it is important that lemmas that are only meant for use in a tactic implementation have a name flagged by `Name.isMetaProgramming`. So, this PR renames everying in `Mathlib/Tactic/Linarith` to the namespace `Mathlib.Tactic.Linarith` (which previously was just `Linarith`)
1 parent 2806fcd commit a978d17

File tree

12 files changed

+31
-36
lines changed

12 files changed

+31
-36
lines changed

Mathlib/Tactic/Linarith/Datatypes.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ We split them into their own file.
1616
This file also contains a few convenient auxiliary functions.
1717
-/
1818

19-
open Lean Elab Tactic Meta Qq Mathlib
19+
open Lean Elab Tactic Meta Qq
2020

2121
initialize registerTraceClass `linarith
2222
initialize registerTraceClass `linarith.detail
2323

24-
namespace Linarith
24+
namespace Mathlib.Tactic.Linarith
2525

2626
/-- A shorthand for getting the types of a list of proofs terms, to trace. -/
2727
def linarithGetProofsMessage (l : List Expr) : MetaM MessageData := do
@@ -305,4 +305,4 @@ def mkSingleCompZeroOf (c : Nat) (h : Expr) : MetaM (Ineq × Expr) := do
305305
let e' ← mkAppM iq.toConstMulName #[h, ex]
306306
return (iq, e')
307307

308-
end Linarith
308+
end Mathlib.Tactic.Linarith

Mathlib/Tactic/Linarith/Frontend.lean

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ linarith, nlinarith, lra, nra, Fourier-Motzkin, linear arithmetic, linear progra
131131
-/
132132

133133
open Lean Elab Parser Tactic Meta
134-
open Batteries Mathlib
134+
open Batteries
135135

136136

137-
namespace Linarith
137+
namespace Mathlib.Tactic.Linarith
138138

139139
/-! ### Config objects
140140
@@ -487,3 +487,5 @@ elab_rules : tactic
487487
-- category := doc_category.tactic,
488488
-- decl_names := [`tactic.interactive.nlinarith],
489489
-- tags := ["arithmetic", "decision procedure", "finishing"] }
490+
491+
end Mathlib.Tactic

Mathlib/Tactic/Linarith/Lemmas.lean

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Those in the `Linarith` namespace should stay here.
1919
Those outside the `Linarith` namespace may be deleted as they are ported to mathlib4.
2020
-/
2121

22-
namespace Linarith
22+
namespace Mathlib.Tactic.Linarith
2323

2424
universe u
2525
theorem lt_irrefl {α : Type u} [Preorder α] {a : α} : ¬a < a := _root_.lt_irrefl a
@@ -90,7 +90,6 @@ theorem sub_neg_of_lt [IsOrderedRing α] {a b : α} : a < b → a - b < 0 :=
9090

9191
end Ring
9292

93-
open Mathlib in
9493
/-- Finds the name of a multiplicative lemma corresponding to an inequality strength. -/
9594
def _root_.Mathlib.Ineq.toConstMulName : Ineq → Lean.Name
9695
| .lt => ``mul_neg
@@ -112,14 +111,14 @@ lemma zero_mul_eq {α} {R : α → α → Prop} [Semiring α] {a b : α} (h : a
112111
a * b = 0 := by
113112
simp [h]
114113

115-
end Linarith
114+
end Mathlib.Tactic.Linarith
116115

117116
section
118-
open Function
119-
-- These lemmas can be removed when their originals are ported.
120117

118+
@[deprecated GT.gt.lt (since := "2025-06-16")]
121119
theorem lt_zero_of_zero_gt {α : Type*} [Zero α] [LT α] {a : α} (h : 0 > a) : a < 0 := h
122120

121+
@[deprecated GE.ge.le (since := "2025-06-16")]
123122
theorem le_zero_of_zero_ge {α : Type*} [Zero α] [LE α] {a : α} (h : 0 ≥ a) : a ≤ 0 := h
124123

125124
end

Mathlib/Tactic/Linarith/Oracle/FourierMotzkin.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ instance : SDiff (TreeSet α cmp) := ⟨TreeSet.sdiff⟩
5555

5656
end Std.TreeSet
5757

58-
namespace Linarith
58+
namespace Mathlib.Tactic.Linarith
5959

6060
/-!
6161
### Datatypes
@@ -361,4 +361,4 @@ def CertificateOracle.fourierMotzkin : CertificateOracle where
361361
| (Except.ok _) => failure
362362
| (Except.error contr) => return contr.src.flatten
363363

364-
end Linarith
364+
end Mathlib.Tactic.Linarith

Mathlib/Tactic/Linarith/Oracle/SimplexAlgorithm.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ The algorithm's entry point is the function `Linarith.SimplexAlgorithm.findPosit
1414
See the file `PositiveVector.lean` for details of how the procedure works.
1515
-/
1616

17-
namespace Linarith.SimplexAlgorithm
18-
open Mathlib
17+
namespace Mathlib.Tactic.Linarith.SimplexAlgorithm
1918

2019
/-- Preprocess the goal to pass it to `Linarith.SimplexAlgorithm.findPositiveVector`. -/
2120
def preprocess (matType : ℕ → ℕ → Type) [UsableInSimplexAlgorithm matType] (hyps : List Comp)
@@ -56,4 +55,4 @@ def CertificateOracle.simplexAlgorithmDense : CertificateOracle where
5655
let vec ← findPositiveVector A strictIndexes
5756
return postprocess vec
5857

59-
end Linarith
58+
end Mathlib.Tactic.Linarith

Mathlib/Tactic/Linarith/Oracle/SimplexAlgorithm/Datatypes.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Std.Data.HashMap.Basic
1111
# Datatypes for the Simplex Algorithm implementation
1212
-/
1313

14-
namespace Linarith.SimplexAlgorithm
14+
namespace Mathlib.Tactic.Linarith.SimplexAlgorithm
1515

1616
/--
1717
Specification for matrix types over ℚ which can be used in the Gauss Elimination and the Simplex
@@ -126,4 +126,4 @@ structure Tableau (matType : Nat → Nat → Type) [UsableInSimplexAlgorithm mat
126126
/-- Matrix of coefficients the basic variables expressed through the free ones. -/
127127
mat : matType basic.size free.size
128128

129-
end Linarith.SimplexAlgorithm
129+
end Mathlib.Tactic.Linarith.SimplexAlgorithm

Mathlib/Tactic/Linarith/Oracle/SimplexAlgorithm/Gauss.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The first step of `Linarith.SimplexAlgorithm.findPositiveVector` is finding init
1212
solution which is done by standard Gaussian Elimination algorithm implemented in this file.
1313
-/
1414

15-
namespace Linarith.SimplexAlgorithm.Gauss
15+
namespace Mathlib.Tactic.Linarith.SimplexAlgorithm.Gauss
1616

1717
/-- The monad for the Gaussian Elimination algorithm. -/
1818
abbrev GaussM (n m : Nat) (matType : Nat → Nat → Type) := StateT (matType n m) Lean.CoreM
@@ -78,4 +78,4 @@ ones.
7878
def getTableau (A : matType n m) : Lean.CoreM (Tableau matType) := do
7979
return (← getTableauImp.run A).fst
8080

81-
end Linarith.SimplexAlgorithm.Gauss
81+
end Mathlib.Tactic.Linarith.SimplexAlgorithm.Gauss

Mathlib/Tactic/Linarith/Oracle/SimplexAlgorithm/PositiveVector.lean

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ The function `findPositiveVector` solves this problem.
3333
3434
-/
3535

36-
namespace Linarith.SimplexAlgorithm
36+
namespace Mathlib.Tactic.Linarith.SimplexAlgorithm
3737

3838
variable {matType : Nat → Nat → Type} [UsableInSimplexAlgorithm matType]
3939

@@ -99,6 +99,4 @@ def findPositiveVector {n m : Nat} {matType : Nat → Nat → Type} [UsableInSim
9999
else
100100
throwError "Simplex Algorithm failed"
101101

102-
end SimplexAlgorithm
103-
104-
end Linarith
102+
end Mathlib.Tactic.Linarith.SimplexAlgorithm

Mathlib/Tactic/Linarith/Oracle/SimplexAlgorithm/SimplexAlgorithm.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ To obtain required vector in `Linarith.SimplexAlgorithm.findPositiveVector` we r
1212
Algorithm. We use Bland's rule for pivoting, which guarantees that the algorithm terminates.
1313
-/
1414

15-
namespace Linarith.SimplexAlgorithm
15+
namespace Mathlib.Tactic.Linarith.SimplexAlgorithm
1616

1717
/-- An exception in the `SimplexAlgorithmM` monad. -/
1818
inductive SimplexAlgorithmException
@@ -120,4 +120,4 @@ def runSimplexAlgorithm : SimplexAlgorithmM matType Unit := do
120120
let ⟨exitIdx, enterIdx⟩ ← choosePivots
121121
doPivotOperation exitIdx enterIdx
122122

123-
end Linarith.SimplexAlgorithm
123+
end Mathlib.Tactic.Linarith.SimplexAlgorithm

Mathlib/Tactic/Linarith/Parsing.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ This is ultimately converted into a `Linexp` in the obvious way.
2727
`linearFormsAndMaxVar` is the main entry point into this file. Everything else is contained.
2828
-/
2929

30-
open Mathlib.Ineq Batteries
3130
open Std (TreeMap)
3231

3332
namespace Std.TreeMap
@@ -78,7 +77,7 @@ local instance {α β : Type*} {c : α → α → Ordering} [Add β] [Zero β] [
7877
Add (TreeMap α β c) where
7978
add := fun f g => (f.mergeWith (fun _ b b' => b + b') g).filter (fun _ b => b ≠ 0)
8079

81-
namespace Linarith
80+
namespace Mathlib.Tactic.Linarith
8281

8382
/-- A local abbreviation for `TreeMap` so we don't need to write `Ord.compare` each time. -/
8483
abbrev Map (α β) [Ord α] := TreeMap α β Ord.compare
@@ -268,4 +267,4 @@ def linearFormsAndMaxVar (red : TransparencyMode) (pfs : List Expr) :
268267
trace[linarith.detail] "monomial map: {map.toList.map fun ⟨k,v⟩ => (k.toList, v)}"
269268
return (l, map.size - 1)
270269

271-
end Linarith
270+
end Mathlib.Tactic.Linarith

0 commit comments

Comments
 (0)