Section Limit.
Context {ora: RandomOracle} {SFo: SigmaAlgebraFamily RandomHistory} {HBSFo: HistoryBasedSigF ora}.
Record RandomVarDomainStream : Type := {
raw_domains: nat -> RandomVarDomain;
rdom_same_covered: forall n, same_covered_anti_chain (raw_domains n) (raw_domains (S n));
rdom_forward: forall n, future_anti_chain (raw_domains n) (raw_domains (S n))
}.
Global Coercion raw_domains: RandomVarDomainStream >-> Funclass.
Record ConvergeDir (Omegas: RandomVarDomainStream): Type := {
raw_direction: forall n, MeasurableSubset (Omegas n);
rdir_forward: forall n, future_anti_chain (raw_direction n) (raw_direction (S n));
rdir_slow: forall n h, Omegas n h -> ~ Omegas (S n) h -> raw_direction n h
}.
Global Coercion raw_direction: ConvergeDir >-> Funclass.
Definition ProgStateStream (Omegas: RandomVarDomainStream) (state: Type) {state_sigma: SigmaAlgebra state}: Type := forall n: nat, ProgState (Omegas n) state.
Definition is_limit_domain (Omegas: RandomVarDomainStream) (lim_Omega: RandomVarDomain) : Prop :=
forall h,
lim_Omega h <->
(forall n h_low, is_fin_history h_low -> prefix_history h_low h ->
exists n' h', n' > n /\ prefix_history h_low h' /\ prefix_history h' h /\ Omegas n' h').
Definition is_limit {Omegas: RandomVarDomainStream} {lim_Omega: RandomVarDomain} {state: Type} {state_sigma: SigmaAlgebra state} (l: ProgStateStream Omegas state) (dir: ConvergeDir Omegas) (lim: ProgState lim_Omega state) : Prop :=
forall h s,
lim h s <->
(exists n, (l n) h s /\ forall n', n' >= n -> ~ dir n' h) \/
(s = NonTerminating _ /\
forall n h_low, is_fin_history h_low -> prefix_history h_low h ->
exists n' h', n' > n /\ prefix_history h_low h' /\ prefix_history h' h /\ dir n' h').
Definition limit_raw_domain (Omegas: RandomVarDomainStream): RandomHistory -> Prop :=
fun h =>
forall n h_low, is_fin_history h_low -> prefix_history h_low h ->
exists n' h', n' > n /\ prefix_history h_low h' /\ prefix_history h' h /\ Omegas n' h'.

Lemma RandomVarDomainStream_stable: forall (Omegas: RandomVarDomainStream) (dir: ConvergeDir Omegas) (n: nat) h,
Omegas n h ->
(forall m, m >= n -> ~ dir m h) ->
(forall m, m >= n -> Omegas m h).