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

full_name: Linarith.SimplexAlgorithm.UsableInSimplexAlgorithm.setElem
code: /--
Specification for matrix types over ℚ which can be used in the Gauss Elimination and the Simplex
Algorithm. It was introduced to unify dense matrices and sparse matrices.
-/
class UsableInSimplexAlgorithm (α : Nat → Nat → Type) where
  /-- Returns `mat[i, j]`. -/
  getElem {n m : Nat} (mat : α n m) (i j : Nat) : Rat
  /-- Sets `mat[i, j]`. -/
  setElem {n m : Nat} (mat : α n m) (i j : Nat) (v : Rat) : α n m
  /-- Returns the list of elements of `mat` in the form `(i, j, mat[i, j])`. -/
  getValues {n m : Nat} (mat : α n m) : List (Nat × Nat × Rat)
  /-- Creates a matrix from a list of elements in the form `(i, j, mat[i, j])`. -/
  ofValues {n m : Nat} (values : List (Nat × Nat × Rat)) : α n m
  /-- Swaps two rows. -/
  swapRows {n m : Nat} (mat : α n m) (i j : Nat) : α n m
  /-- Subtracts `i`-th row multiplied by `coef` from `j`-th row. -/
  subtractRow {n m : Nat} (mat : α n m) (i j : Nat) (coef : Rat) : α n m
  /-- Divides the `i`-th row by `coef`. -/
  divideRow {n m : Nat} (mat : α n m) (i : Nat) (coef : Rat) : α n m
goal: α n m

full_name: Linarith.SimplexAlgorithm.UsableInSimplexAlgorithm.getValues
code: /--
Specification for matrix types over ℚ which can be used in the Gauss Elimination and the Simplex
Algorithm. It was introduced to unify dense matrices and sparse matrices.
-/
class UsableInSimplexAlgorithm (α : Nat → Nat → Type) where
  /-- Returns `mat[i, j]`. -/
  getElem {n m : Nat} (mat : α n m) (i j : Nat) : Rat
  /-- Sets `mat[i, j]`. -/
  setElem {n m : Nat} (mat : α n m) (i j : Nat) (v : Rat) : α n m
  /-- Returns the list of elements of `mat` in the form `(i, j, mat[i, j])`. -/
  getValues {n m : Nat} (mat : α n m) : List (Nat × Nat × Rat)
  /-- Creates a matrix from a list of elements in the form `(i, j, mat[i, j])`. -/
  ofValues {n m : Nat} (values : List (Nat × Nat × Rat)) : α n m
  /-- Swaps two rows. -/
  swapRows {n m : Nat} (mat : α n m) (i j : Nat) : α n m
  /-- Subtracts `i`-th row multiplied by `coef` from `j`-th row. -/
  subtractRow {n m : Nat} (mat : α n m) (i j : Nat) (coef : Rat) : α n m
  /-- Divides the `i`-th row by `coef`. -/
  divideRow {n m : Nat} (mat : α n m) (i : Nat) (coef : Rat) : α n m
goal: List (Nat × Nat × Rat)

full_name: Linarith.SimplexAlgorithm.UsableInSimplexAlgorithm.getElem
code: /--
Specification for matrix types over ℚ which can be used in the Gauss Elimination and the Simplex
Algorithm. It was introduced to unify dense matrices and sparse matrices.
-/
class UsableInSimplexAlgorithm (α : Nat → Nat → Type) where
  /-- Returns `mat[i, j]`. -/
  getElem {n m : Nat} (mat : α n m) (i j : Nat) : Rat
  /-- Sets `mat[i, j]`. -/
  setElem {n m : Nat} (mat : α n m) (i j : Nat) (v : Rat) : α n m
  /-- Returns the list of elements of `mat` in the form `(i, j, mat[i, j])`. -/
  getValues {n m : Nat} (mat : α n m) : List (Nat × Nat × Rat)
  /-- Creates a matrix from a list of elements in the form `(i, j, mat[i, j])`. -/
  ofValues {n m : Nat} (values : List (Nat × Nat × Rat)) : α n m
  /-- Swaps two rows. -/
  swapRows {n m : Nat} (mat : α n m) (i j : Nat) : α n m
  /-- Subtracts `i`-th row multiplied by `coef` from `j`-th row. -/
  subtractRow {n m : Nat} (mat : α n m) (i j : Nat) (coef : Rat) : α n m
  /-- Divides the `i`-th row by `coef`. -/
  divideRow {n m : Nat} (mat : α n m) (i : Nat) (coef : Rat) : α n m
goal: Rat

full_name: Linarith.SimplexAlgorithm.UsableInSimplexAlgorithm
code: /--
Specification for matrix types over ℚ which can be used in the Gauss Elimination and the Simplex
Algorithm. It was introduced to unify dense matrices and sparse matrices.
-/
class UsableInSimplexAlgorithm (α : Nat → Nat → Type) where
  /-- Returns `mat[i, j]`. -/
  getElem {n m : Nat} (mat : α n m) (i j : Nat) : Rat
  /-- Sets `mat[i, j]`. -/
  setElem {n m : Nat} (mat : α n m) (i j : Nat) (v : Rat) : α n m
  /-- Returns the list of elements of `mat` in the form `(i, j, mat[i, j])`. -/
  getValues {n m : Nat} (mat : α n m) : List (Nat × Nat × Rat)
  /-- Creates a matrix from a list of elements in the form `(i, j, mat[i, j])`. -/
  ofValues {n m : Nat} (values : List (Nat × Nat × Rat)) : α n m
  /-- Swaps two rows. -/
  swapRows {n m : Nat} (mat : α n m) (i j : Nat) : α n m
  /-- Subtracts `i`-th row multiplied by `coef` from `j`-th row. -/
  subtractRow {n m : Nat} (mat : α n m) (i j : Nat) (coef : Rat) : α n m
  /-- Divides the `i`-th row by `coef`. -/
  divideRow {n m : Nat} (mat : α n m) (i : Nat) (coef : Rat) : α n m
goal: Type

full_name: Linarith.SimplexAlgorithm.UsableInSimplexAlgorithm.divideRow
code: /--
Specification for matrix types over ℚ which can be used in the Gauss Elimination and the Simplex
Algorithm. It was introduced to unify dense matrices and sparse matrices.
-/
class UsableInSimplexAlgorithm (α : Nat → Nat → Type) where
  /-- Returns `mat[i, j]`. -/
  getElem {n m : Nat} (mat : α n m) (i j : Nat) : Rat
  /-- Sets `mat[i, j]`. -/
  setElem {n m : Nat} (mat : α n m) (i j : Nat) (v : Rat) : α n m
  /-- Returns the list of elements of `mat` in the form `(i, j, mat[i, j])`. -/
  getValues {n m : Nat} (mat : α n m) : List (Nat × Nat × Rat)
  /-- Creates a matrix from a list of elements in the form `(i, j, mat[i, j])`. -/
  ofValues {n m : Nat} (values : List (Nat × Nat × Rat)) : α n m
  /-- Swaps two rows. -/
  swapRows {n m : Nat} (mat : α n m) (i j : Nat) : α n m
  /-- Subtracts `i`-th row multiplied by `coef` from `j`-th row. -/
  subtractRow {n m : Nat} (mat : α n m) (i j : Nat) (coef : Rat) : α n m
  /-- Divides the `i`-th row by `coef`. -/
  divideRow {n m : Nat} (mat : α n m) (i : Nat) (coef : Rat) : α n m
goal: α n m

full_name: Linarith.SimplexAlgorithm.UsableInSimplexAlgorithm.subtractRow
code: /--
Specification for matrix types over ℚ which can be used in the Gauss Elimination and the Simplex
Algorithm. It was introduced to unify dense matrices and sparse matrices.
-/
class UsableInSimplexAlgorithm (α : Nat → Nat → Type) where
  /-- Returns `mat[i, j]`. -/
  getElem {n m : Nat} (mat : α n m) (i j : Nat) : Rat
  /-- Sets `mat[i, j]`. -/
  setElem {n m : Nat} (mat : α n m) (i j : Nat) (v : Rat) : α n m
  /-- Returns the list of elements of `mat` in the form `(i, j, mat[i, j])`. -/
  getValues {n m : Nat} (mat : α n m) : List (Nat × Nat × Rat)
  /-- Creates a matrix from a list of elements in the form `(i, j, mat[i, j])`. -/
  ofValues {n m : Nat} (values : List (Nat × Nat × Rat)) : α n m
  /-- Swaps two rows. -/
  swapRows {n m : Nat} (mat : α n m) (i j : Nat) : α n m
  /-- Subtracts `i`-th row multiplied by `coef` from `j`-th row. -/
  subtractRow {n m : Nat} (mat : α n m) (i j : Nat) (coef : Rat) : α n m
  /-- Divides the `i`-th row by `coef`. -/
  divideRow {n m : Nat} (mat : α n m) (i : Nat) (coef : Rat) : α n m
goal: α n m

full_name: Linarith.SimplexAlgorithm.UsableInSimplexAlgorithm.swapRows
code: /--
Specification for matrix types over ℚ which can be used in the Gauss Elimination and the Simplex
Algorithm. It was introduced to unify dense matrices and sparse matrices.
-/
class UsableInSimplexAlgorithm (α : Nat → Nat → Type) where
  /-- Returns `mat[i, j]`. -/
  getElem {n m : Nat} (mat : α n m) (i j : Nat) : Rat
  /-- Sets `mat[i, j]`. -/
  setElem {n m : Nat} (mat : α n m) (i j : Nat) (v : Rat) : α n m
  /-- Returns the list of elements of `mat` in the form `(i, j, mat[i, j])`. -/
  getValues {n m : Nat} (mat : α n m) : List (Nat × Nat × Rat)
  /-- Creates a matrix from a list of elements in the form `(i, j, mat[i, j])`. -/
  ofValues {n m : Nat} (values : List (Nat × Nat × Rat)) : α n m
  /-- Swaps two rows. -/
  swapRows {n m : Nat} (mat : α n m) (i j : Nat) : α n m
  /-- Subtracts `i`-th row multiplied by `coef` from `j`-th row. -/
  subtractRow {n m : Nat} (mat : α n m) (i j : Nat) (coef : Rat) : α n m
  /-- Divides the `i`-th row by `coef`. -/
  divideRow {n m : Nat} (mat : α n m) (i : Nat) (coef : Rat) : α n m
goal: α n m

full_name: Linarith.SimplexAlgorithm.UsableInSimplexAlgorithm.ofValues
code: /--
Specification for matrix types over ℚ which can be used in the Gauss Elimination and the Simplex
Algorithm. It was introduced to unify dense matrices and sparse matrices.
-/
class UsableInSimplexAlgorithm (α : Nat → Nat → Type) where
  /-- Returns `mat[i, j]`. -/
  getElem {n m : Nat} (mat : α n m) (i j : Nat) : Rat
  /-- Sets `mat[i, j]`. -/
  setElem {n m : Nat} (mat : α n m) (i j : Nat) (v : Rat) : α n m
  /-- Returns the list of elements of `mat` in the form `(i, j, mat[i, j])`. -/
  getValues {n m : Nat} (mat : α n m) : List (Nat × Nat × Rat)
  /-- Creates a matrix from a list of elements in the form `(i, j, mat[i, j])`. -/
  ofValues {n m : Nat} (values : List (Nat × Nat × Rat)) : α n m
  /-- Swaps two rows. -/
  swapRows {n m : Nat} (mat : α n m) (i j : Nat) : α n m
  /-- Subtracts `i`-th row multiplied by `coef` from `j`-th row. -/
  subtractRow {n m : Nat} (mat : α n m) (i j : Nat) (coef : Rat) : α n m
  /-- Divides the `i`-th row by `coef`. -/
  divideRow {n m : Nat} (mat : α n m) (i : Nat) (coef : Rat) : α n m
goal: α n m

full_name: Linarith.SimplexAlgorithm.instGetElemProdNatRatAndLtFstSndOfUsableInSimplexAlgorithm
code: instance (n m : Nat) (matType : Nat → Nat → Type) [UsableInSimplexAlgorithm matType] :
    GetElem (matType n m) (Nat × Nat) Rat fun _ p => p.1 < n ∧ p.2 < m 
goal: GetElem (matType n m) (Nat × Nat) Rat fun x p => p.fst < n ∧ p.snd < m

full_name: Linarith.SimplexAlgorithm.DenseMatrix
code: /--
Structure for matrices over ℚ.

So far it is just a 2d-array carrying dimensions (that are supposed to match with the actual
dimensions of `data`), but the plan is to add some `Prop`-data and make the structure strict and
safe.

Note: we avoid using the `Matrix` from `Mathlib.Data.Matrix` because it is far more efficient to
store matrix as its entries than as function between `Fin`-s.
-/
structure DenseMatrix (n m : Nat) where
  /-- The content of the matrix. -/
  data : Array (Array Rat)
goal: Type

full_name: Linarith.SimplexAlgorithm.DenseMatrix.data
code: /--
Structure for matrices over ℚ.

So far it is just a 2d-array carrying dimensions (that are supposed to match with the actual
dimensions of `data`), but the plan is to add some `Prop`-data and make the structure strict and
safe.

Note: we avoid using the `Matrix` from `Mathlib.Data.Matrix` because it is far more efficient to
store matrix as its entries than as function between `Fin`-s.
-/
structure DenseMatrix (n m : Nat) where
  /-- The content of the matrix. -/
  data : Array (Array Rat)
goal: Array (Array Rat)

full_name: Linarith.SimplexAlgorithm.instUsableInSimplexAlgorithmDenseMatrix
code: instance : UsableInSimplexAlgorithm DenseMatrix 
goal: Linarith.SimplexAlgorithm.UsableInSimplexAlgorithm Linarith.SimplexAlgorithm.DenseMatrix

full_name: Linarith.SimplexAlgorithm.SparseMatrix
code: /--
Structure for sparse matrices over ℚ, implemented as an array of hashmaps, containing only nonzero
values.
-/
structure SparseMatrix (n m : Nat) where
  /-- The content of the matrix. -/
  data : Array <| Lean.HashMap Nat Rat
goal: Type

full_name: Linarith.SimplexAlgorithm.SparseMatrix.data
code: /--
Structure for sparse matrices over ℚ, implemented as an array of hashmaps, containing only nonzero
values.
-/
structure SparseMatrix (n m : Nat) where
  /-- The content of the matrix. -/
  data : Array <| Lean.HashMap Nat Rat
goal: Array (Lean.HashMap Nat Rat)

full_name: Linarith.SimplexAlgorithm.instUsableInSimplexAlgorithmSparseMatrix
code: instance : UsableInSimplexAlgorithm SparseMatrix 
goal: Linarith.SimplexAlgorithm.UsableInSimplexAlgorithm Linarith.SimplexAlgorithm.SparseMatrix

full_name: Linarith.SimplexAlgorithm.Tableau
code: /--
`Tableau` is a structure the Simplex Algorithm operates on. The `i`-th row of `mat` expresses the
variable `basic[i]` as a linear combination of variables from `free`.
-/
structure Tableau (matType : Nat → Nat → Type) [UsableInSimplexAlgorithm matType] where
  /-- Array containing the basic variables' indexes -/
  basic : Array Nat
  /-- Array containing the free variables' indexes -/
  free : Array Nat
  /-- Matrix of coefficients the basic variables expressed through the free ones. -/
  mat : matType basic.size free.size
goal: Type

full_name: Linarith.SimplexAlgorithm.Tableau.mat
code: /--
`Tableau` is a structure the Simplex Algorithm operates on. The `i`-th row of `mat` expresses the
variable `basic[i]` as a linear combination of variables from `free`.
-/
structure Tableau (matType : Nat → Nat → Type) [UsableInSimplexAlgorithm matType] where
  /-- Array containing the basic variables' indexes -/
  basic : Array Nat
  /-- Array containing the free variables' indexes -/
  free : Array Nat
  /-- Matrix of coefficients the basic variables expressed through the free ones. -/
  mat : matType basic.size free.size
goal: matType self.basic.size self.free.size

full_name: Linarith.SimplexAlgorithm.Tableau.basic
code: /--
`Tableau` is a structure the Simplex Algorithm operates on. The `i`-th row of `mat` expresses the
variable `basic[i]` as a linear combination of variables from `free`.
-/
structure Tableau (matType : Nat → Nat → Type) [UsableInSimplexAlgorithm matType] where
  /-- Array containing the basic variables' indexes -/
  basic : Array Nat
  /-- Array containing the free variables' indexes -/
  free : Array Nat
  /-- Matrix of coefficients the basic variables expressed through the free ones. -/
  mat : matType basic.size free.size
goal: Array Nat

full_name: Linarith.SimplexAlgorithm.Tableau.free
code: /--
`Tableau` is a structure the Simplex Algorithm operates on. The `i`-th row of `mat` expresses the
variable `basic[i]` as a linear combination of variables from `free`.
-/
structure Tableau (matType : Nat → Nat → Type) [UsableInSimplexAlgorithm matType] where
  /-- Array containing the basic variables' indexes -/
  basic : Array Nat
  /-- Array containing the free variables' indexes -/
  free : Array Nat
  /-- Matrix of coefficients the basic variables expressed through the free ones. -/
  mat : matType basic.size free.size
goal: Array Nat