Documentation

LeanPool.ComputableReal.IsComputable

The IsComputable typeclass #

IsComputable x packages a ComputableℝSeq converging to the real number x: an explicit sequence of rational interval approximations. Closure instances (for arithmetic, powers, scalar multiples) and Decidable instances for comparisons are provided, along with a tool for lifting continuous functions defined by locally-uniformly converging rational approximations.

Since a ComputableℝSeq is an arbitrary function ℕ → ℚInterval (with convergence proofs) rather than recursive data, this is not computability in the computable-analysis sense, and the comparison instances below are classical (noncomputable, via sign information on the limit).

class IsComputable (x : ℝ) :

Type class stating that x : ℝ carries a ComputableℝSeq: an explicit sequence of rational interval approximations converging to x. Like Decidable, it carries data with it, and classically every real number admits such a sequence; its value lies in the explicit approximations it provides, not in a computability guarantee.

Instances
    @[reducible]
    def IsComputable.liftEq {x y : ℝ} (h : x = y) :

    Turns one IsComputable into another one, given a proof that they're equal. This is directly analogous to decidable_of_iff, as a way to avoid Eq.rec on data-carrying instances.

    Equations
    Instances For
      @[reducible]
      def IsComputable.lift {x : ℝ} (fr : ℝ → ℝ) (fs : ComputableℝSeq → ComputableℝSeq) (h : ∀ (a : ComputableℝSeq), (fs a).val = fr a.val) :

      Definition of lift.

      Equations
      Instances For
        @[reducible]
        def IsComputable.lift₂ {x y : ℝ} (fr : ℝ → ℝ → ℝ) (fs : ComputableℝSeq → ComputableℝSeq → ComputableℝSeq) (h : ∀ (a b : ComputableℝSeq), (fs a b).val = fr a.val b.val) :

        Definition of lift₂.

        Equations
        Instances For
          @[instance_reducible]
          Equations
          @[instance_reducible]
          Equations
          @[instance_reducible]
          Equations
          @[instance_reducible]
          Equations
          • One or more equations did not get rendered due to their size.
          @[instance_reducible]
          noncomputable instance IsComputable.instComputableDiv {x y : ℝ} [hx : IsComputable x] [hy : IsComputable y] :
          Equations
          @[instance_reducible]
          Equations
          @[instance_reducible]
          noncomputable instance IsComputable.instComputableZPow {x : ℝ} [hx : IsComputable x] (z : ℤ) :
          Equations
          • One or more equations did not get rendered due to their size.
          @[instance_reducible]
          noncomputable instance IsComputable.instComputableNSMul {x : ℝ} [hx : IsComputable x] (n : ℕ) :
          Equations
          @[instance_reducible]
          noncomputable instance IsComputable.instComputableZSMul {x : ℝ} [hx : IsComputable x] (z : ℤ) :
          Equations
          @[instance_reducible]
          noncomputable instance IsComputable.instComputableQSMul {x : ℝ} [hx : IsComputable x] (q : ℚ) :
          Equations
          @[instance_reducible]
          noncomputable instance IsComputable.instDecidableLE {x y : ℝ} [hx : IsComputable x] [hy : IsComputable y] :

          When expressions happen to be IsComputable, we can get a decidability instance by lifting them to a comparison on the ComputableℝSeqs. The comparison there is classical (it goes through the noncomputable ComputableℝSeq.sign), so this instance is noncomputable and carries no algorithmic content.

          Equations
          @[instance_reducible]
          noncomputable instance IsComputable.instDecidableEq {x y : ℝ} [hx : IsComputable x] [hy : IsComputable y] :
          Decidable (x = y)
          Equations
          @[instance_reducible]
          noncomputable instance IsComputable.instDecidableLT {x y : ℝ} [hx : IsComputable x] [hy : IsComputable y] :
          Decidable (x < y)
          Equations
          def TendstoLocallyUniformlyWithout (F : ℕ → ℚ → ℚ) (f : ℝ → ℝ) :

          This is very similar to the statement TendstoLocallyUniformly (fun n x ↦ (F n x : ℝ)) (fun (q : ℚ) ↦ f q) .atTop but that only uses neighborhoods within the rationals, which is a strictly weaker condition. This uses neighborhoods in the ambient space, the reals.

          Equations
          Instances For
            theorem Real_mk_of_TendstoLocallyUniformly' (fImpl : ℕ → ℚ → ℚ) (f : ℝ → ℝ) (hfImpl : TendstoLocallyUniformlyWithout fImpl f) (hf : Continuous f) (x : CauSeq ℚ abs) :
            ∃ (h : IsCauSeq abs fun (n : ℕ) => fImpl n (↑x n)), Real.mk ⟨fun (n : ℕ) => fImpl n (↑x n), h⟩ = f (Real.mk x)
            def ComputableℝSeq.ofTendstoLocallyUniformlyContinuous {f : ℝ → ℝ} (hf : Continuous f) (fImpl : ℕ → NonemptyInterval ℚ → NonemptyInterval ℚ) (fImpl_l fImpl_u : ℕ → ℚ → ℚ) (hlb : ∀ (n : ℕ) (q : NonemptyInterval ℚ), ∀ x ∈ q, ↑(fImpl_l n q.toProd.1) ≤ f x) (hub : ∀ (n : ℕ) (q : NonemptyInterval ℚ), ∀ x ∈ q, f x ≤ ↑(fImpl_u n q.toProd.2)) (hImplDef : ∀ (n : ℕ) (q : NonemptyInterval ℚ), fImpl n q = { fst := fImpl_l n q.toProd.1, snd := fImpl_u n q.toProd.2, fst_le_snd := ⋯ }) (hTLU_l : TendstoLocallyUniformlyWithout fImpl_l f) (hTLU_u : TendstoLocallyUniformlyWithout fImpl_u f) (x : ComputableℝSeq) :

            Definition of ofTendstoLocallyUniformlyContinuous.

            Equations
            Instances For
              @[simp]
              theorem ComputableℝSeq.val_ofTendstoLocallyUniformlyContinuous (f : ℝ → ℝ) (hf : Continuous f) (fI : ℕ → NonemptyInterval ℚ → NonemptyInterval ℚ) (fl fu : ℕ → ℚ → ℚ) (h₁ : ∀ (n : ℕ) (q : NonemptyInterval ℚ), ∀ x ∈ q, ↑(fl n q.toProd.1) ≤ f x) (h₂ : ∀ (n : ℕ) (q : NonemptyInterval ℚ), ∀ x ∈ q, f x ≤ ↑(fu n q.toProd.2)) (h₃ : ∀ (n : ℕ) (q : NonemptyInterval ℚ), fI n q = { fst := fl n q.toProd.1, snd := fu n q.toProd.2, fst_le_snd := ⋯ }) (h₄ : TendstoLocallyUniformlyWithout fl f) (h₅ : TendstoLocallyUniformlyWithout fu f) (a : ComputableℝSeq) :
              (ofTendstoLocallyUniformlyContinuous hf fI fl fu h₁ h₂ h₃ h₄ h₅ a).val = f a.val
              def Rat.toDecimal (q : ℚ) (prec : ℕ := 20) :

              Definition of toDecimal.

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