Section through_is_insert.
Variable P : list (list A) -> Tree -> Prop.
Definition P_on_tree (ws : list (list A)) (t : Tree) : Prop := forall t', subtree t' t -> P ws t'.
Definition P_on_forest (ws : list (list A)) (f : list Tree) : Prop :=
forall t, tree_in_forest t f -> P ws t.
Fact P_on_node : forall a ts ws, P_on_tree ws (node a ts) ->
forall t, In t ts -> P_on_tree ws t.
Definition from_insert_forest (t : Tree) (a : A) : Prop :=
forall a' l vs ts, t = node (vs, a'::l) ts -> leA a' a.
Hypothesis P_added_node : forall ws w vs a l ts, from_insert_forest (node (vs,l) ts) a ->
P ws (node (vs,l) ts) ->
P ((a::w)::ws) (node (w::vs, a::l) ts).
Hypothesis P_added_node_base : forall ws w a f, P_on_forest ws f ->
P ((a::w)::ws) (node (w::ws,a::nil) f).
Hypothesis P_split : forall ws a t f, P ws (node a (t::f)) -> P ws t -> P ws (node a f).
Hypothesis P_merge : forall ws a t f, P ws (node a f) -> P ws t -> P ws (node a (t::f)).
Hypothesis P_add : forall w ws t, P ws t -> P (w::ws) t.

Lemma is_insert_tree_invariant : forall ws t w a t',
from_insert_forest t a ->
is_insert_tree t w a t' ->
P_on_tree ws t -> P_on_tree ((a::w)::ws) t'.