mirror of
https://github.com/HigherOrderCO/Kind.git
synced 2024-09-11 19:47:15 +03:00
Now, there are two local binders: let x = ... use x = ... The 'let' binder will create a local definition, type-check it, and assign a name to it. When compiled, it will create 'dup' nodes. The 'use' binder is just an alias. It will not bind a new variable, and, when compiled, will create inline copies. Also, for type-checking, it allows creating aliases that are definitionaly equal for the checker.
53 lines
1.3 KiB
Plaintext
53 lines
1.3 KiB
Plaintext
BBT.balance.rgt_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 = λrgt.size λrgt.key λrgt.val λrgt.lft λrgt.rgt
|
|
use P = λx
|
|
∀(new_size: #U60)
|
|
∀(key: K)
|
|
∀(val: V)
|
|
∀(lft: (BBT K V))
|
|
∀(rgt.key: K)
|
|
∀(rgt.val: V)
|
|
∀(rgt.lft: (BBT K V))
|
|
∀(rgt.rgt: (BBT K V))
|
|
(BBT K V)
|
|
use true = λnew_size λkey λval λlft λrgt.key λrgt.val λrgt.lft λrgt.rgt
|
|
use rgt = (BBT.bin K V rgt.size rgt.key rgt.val rgt.lft rgt.rgt)
|
|
(BBT.lft_rotate K V new_size key val lft rgt)
|
|
use false = λnew_size λkey λval λlft λrgt.key λrgt.val λrgt.lft λrgt.rgt
|
|
use rgt = (BBT.rgt_rotate
|
|
K
|
|
V
|
|
rgt.size
|
|
rgt.key
|
|
rgt.val
|
|
rgt.lft
|
|
rgt.rgt
|
|
)
|
|
(BBT.lft_rotate K V new_size key val lft rgt)
|
|
(~(Cmp.is_gtn (cmp set_key rgt.key))
|
|
P
|
|
true
|
|
false
|
|
new_size
|
|
node_key
|
|
val
|
|
lft
|
|
rgt.key
|
|
rgt.val
|
|
rgt.lft
|
|
rgt.rgt
|
|
)
|
|
use tip = (BBT.tip K V)
|
|
(~rgt P bin tip) |