Stopping times and the three estimators
DefinitionFormalizedScopeReach_TimesThe first outcome time is the first one-based token position occupied by the outcome, or infinity if it does not occur. The threshold time is the first prefix length at which the threshold predicate holds, or infinity if it never holds within the list. The model rules out crossing at the empty prefix. Monte Carlo averages the indicators of the strict event that the first outcome precedes that threshold. The definitions also expose SCOPE and REACH under their paper symbols, and specify the original target probability. The threshold time is not reassigned after an outcome.
import Definitions.Def_FormalizedScopeReach_REACH
import Mathlib.Data.ENat.Basic
noncomputable section
open scoped BigOperators ENNReal
open MeasureTheory
namespace FormalizedScopeReach
variable {V : Type}
/-- First occurrence of the outcome, using the paper's indices 1, 2, ... . -/
def T_O (M : Model V) (x : Timeline V) : ℕ∞ := by
classical
exact if M.outcome ∈ x then (x.idxOf M.outcome + 1 : ℕ) else ⊤
/-- First prefix that exceeds the time threshold. All prefix tokens may be used. -/
def T_E (M : Model V) (x : Timeline V) : ℕ∞ := by
classical
exact if h : ∃ n : ℕ, n ≤ x.length ∧ M.stop (x.take n) then
(Nat.find h : ℕ) else ⊤
/-- The paper's Monte Carlo estimator M₀, on n sampled timelines. -/
def M₀ (M : Model V) (n : ℕ) (xs : Fin n → Timeline V) : ℝ := by
classical
exact (∑ i, if T_O M (xs i) < T_E M (xs i) then (1 : ℝ) else 0) / (n : ℝ)
/-- The SCOPE estimator 𝒮. -/
def 𝒮 (M : Model V) (n : ℕ) (xs : Fin n → Timeline V) : ℝ :=
scopeEstimator M n xs
/-- The REACH estimator ℛ, evaluated on outcome-avoiding timelines. -/
def ℛ (M : Model V) (n : ℕ) (xs : Fin n → Timeline V) : ℝ :=
reachEstimator M n xs
/-- Probability to be estimated: the first outcome precedes the time threshold. -/
def targetProbability (M : Model V) : ℝ :=
((originalLaw M) {x | T_O M x < T_E M x}).toReal
end FormalizedScopeReach
Read-back
What the Lean code literally says, in plain math · GPT-6 (Codex independent sub-agent)
Blind read-back: Def_FormalizedScopeReach_Times.lean
T_O
For any type , any model with distinguished element , a probability mass function on assigned to every finite list, and a stopping predicate, and any finite list over , is the position of the first occurrence of in , counted starting at , if occurs, and is otherwise. Its values belong to . Thus a present outcome has value between and the length of , the empty list has value , repeated occurrences use the first position, and no occurrence produces value . There is no terminality or transition-probability requirement, and the stopping predicate does not enter this definition. The model includes the requirement that its stopping predicate is false on the empty list.
T_E
For any type , any model with distinguished element, transition probability mass functions on every finite list, and stopping predicate , and any finite list over of length , is the least natural number such that and holds, if such a number exists, and is otherwise; means the first entries. Its values are in . The search includes and , but the model requires , so never satisfies the condition. Consequently the value is either a natural number from through or , and the empty list has value . The distinguished element and transition probability mass functions play no role in the search, and the stopping predicate, subject to being false on the empty list, has no imposed threshold structure or monotonicity; terminality of the supplied list is not required.
M₀
For any type , any model with distinguished element , transition probability mass functions, and stopping predicate , any natural number , and any family of finite lists over indexed by , is the real number . Here is the first position at which occurs in , counted from , or if it does not occur; is the least natural number between and the length of inclusive for which holds, or if there is none; the indicator is when the displayed strict inequality holds and otherwise. The comparison uses the order on : every finite value is less than , and is false. An outcome at the same position as the first stopped prefix is excluded, an outcome present with no stopped prefix is included, and an absent outcome contributes zero. The first stopped-prefix time cannot be zero because the model requires the empty prefix not to be stopped. If a list satisfies exactly first at its full length, a first outcome at its final entry is excluded. No sample distribution, independence, terminality, or positive path mass is assumed. The case is included and has value by real division of the empty sum by zero.
𝒮
For any type , any model with distinguished element , transition probability mass functions of total mass on , and stopping predicate , any natural number , and any family of finite lists over indexed by , is defined to be the real number , where is the list length, is the first entries, probabilities are interpreted as their finite real values, and the indicator is or according to its condition. Thus each contribution checks that its preceding prefix is not stopped and has no occurrence of , without any condition involving ; the stopping predicate is checked separately at each prefix. All finite lists are admissible, without a sampling-law, independence, terminality, or positive-path-weight assumption. Empty lists contribute zero. The natural number may be zero, and the whole expression then equals by the empty-sum and real-division conventions. The model includes the requirement that its stopping predicate is false on the empty list.
ℛ
For any type , any model with distinguished element , transition probability mass functions of total mass on , and a stopping predicate, any natural number , and any family of finite lists over indexed by , is defined to be the real number , where is the length, is the prefix of length , and probabilities are interpreted as their finite real values. The stopping predicate is not used in this expression, and no requirement says that a supplied list avoids , is terminal, has positive path weight, or is sampled from any particular measure. No independence assumption is present. The empty product is , so an empty list contributes zero. When , the value is by the empty outer sum and total real division. The model includes the requirement that its stopping predicate is false on the empty list.
targetProbability
For any type and any model with distinguished element , transition probability mass functions of total mass on , and stopping predicate , targetProbability is the real conversion of the measure of on the space of all finite lists over , where every subset is measurable. Here is the first occurrence position of counted from , or if absent, and is the least with and , or if absent, for a list of length and prefixes . The measure is the sum of point masses with weight at lists satisfying and for every , and weight zero at all other lists; no normalization or total-mass-one assumption is supplied. Equivalently the defining mass sum includes only such terminal lists whose first occurrence of is at a position strictly less than their length, since their first stopped prefix has length . A first occurrence at the final entry, an absent outcome, and the empty list are excluded. The comparison treats every finite value as less than and does not have . The real conversion preserves finite extended nonnegative values and sends to . The model includes the requirement that its stopping predicate is false on the empty list.
Confirmed by the mission captain (proposal self-audit).