Documentation

PrimeCert.Interval

Interval checking by binary search #

The check_interval tactic proves goals of the form ∀ n, lo ≤ n → n < hi → P n or ∀ n, lo ≤ n → n < hi → n % b = r → P n by building a balanced binary tree of eagerReduce proof terms, one per value in the range.

Tools for automation of ∀ n, lo ≤ n → n < hi → P n #

theorem forall_start {P : Prop} {hi : } (ih : ∀ (n : ), 0 nn < hiP n) (n : ) :
n < hiP n
theorem forall_step {P : Prop} {curr hi : } (next : ) (now : P curr) (h : curr.succ = next) (ih : ∀ (n : ), next nn < hiP n) (n : ) :
curr nn < hiP n
theorem forall_bisect {P : Prop} {lo hi : } (mi : ) (h₁ : ∀ (n : ), lo nn < miP n) (h₂ : ∀ (n : ), mi nn < hiP n) (n : ) :
lo nn < hiP n
theorem forall_succ {P : Prop} {lo hi : } (h : P lo) (spec : hi.ble lo.succ = true := by rfl) (n : ) :
lo nn < hiP n
theorem forall_last {P : Prop} {hi : } (n : ) :
hi nn < hiP n
theorem forall_exceed {P : Prop} {lo hi : } (h : hi.ble lo = true) (n : ) :
lo nn < hiP n

Tools for automation of ∀ n, lo ≤ n → n < hi → n % b = r → P n #

theorem forall_mod_start {P : Prop} {hi b r : } (ih : ∀ (n : ), r nn < hin % b = rP n) (n : ) :
n < hin % b = rP n
theorem forall_mod_step {P : Prop} {lo hi b r : } (next : ) (now : P lo) (ih : ∀ (n : ), next nn < hin % b = rP n) (spec₁ : lo + b = next := by rfl) (spec₂ : lo % b = r := by rfl) (n : ) :
lo nn < hin % b = rP n
theorem forall_mod_succ {P : Prop} {lo hi b r : } (now : P lo) (spec₁ : lo % b = r := by rfl) (spec₂ : hi.ble (lo.add b) = true := by rfl) (n : ) :
lo nn < hin % b = rP n
theorem forall_mod_bisect {P : Prop} {lo hi b r : } (mi : ) (ih₁ : ∀ (n : ), lo nn < min % b = rP n) (ih₂ : ∀ (n : ), mi nn < hin % b = rP n) (n : ) :
lo nn < hin % b = rP n
theorem forall_mod_exceed {P : Prop} {lo hi b r : } (h : hi.ble lo = true) (n : ) :
lo nn < hin % b = rP n
@[irreducible]
def makeForallBisectLoHi (P : Lean.Expr) (lo hi : ) (pf : Lean.Expr) :

An expression to prove statement of the form ∀ n, lo ≤ n → n < hi → P n

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    def makeForallBisectHi (P : Lean.Expr) (hi : ) (pf : Lean.Expr) :

    An expression to prove statement of the form ∀ n < hi → P n

    Equations
    Instances For
      partial def makeForallModBisectLoHi (P : Lean.Expr) (lo hi b r : ) (bE rE : Lean.Expr) (pf : Lean.Expr) :

      An expression to prove statement of the form ∀ n, lo ≤ n → n < hi → n % b = r → P n. This always assumes lo % b = r.

      def makeForallModBisectHi (P : Lean.Expr) (hi b r : ) (bE rE : Lean.Expr) (pf : Lean.Expr) :

      An expression to prove statement of the form ∀ n < hi → n % b = r → P n.

      Equations
      Instances For

        Tactic to prove bounded universal statements by exhaustive kernel checking. Accepts four goal shapes:

        • ∀ n < hi, P n
        • ∀ n, lo ≤ n → n < hi → P n
        • ∀ n < hi, n % b = r → P n
        • ∀ n, lo ≤ n → n < hi → n % b = r → P n

        The predicate P n must reduce to true (via eagerReduce) for every n in range. The tactic builds a balanced binary tree of proof terms, so the elaboration depth is logarithmic in the range size.

        -- Check that wieferichKR is false or mirimanoffKR is false for all n ≡ 1 (mod 6), n < 6000:
        theorem wieferich_mirimanoff₁ : ∀ n < 6000, n % 6 = 1 →
            (wieferichKR n).not'.or' (mirimanoffKR n).not' := by
          check_interval
        
        Equations
        Instances For