Definition recompose (tt : (canonTree*canonTree)): canonTree :=
let (t1, t2) := tt in
let (x1, c1) := t1 in
let (x2, c2) := t2 in
match x1 as s return (canonicalTree s -> canonTree) with
| Leaf b1 =>
fun c3 : canonicalTree (Leaf b1) =>
match x2 as s return (canonicalTree s -> canonTree) with
| Leaf b2 =>
fun c4 : canonicalTree (Leaf b2) =>
match bool_dec b1 b2 with
| left e =>
let H :=
eq_rec b1
(fun b3 : bool => canonicalTree (Leaf b3) -> canonTree)
(fun _ : canonicalTree (Leaf b1) =>
exist (fun t : ShareTree => canonicalTree t) (Leaf b1) c3)
b2 e in
H c4
| right n =>
exist (fun t : ShareTree => canonicalTree t)
(Node (Leaf b1) (Leaf b2)) (compose_canon1 b1 b2 n c3 c4)
end
| Node x21 x22 =>
fun c4 : canonicalTree (Node x21 x22) =>
exist (fun t : ShareTree => canonicalTree t)
(Node (Leaf b1) (Node x21 x22)) (compose_canon2 b1 x21 x22 c3 c4)
end c2
| Node x11 x12 =>
fun c3 : canonicalTree (Node x11 x12) =>
match x2 as s return (canonicalTree s -> canonTree) with
| Leaf b2 =>
fun c4 : canonicalTree (Leaf b2) =>
exist (fun t : ShareTree => canonicalTree t)
(Node (Node x11 x12) (Leaf b2)) (compose_canon3 x11 x12 b2 c3 c4)
| Node x21 x22 =>
fun c4 : canonicalTree (Node x21 x22) =>
exist (fun t : ShareTree => canonicalTree t)
(Node (Node x11 x12) (Node x21 x22))
(compose_canon4 x11 x12 x21 x22 c3 c4)
end c2
end c1.
(*End Definition*)

(*L35*)
Lemma avg_share_correct: forall n s,
(height s <= S n)%nat ->
exists s', exists s'',
roundL (S n) s = Some s' /\
roundR (S n) s = Some s'' /\
avg (S n) s' s'' = Some s.