mirror of
https://github.com/HigherOrderCO/Kind.git
synced 2024-09-11 16:25:54 +03:00
54 lines
1.3 KiB
Plaintext
54 lines
1.3 KiB
Plaintext
BBT.balance.lft_heavier
|
|
: ∀(K: *)
|
|
∀(V: *)
|
|
∀(cmp: ∀(a: K) ∀(b: K) Cmp)
|
|
∀(new_size: #U60)
|
|
∀(node_key: K)
|
|
∀(set_key: K)
|
|
∀(val: V)
|
|
∀(lft: (BBT K V))
|
|
∀(rgt: (BBT K V))
|
|
(BBT K V)
|
|
= λK λV λcmp λnew_size λnode_key λset_key λval λlft λrgt
|
|
use P = λx (BBT K V)
|
|
use bin = λlft.size λlft.key λlft.val λlft.lft λlft.rgt
|
|
use P = λx
|
|
∀(new_size: #U60)
|
|
∀(key: K)
|
|
∀(val: V)
|
|
∀(lft.key: K)
|
|
∀(lft.val: V)
|
|
∀(lft.lft: (BBT K V))
|
|
∀(lft.rgt: (BBT K V))
|
|
∀(rgt: (BBT K V))
|
|
(BBT K V)
|
|
use true = λnew_size λkey λval λlft.key λlft.val λlft.lft λlft.rgt λrgt
|
|
use lft = (BBT.lft_rotate
|
|
K
|
|
V
|
|
lft.size
|
|
lft.key
|
|
lft.val
|
|
lft.lft
|
|
lft.rgt
|
|
)
|
|
(BBT.rgt_rotate K V new_size key val lft rgt)
|
|
use false = λnew_size λkey λval λlft.key λlft.val λlft.lft λlft.rgt λrgt
|
|
use lft = (BBT.bin K V lft.size lft.key lft.val lft.lft lft.rgt)
|
|
(BBT.rgt_rotate K V new_size key val lft rgt)
|
|
(~(Cmp.is_gtn (cmp set_key lft.key))
|
|
P
|
|
true
|
|
false
|
|
new_size
|
|
node_key
|
|
val
|
|
lft.key
|
|
lft.val
|
|
lft.lft
|
|
lft.rgt
|
|
rgt
|
|
)
|
|
use tip = (BBT.tip K V)
|
|
(~lft P bin tip)
|