Kind/book/BBT.has.linear.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

50 lines
1.3 KiB
Plaintext

BBT.has.linear
: ∀(K: *)
∀(V: *)
∀(cmp: ∀(a: K) ∀(b: K) Cmp)
∀(key: K)
∀(map: (BBT K V))
(Pair Bool (BBT K V))
= λK λV λcmp λkey λmap
use P = λx (Pair Bool (BBT K V))
use bin = λsize λnode_key λval λlft λrgt
use P = λx
∀(cmp: ∀(a: K) ∀(b: K) Cmp)
∀(key: K)
∀(lft: (BBT K V))
∀(rgt: (BBT K V))
(Pair Bool (BBT K V))
use ltn = λcmp λsize λhas_key λval λlft λrgt λhas_key
use P = λx (Pair Bool (BBT K V))
use new = λbool λlft
use map = (BBT.bin K V size node_key val lft rgt)
(Pair.new Bool (BBT K V) bool map)
(~(BBT.has.linear K V cmp has_key lft) P new)
use eql = λcmp λsize λkey λval λlft λrgt λhas_key
(Pair.new
Bool
(BBT K V)
Bool.true
(BBT.bin K V size node_key val lft rgt)
)
use gtn = λcmp λsize λkey λval λlft λrgt λhas_key
use P = λx (Pair Bool (BBT K V))
use new = λbool λrgt
use map = (BBT.bin K V size node_key val lft rgt)
(Pair.new Bool (BBT K V) bool rgt)
(~(BBT.has.linear K V cmp has_key rgt) P new)
(~(cmp key node_key)
P
ltn
eql
gtn
cmp
size
node_key
val
lft
rgt
key
)
use tip = (Pair.new Bool (BBT K V) Bool.false (BBT.tip K V))
(~map P bin tip)