(* 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
}.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
}.Record HistoryAntiChain {ora: RandomOracle}: Type := {
  raw_anti_chain: RandomHistory -> Prop;
  raw_anti_chain_legal: LegalHistoryAntiChain raw_anti_chain
}.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.Definition history_in_anti_chain{ora: RandomOracle} (d: HistoryAntiChain) : Type := {h: RandomHistory | d h}.Definition history_in_anti_chain_history {ora: RandomOracle} (d: HistoryAntiChain) : history_in_anti_chain d -> RandomHistory := @proj1_sig _ _.

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