(* TODO: put this in lib *)
Definition isSome {A} (o: option A) := match o with Some _ => True | None => False end.
Definition history_set_consi {ora: RandomOracle} (P: RandomHistory -> Prop) : Prop :=
forall h1 h2,
conflict_history h1 h2 ->
P h1 ->
P h2 ->
False.
Class LegalHistoryAntiChain {ora: RandomOracle} (d: RandomHistory -> Prop) : Prop := {
rand_consi: history_set_consi d
}.
Record HistoryAntiChain {ora: RandomOracle}: Type := {
raw_anti_chain: RandomHistory -> Prop;
raw_anti_chain_legal: LegalHistoryAntiChain raw_anti_chain
}.
Definition in_anti_chain {ora: RandomOracle} (d: HistoryAntiChain) (h: RandomHistory): Prop := raw_anti_chain d h.
Coercion in_anti_chain: HistoryAntiChain >-> Funclass.
Definition history_in_anti_chain{ora: RandomOracle} (d: HistoryAntiChain) : Type := {h: RandomHistory | d h}.
Coercion history_in_anti_chain: HistoryAntiChain >-> Sortclass.
Definition history_in_anti_chain_history {ora: RandomOracle} (d: HistoryAntiChain) : history_in_anti_chain d -> RandomHistory := @proj1_sig _ _.
Coercion history_in_anti_chain_history: history_in_anti_chain >-> RandomHistory.

Lemma LegalHistoryAntiChain_Included {ora: RandomOracle}: forall (d1 d2: RandomHistory -> Prop), (forall h, d1 h -> d2 h) -> LegalHistoryAntiChain d2 -> LegalHistoryAntiChain d1.
Definition singleton_history_anti_chain {ora: RandomOracle} (h: RandomHistory): HistoryAntiChain.