Set Warnings "-extraction-opaque-accessed,-extraction".
Set Warnings "-notation-overridden,-parsing".
(* end randomSplitAssumption *)
CoInductive RandomSeedTree :=
| RstNode : RandomSeed -> RandomSeedTree -> RandomSeedTree -> RandomSeedTree.
Definition root_rst (rst : RandomSeedTree) : RandomSeed :=
match rst with
| RstNode root _ _ => root
end.
Definition left_rst (rst : RandomSeedTree) : RandomSeedTree :=
match rst with
| RstNode _ t1 _ => t1
end.
Definition right_rst (rst : RandomSeedTree) : RandomSeedTree :=
match rst with
| RstNode _ _ t2 => t2
end.
Inductive PrefixFree : list SplitPath -> Prop :=
| FreeNil : PrefixFree []
| FreeCons : forall (p : SplitPath) (l : list SplitPath),
PrefixFree l ->
(forall (p' : SplitPath), In p' l ->
(forall p1 p2, p' ++ p1 = p ++ p2-> False)) ->
PrefixFree (p :: l).
intro.
apply FreeCons.
+ apply FreeNil.
+ intros. inversion H.
Qed.
intros.
destruct l; auto.
inversion H.
subst.
pose proof H3 l.
assert (In l (l :: l0)) by (left; auto).
eapply H0 in H1. inversion H1.
instantiate (2 := []). rewrite app_nil_r; simpl; eauto.
Qed.
Inductive correspondingSeedTree (l : list SplitPath) (f : SplitPath -> RandomSeed)
(st : SeedTree) : Prop :=
| Corresponding : (forall (p : SplitPath) s, varySeed' st p = Some s -> In p l) ->
(forall (p : SplitPath), In p l -> varySeed' st p = Some (f p)) ->
PrefixFree l ->
correspondingSeedTree l f st.
intro f.
apply Corresponding.
+ intros p s Contra.
inversion Contra.
+ intros p InNil. inversion InNil.
+ apply FreeNil.
Qed.
Ltac fireInLeft name :=
match goal with
| [H : In ?X (?X :: ?XS) -> _ |- _ ] =>
assert (In X (X :: XS)) as name by (left; auto); apply H in name; clear H
end.
intros l f Corr.
inversion Corr as [Vary_In In_Vary Pref]; clear Corr.
destruct l as [ | p ps]; auto.
clear Vary_In Pref.
pose proof (In_Vary p) as Contra; clear In_Vary.
fireInLeft Hyp.
inversion Hyp.
Qed.

Lemma PrefixFreeWithNil : forall l, PrefixFree ([] :: l) -> l = [].