Definition contextual_consi {ora: RandomOracle} (d: RandomHistory -> Prop) (h: RandomHistory): Prop :=
forall h', d h' -> conflict_history h h' -> False.
Definition nth_layer_pre_extension {ora: RandomOracle} (n: nat) (d: RandomHistory -> Prop): RandomHistory -> Prop :=
fun h => d h \/ (is_n_history n h /\ contextual_consi d h).
Fixpoint n_layers_pre_extension {ora: RandomOracle} (n: nat) (d: RandomHistory -> Prop): RandomHistory -> Prop :=
match n with
| 0 => d
| S n => nth_layer_pre_extension n (n_layers_pre_extension n d)
end.
Definition finite_layers_pre_extension {ora: RandomOracle} (d: RandomHistory -> Prop): RandomHistory -> Prop :=
fun h => exists n, n_layers_pre_extension n d h.
Definition max_pre_extension {ora: RandomOracle} (d: RandomHistory -> Prop): RandomHistory -> Prop :=
fun h => finite_layers_pre_extension d h \/ (is_inf_history h /\ contextual_consi (finite_layers_pre_extension d) h).
Definition guarded_covered {ora: RandomOracle} (P: RandomHistory -> Prop) (d: RandomHistory -> Prop): Prop :=
forall h, P h -> contextual_consi d h -> d h.
Definition nth_layer_covered {ora: RandomOracle} (n: nat) (d: RandomHistory -> Prop): Prop :=
guarded_covered (is_n_history n) d.

Lemma nth_layer_pre_extension_spec {ora: RandomOracle}: forall (n: nat) (d: RandomHistory -> Prop),
(history_set_consi d /\ forall n', n' < n -> nth_layer_covered n' d) ->
(history_set_consi (nth_layer_pre_extension n d) /\
forall n', n' < S n -> nth_layer_covered n' (nth_layer_pre_extension n d)).