TorchLean API

NN.Verification.ODE.Ast

Ast #

ODE RHS expression language + interval evaluator.

This is a small companion to the existing PINN PDE DSL, specialized for ODE IVPs: u'(t) = f(t, u(t)).

We use conservative interval arithmetic over α × α intervals (for any scalar α with a Context instance), with a few common transcendentals (sin, cos, exp, log) needed by the benchmarks in arXiv:2601.19818.

For the trigonometric cases we use a 1-Lipschitz enclosure around the midpoint and then clamp to [-1,1]. Over real-valued semantics this is the intended enclosure argument; executable scalar backends rely on their Context operations matching the assumed real behavior closely enough for the checker mode being used.

Expr is an AST for ODE right-hand sides f(t,u).

We cover the arithmetic and elementary functions needed by the ODE certificate format used in TorchLean: constants, the independent variable t, the state variable u, field arithmetic, and the common scalar functions sin, cos, exp, and log. Keeping this language explicit makes the checker easier to inspect while still covering the benchmark equations we want to verify.

Instances For
    @[implicit_reducible]

    An evaluation environment for Expr.

    We interpret t and u as intervals (lo,hi); everything evaluates to an interval.

    • t : α × α

      Interval for the independent time variable t.

    • u : α × α

      Interval for the current state value u(t).

    Instances For

      Interval primitives used by eval.

      These operations are written against the abstract scalar interface Context α so we can evaluate the same expression under Float or IEEE32Exec (or other executable scalars).

      @[inline]
      def NN.Verification.ODE.Ival.leBool {α : Type} [Context α] (x y : α) :

      Boolean x ≤ y test, implemented via the primitive Context.gtBool.

      Instances For
        @[inline]
        def NN.Verification.ODE.Ival.min2 {α : Type} [Context α] (a b : α) :
        α

        Binary minimum.

        Instances For
          @[inline]
          def NN.Verification.ODE.Ival.max2 {α : Type} [Context α] (a b : α) :
          α

          Binary maximum.

          Instances For
            @[inline]
            def NN.Verification.ODE.Ival.add {α : Type} [Context α] (x y : α × α) :
            α × α

            Interval addition.

            Instances For
              @[inline]
              def NN.Verification.ODE.Ival.sub {α : Type} [Context α] (x y : α × α) :
              α × α

              Interval subtraction.

              Instances For
                @[inline]
                def NN.Verification.ODE.Ival.neg {α : Type} [Context α] (x : α × α) :
                α × α

                Interval negation.

                Instances For
                  @[inline]
                  def NN.Verification.ODE.Ival.mul {α : Type} [Context α] (x y : α × α) :
                  α × α

                  Interval multiplication using the standard four-product enclosure.

                  Instances For
                    @[inline]
                    def NN.Verification.ODE.Ival.inv {α : Type} [Context α] (y : α × α) :
                    Option (α × α)

                    Interval reciprocal.

                    Returns none if the interval contains 0, because 1/x is not interval-safe across a pole.

                    Instances For
                      @[inline]
                      def NN.Verification.ODE.Ival.div {α : Type} [Context α] (x y : α × α) :
                      Option (α × α)

                      Interval division, returning none if the denominator interval contains 0.

                      Instances For
                        @[inline]
                        def NN.Verification.ODE.Ival.exp {α : Type} [Context α] (x : α × α) :
                        α × α

                        Interval exponential (monotone, so endpoints map to endpoints).

                        Instances For
                          @[inline]
                          def NN.Verification.ODE.Ival.log {α : Type} [Context α] (x : α × α) :
                          Option (α × α)

                          Interval logarithm.

                          Returns none unless the interval is strictly positive.

                          Instances For
                            @[inline]
                            def NN.Verification.ODE.Ival.sin {α : Type} [Context α] (x : α × α) :
                            α × α

                            Interval sine enclosure.

                            We use a 1‑Lipschitz enclosure around the midpoint and clamp to [-1, 1].

                            Instances For
                              @[inline]
                              def NN.Verification.ODE.Ival.cos {α : Type} [Context α] (x : α × α) :
                              α × α

                              Interval cosine enclosure.

                              Same strategy as sin: 1‑Lipschitz around the midpoint, clamped to [-1, 1].

                              Instances For

                                Interval evaluation for Expr.

                                evalWithFuel uses a fuel parameter so the evaluator is total even for malformed/self-referential expressions (though Expr itself has no recursion).

                                def NN.Verification.ODE.evalWithFuel {α : Type} [Context α] (ofFloat : Floatα) (fuel : ) (env : Env α) (e : Expr) :
                                Option (α × α)
                                Instances For

                                  Convenience wrapper with a generous fixed fuel.

                                  def NN.Verification.ODE.eval {α : Type} [Context α] (ofFloat : Floatα) (env : Env α) (e : Expr) :
                                  Option (α × α)
                                  Instances For