Definition fin_history {ora: RandomOracle} (h: list RandomQA) : RandomHistory.
exists (fun n => nth_error h n).
intros.
rewrite nth_error_None_iff in H0 |- *.
omega.
Defined.
Definition inf_history {ora: RandomOracle} (h: nat -> RandomQA) : RandomHistory.
exists (fun n => Some (h n)).
intros.
congruence.
Defined.
Definition fstn_history {ora: RandomOracle} (n: nat) (h: RandomHistory) : RandomHistory.
exists (fun m => if le_lt_dec n m then None else h m).
intros.
destruct (le_lt_dec n x), (le_lt_dec n y); try congruence.
+ omega.
+ apply (history_sound1 h x y); auto; omega.
Defined.
Definition history_coincide {ora: RandomOracle} (n: nat) (h1 h2: RandomHistory): Prop :=
forall m, m < n -> h1 m = h2 m.
(* Definition history_cons {ora: RandomOracle} (h1: RandomHistory) (a: RandomQA) (h2: RandomHistory): Prop := exists n, history_coincide n h1 h2 /\ h1 n = None /\ h2 n = Some a /\ h2 (S n) = None. *)
Definition history_app {ora: RandomOracle} (h1 h2 h: RandomHistory): Prop :=
exists n,
h1 n = None /\
history_coincide n h1 h /\
(forall m, h (m + n) = h2 m).
Definition is_fin_history {ora: RandomOracle} (h: RandomHistory): Prop :=
exists n, h n = None.
Definition is_inf_history {ora: RandomOracle} (h: RandomHistory): Prop :=
forall n, h n <> None.
Definition is_n_history {ora: RandomOracle} (n: nat) (h: RandomHistory): Prop :=
h n = None /\ forall n', n' < n -> h n' <> None.
Definition is_at_least_n_history {ora: RandomOracle} (n: nat) (h: RandomHistory): Prop :=
forall n', n' < n -> h n' <> None.

Lemma fin_history_fin {ora: RandomOracle}: forall l, is_fin_history (fin_history l).