Kind/book/BBT.set.kind2
Victor Taelin 85ad65b026 use-notation
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.
2024-03-08 17:39:37 -03:00

61 lines
1.4 KiB
Plaintext

BBT.set
: ∀(K: *)
∀(V: *)
∀(cmp: ∀(a: K) ∀(b: K) Cmp)
∀(key: K)
∀(val: V)
∀(map: (BBT K V))
(BBT K V)
= λK λV λcmp λkey λval λmap
use P = λx ∀(key: K) ∀(val: V) (BBT K V)
use bin = λsize λnext.key λnext.val λnext.lft λnext.rgt λkey λval
use P = λx
∀(key: K)
∀(next.key: K)
∀(next.val: V)
∀(next.lft: (BBT K V))
∀(next.rgt: (BBT K V))
∀(key: K)
∀(val: V)
(BBT K V)
use ltn = λkey λnext.key λnext.val λnext.lft λnext.rgt λkey λval
use new_lft = (BBT.set K V cmp key val next.lft)
(BBT.balance
K
V
cmp
key
next.key
next.val
new_lft
next.rgt
)
use eql = λkey λnext.key λnext.val λnext.lft λnext.rgt λkey λval
(BBT.bin K V size next.key val next.lft next.rgt)
use gtn = λkey λnext.key λnext.val λnext.lft λnext.rgt λkey λval
use new_rgt = (BBT.set K V cmp key val next.rgt)
(BBT.balance
K
V
cmp
key
next.key
next.val
next.lft
new_rgt
)
(~(cmp key next.key)
P
ltn
eql
gtn
key
next.key
next.val
next.lft
next.rgt
key
val
)
use tip = λkey λval (BBT.singleton K V key val)
(~map P bin tip key val)