Aquickwordofencouragement:Afterwritingthiscode,evenIdonotunderstandtheprecisedetailsofhowbalancingworks!IconsultedChrisOkasaki'spaper%``%#"#Red-Black Trees in a Functional Setting#"#%''~\cite{Okasaki}%andtranscribedthecodetousedependenttypes.Luckily,thedetailsarenotsoimportanthere;typesalonewilltellusthatinsertionpreservesbalanced-ness,andwewillprovethatinsertionproducestreescontainingtherightkeys.*)
Definitionbalance1n(a:rtreen)(data:nat)c2:=
Definitionbalance1n(a:rtreen)(data:nat)c2:=
matchainrtreenreturnrbtreec2n
matchainrtreenreturnrbtreec2n
...
@@ -550,13 +544,11 @@ Definition balance1 n (a : rtree n) (data : nat) c2 :=
...
@@ -550,13 +544,11 @@ Definition balance1 n (a : rtree n) (data : nat) c2 :=
Afterwritingthiscode,evenIdonotunderstandtheprecisedetailsofhowbalancingworks.IconsultedChrisOkasaki'spaper%``%#"#Red-Black Trees in a Functional Setting#"#%''%andtranscribedthecodetousedependenttypes.Luckily,thedetailsarenotsoimportanthere;typesalonewilltellusthatinsertionpreservesbalanced-ness,andwewillprovethatinsertionproducestreescontainingtherightkeys.