-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More work towards proving farkas lemma
- Loading branch information
Showing
8 changed files
with
129 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 5 additions & 6 deletions
11
...dralCombinatorics/Polyhedron/Duality.lean → PolyhedralCombinatorics/Duality/Farkas.lean
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
import PolyhedralCombinatorics.Projection.FourierMotzkin | ||
|
||
import Mathlib.LinearAlgebra.Matrix.DotProduct | ||
|
||
namespace LinearSystem.Duality | ||
open Polyhedron Matrix | ||
namespace LinearSystem | ||
open Matrix | ||
|
||
variable {𝔽 : Type*} [LinearOrderedField 𝔽] {m n : ℕ} | ||
|
||
theorem farkas_lemma {A : Matrix (Fin m) (Fin n) 𝔽} {b : Fin m → 𝔽} | ||
: (∃ x, x ∈ P(A, b)) ↔ ∀ y, y ≥ 0 → y ᵥ* A = 0 → y ⬝ᵥ b ≥ 0 := by | ||
theorem farkas_lemma {S : LinearSystem 𝔽 n} | ||
: (∃ x, x ∈ S.solutions) ↔ ∀ y ≥ 0, y ᵥ* S.mat = 0 → y ⬝ᵥ S.vec ≥ 0 := by | ||
constructor <;> intro h | ||
. intro y y_nonneg hy | ||
obtain ⟨x, hx⟩ := h | ||
rw [mem_ofLinearSystem_of] at hx | ||
have := dotProduct_le_dotProduct_of_nonneg_left hx y_nonneg | ||
rw [dotProduct_mulVec, hy, zero_dotProduct] at this | ||
assumption | ||
. by_contra hc | ||
simp_rw [not_exists, ←Polyhedron.eq_empty_iff] at hc | ||
sorry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import PolyhedralCombinatorics.LinearSystem.LinearConstraints | ||
|
||
namespace LinearSystem | ||
open Matrix | ||
|
||
variable {𝔽} [LinearOrderedField 𝔽] {n : ℕ} | ||
|
||
open Lean.Parser Lean.Elab.Term | ||
|
||
/-- Syntax for addressing variables in linear constraints. | ||
`x_[n]` is shorthand for `Pi.single n 1`. -/ | ||
notation "x_[" n "]" => Pi.single (n : Fin _) 1 | ||
|
||
/-- Syntax category for linear constraints used to define polyhedra. -/ | ||
declare_syntax_cat linConstraint | ||
syntax:60 term:61 " ≤ " term : linConstraint | ||
syntax:60 term:61 " <= " term : linConstraint | ||
syntax:60 term:61 " = " term : linConstraint | ||
syntax:60 term:61 " ≥ " term : linConstraint | ||
syntax:60 term:61 " >= " term : linConstraint | ||
|
||
/-- Syntax for declaring polyhedra as systems of linear constraints. -/ | ||
syntax:max (name := linSystem) | ||
"!L" ("[" term:90 "^" term "]")? "{" linConstraint,*,? "}" : term | ||
|
||
macro_rules | ||
| `(!L[$t^$n]{$[$constraints],*}) => `((!L{$constraints,*} : LinearSystem $t $n)) | ||
| `(!L{$[$constraints],*}) => do | ||
let constraints ← constraints.mapM (fun | ||
| `(linConstraint| $x:term ≤ $y:term) => `(LinearConstraint.le $x $y) | ||
| `(linConstraint| $x:term <= $y:term) => `(LinearConstraint.le $x $y) | ||
| `(linConstraint| $x:term = $y:term) => `(LinearConstraint.eq $x $y) | ||
| `(linConstraint| $x:term ≥ $y:term) => `(LinearConstraint.ge $x $y) | ||
| `(linConstraint| $x:term >= $y:term) => `(LinearConstraint.ge $x $y) | ||
| _ => Lean.Macro.throwUnsupported) | ||
`(ofConstraints [$constraints,*]) | ||
|
||
example := !L[ℚ^2]{2 • x_[1] ≤ 1} | ||
example : LinearSystem 𝔽 2 := !L{2 • x_[1] ≤ 1, x_[0] + x_[1] = 0} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters