Documentation

Linglib.Core.Order.FourierMotzkin

Fourier-Motzkin elimination and Farkas' lemma over ℚ #

Fourier-Motzkin (FM) elimination is a variable-elimination procedure for rational linear inequalities: given a system Ax ≤ b in n+1 variables, eliminate the last variable by combining pairs of constraints (one with positive last coefficient, one with negative) to produce an equisatisfiable system in n variables.

From FM equisatisfiability we derive Farkas' lemma over ℚ: a rational linear system is either feasible or admits a nonneg certificate of infeasibility. This is the core duality theorem for rational linear programming — no topology, no completeness, no ℝ detour. (Mathlib's Farkas, ProperCone.hyperplane_separation, is the topological hyperplane-separation version over ℝ; this constructive ℚ development is complementary.)

Main declarations #

Rational linear inequalities #

def Polyhedral.dot {n : } (u v : Fin n) :

Dot product of two rational vectors indexed by Fin n.

Equations
Instances For
    structure Polyhedral.Ineq (n : ) :

    A linear inequality constraint: lhs · x ≤ rhs.

    • lhs : Fin n
    • rhs :
    Instances For
      def Polyhedral.Ineq.sat {n : } (c : Ineq n) (x : Fin n) :

      A constraint is satisfied by a point x when lhs · x ≤ rhs.

      Equations
      Instances For
        @[reducible, inline]
        abbrev Polyhedral.System (n : ) :

        A system of linear inequalities (a list of constraints).

        Equations
        Instances For
          def Polyhedral.System.feasible {n : } (S : System n) :

          A system is feasible if some point satisfies every constraint.

          Equations
          • S.feasible = ∃ (x : Fin n), cS, c.sat x
          Instances For

            Fourier-Motzkin Elimination Step #

            def Polyhedral.Ineq.lastCoeff {n : } (c : Ineq (n + 1)) :

            The last coefficient of a constraint in n+1 variables.

            Equations
            Instances For
              def Polyhedral.Ineq.project {n : } (c : Ineq (n + 1)) :

              Project a constraint to n variables (dropping the last coefficient).

              Equations
              Instances For
                def Polyhedral.Ineq.combine {n : } (cp cn : Ineq (n + 1)) :

                Combine a positive-last and negative-last constraint, eliminating the last variable.

                Equations
                Instances For
                  def Polyhedral.fmElim {n : } (S : System (n + 1)) :

                  One step of FM elimination: partition constraints by sign of the last coefficient, project the zero ones, combine all positive × negative pairs.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For

                    FM Equisatisfiability #

                    theorem Polyhedral.fmElim_equisat {n : } (S : System (n + 1)) :

                    FM equisatisfiability: the original system (n+1 variables) is feasible iff the reduced system (n variables) is feasible.

                    Forward: project out last coordinate. Backward: find t in the interval defined by positive (upper bound) and negative (lower bound) constraints; the P×N combinations guarantee the interval is nonempty.

                    Farkas' Lemma #

                    structure Polyhedral.InfeasCert {n : } (S : System n) :

                    An infeasibility certificate: nonneg weights (indexed by constraint position) such that the weighted combination of constraints yields 0·x ≤ negative.

                    • ws : Fin (List.length S)
                    • nonneg (i : Fin (List.length S)) : 0 self.ws i
                    • coeffsZero (j : Fin n) : i : Fin (List.length S), self.ws i * (List.get S i).lhs j = 0
                    • boundNeg : i : Fin (List.length S), self.ws i * (List.get S i).rhs < 0
                    Instances For
                      theorem Polyhedral.farkas {n : } (S : System n) :
                      S.feasible Nonempty (InfeasCert S)

                      Farkas' lemma over ℚ: a rational linear system is either feasible or has a nonneg certificate of infeasibility.

                      Proof by induction on n (number of variables), using FM elimination. Base case (0 variables): each constraint is 0 ≤ rhs. Inductive step: FM-eliminate → IH → extend backward or lift certificate.