File: Mathlib/Tactic/Linarith/Preprocessing.lean

full_name: Linarith.splitConjunctions.aux
code: /-- Processor that recursively replaces `P ∧ Q` hypotheses with the pair `P` and `Q`. -/
partial def splitConjunctions : Preprocessor 
goal: Lean.MetaM (List Lean.Expr)

full_name: Linarith.splitConjunctions
code: /-- Processor that recursively replaces `P ∧ Q` hypotheses with the pair `P` and `Q`. -/
partial def splitConjunctions : Preprocessor 
goal: Linarith.Preprocessor

full_name: Linarith.filterComparisons
code: /--
Removes any expressions that are not proofs of inequalities, equalities, or negations thereof.
-/
partial def filterComparisons : Preprocessor 
goal: Linarith.Preprocessor

full_name: Linarith.filterComparisons.aux
code: /--
Removes any expressions that are not proofs of inequalities, equalities, or negations thereof.
-/
partial def filterComparisons : Preprocessor 
goal: Lean.MetaM Bool

full_name: Linarith.flipNegatedComparison
code: /--
If `prf` is a proof of `¬ e`, where `e` is a comparison,
`flipNegatedComparison prf e` flips the comparison in `e` and returns a proof.
For example, if `prf : ¬ a < b`, ``flipNegatedComparison prf q(a < b)`` returns a proof of `a ≥ b`.
-/
def flipNegatedComparison (prf : Expr) (e : Expr) : MetaM (Option Expr) 
goal: Lean.MetaM (Option Lean.Expr)

full_name: Linarith.removeNegations
code: /--
Replaces proofs of negations of comparisons with proofs of the reversed comparisons.
For example, a proof of `¬ a < b` will become a proof of `a ≥ b`.
-/
def removeNegations : Preprocessor 
goal: Linarith.Preprocessor

full_name: Linarith.isNatProp
code: /--
`isNatProp tp` is true iff `tp` is an inequality or equality between natural numbers
or the negation thereof.
-/
partial def isNatProp (e : Expr) : Bool 
goal: Bool

full_name: Linarith.isNatCoe
code: /-- If `e` is of the form `((n : ℕ) : C)`, `isNatCoe e` returns `⟨n, C⟩`. -/
def isNatCoe (e : Expr) : Option (Expr × Expr) 
goal: Option (Lean.Expr × Lean.Expr)

full_name: Linarith.getNatComparisons
code: /--
`getNatComparisons e` returns a list of all subexpressions of `e` of the form `((t : ℕ) : C)`.
-/
partial def getNatComparisons (e : Expr) : List (Expr × Expr) 
goal: List (Lean.Expr × Lean.Expr)

full_name: Linarith.mk_natCast_nonneg_prf
code: /-- If `e : ℕ`, returns a proof of `0 ≤ (e : C)`. -/
def mk_natCast_nonneg_prf (p : Expr × Expr) : MetaM (Option Expr) 
goal: Lean.MetaM (Option Lean.Expr)

full_name: Linarith.Expr.Ord
code: /-- Ordering on `Expr`. -/
def Expr.Ord : Ord Expr 
goal: Ord Lean.Expr

full_name: Linarith.natToInt
code: /--
If `h` is an equality or inequality between natural numbers,
`natToInt` lifts this inequality to the integers.
It also adds the facts that the integers involved are nonnegative.
To avoid adding the same nonnegativity facts many times, it is a global preprocessor.
 -/
def natToInt : GlobalBranchingPreprocessor 
goal: Linarith.GlobalBranchingPreprocessor

full_name: Linarith.mkNonstrictIntProof
code: /--
If `pf` is a proof of a strict inequality `(a : ℤ) < b`,
`mkNonstrictIntProof pf` returns a proof of `a + 1 ≤ b`,
and similarly if `pf` proves a negated weak inequality.
-/
def mkNonstrictIntProof (pf : Expr) : MetaM (Option Expr) 
goal: Lean.MetaM (Option Lean.Expr)

full_name: Linarith.strengthenStrictInt
code: /-- `strengthenStrictInt h` turns a proof `h` of a strict integer inequality `t1 < t2`
into a proof of `t1 ≤ t2 + 1`. -/
def strengthenStrictInt : Preprocessor 
goal: Linarith.Preprocessor

full_name: Linarith.rearrangeComparison
code: /--
`rearrangeComparison e` takes a proof `e` of an equality, inequality, or negation thereof,
and turns it into a proof of a comparison `_ R 0`, where `R ∈ {=, ≤, <}`.
 -/
partial def rearrangeComparison (e : Expr) : MetaM (Option Expr) 
goal: Lean.MetaM (Option Lean.Expr)

full_name: Linarith.rearrangeComparison.aux
code: /--
`rearrangeComparison e` takes a proof `e` of an equality, inequality, or negation thereof,
and turns it into a proof of a comparison `_ R 0`, where `R ∈ {=, ≤, <}`.
 -/
partial def rearrangeComparison (e : Expr) : MetaM (Option Expr) 
goal: Lean.MetaM (Option Lean.Expr)

full_name: Linarith.compWithZero
code: /--
`compWithZero h` takes a proof `h` of an equality, inequality, or negation thereof,
and turns it into a proof of a comparison `_ R 0`, where `R ∈ {=, ≤, <}`.
 -/
def compWithZero : Preprocessor 
goal: Linarith.Preprocessor

full_name: Linarith.without_one_mul
code: theorem without_one_mul {M : Type*} [MulOneClass M] {a b : M} (h : 1 * a = b) : a = b 
goal: a = b

full_name: Linarith.normalizeDenominatorsLHS
code: /--
`normalizeDenominatorsLHS h lhs` assumes that `h` is a proof of `lhs R 0`.
It creates a proof of `lhs' R 0`, where all numeric division in `lhs` has been cancelled.
-/
def normalizeDenominatorsLHS (h lhs : Expr) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: Linarith.cancelDenoms
code: /--
`cancelDenoms pf` assumes `pf` is a proof of `t R 0`. If `t` contains the division symbol `/`,
it tries to scale `t` to cancel out division by numerals.
-/
def cancelDenoms : Preprocessor 
goal: Linarith.Preprocessor

full_name: Linarith.findSquares
code: /--
`findSquares s e` collects all terms of the form `a ^ 2` and `a * a` that appear in `e`
and adds them to the set `s`.
A pair `(i, true)` is added to `s` when `atoms[i]^2` appears in `e`,
and `(i, false)` is added to `s` when `atoms[i]*atoms[i]` appears in `e`.  -/
partial def findSquares (s : RBSet (Nat × Bool) lexOrd.compare) (e : Expr) :
    AtomM (RBSet (Nat × Bool) lexOrd.compare) 
goal: Mathlib.Tactic.AtomM (Batteries.RBSet (ℕ × Bool) compare)

full_name: Linarith.nlinarithExtras
code: /--
`nlinarithExtras` is the preprocessor corresponding to the `nlinarith` tactic.

* For every term `t` such that `t^2` or `t*t` appears in the input, adds a proof of `t^2 ≥ 0`
  or `t*t ≥ 0`.
* For every pair of comparisons `t1 R1 0` and `t2 R2 0`, adds a proof of `t1*t2 R 0`.

This preprocessor is typically run last, after all inputs have been canonized.
-/
def nlinarithExtras : GlobalPreprocessor 
goal: Linarith.GlobalPreprocessor

full_name: Linarith.removeNe_aux
code: /--
`removeNe_aux` case splits on any proof `h : a ≠ b` in the input,
turning it into `a < b ∨ a > b`.
This produces `2^n` branches when there are `n` such hypotheses in the input.
-/
partial def removeNe_aux : MVarId → List Expr → MetaM (List Branch) 
goal: Lean.MVarId → List Lean.Expr → Lean.MetaM (List Linarith.Branch)

full_name: Linarith.removeNe
code: /--
`removeNe` case splits on any proof `h : a ≠ b` in the input, turning it into `a < b ∨ a > b`,
by calling `linarith.removeNe_aux`.
This produces `2^n` branches when there are `n` such hypotheses in the input.
-/
def removeNe : GlobalBranchingPreprocessor 
goal: Linarith.GlobalBranchingPreprocessor

full_name: Linarith.defaultPreprocessors
code: /--
The default list of preprocessors, in the order they should typically run.
-/
def defaultPreprocessors : List GlobalBranchingPreprocessor 
goal: List Linarith.GlobalBranchingPreprocessor

full_name: Linarith.preprocess
code: /--
`preprocess pps l` takes a list `l` of proofs of propositions.
It maps each preprocessor `pp ∈ pps` over this list.
The preprocessors are run sequentially: each receives the output of the previous one.
Note that a preprocessor may produce multiple or no expressions from each input expression,
so the size of the list may change.
-/
def preprocess (pps : List GlobalBranchingPreprocessor) (g : MVarId) (l : List Expr) :
    MetaM (List Branch) 
goal: Lean.MetaM (List Linarith.Branch)