• 数学中的「闭包」与计算机科学中的「闭包」有什么关系？
• 内存管理中的「堆」与数据结构中的「堆」有什么关系？

## 闭包

In programming languages, closures (also lexical closures or function closures) are techniques for implementing lexically scoped name binding in languages with first-class functions
Wikipedia

The use of the word “closure” here comes from abstract algebra, where a set of elements is said to be closed under an operation if applying the operation to elements in the set produces an element that is again an element of the set. The Lisp community also (unfortunately) uses the word “closure” to describe a totally unrelated concept: A closure is an implementation technique for representing procedures with free.
Structure and Interpretation of Computer Programs, 2nd ed. p.133

「闭包」这个词不仅仅出现这两个地方，我再举几个相关的词。

$$S=R\cup \left\lbrace(x,x):x\in X\right\rbrace$$

$$S=R\cup \left\lbrace(x,y):(y,x)\in R\right\rbrace.\,$$

$$S=\bigcup_{i\in \lbrace 1,2,3,\ldots\rbrace} R^i.$$

$$\begin{cases} R^1 = R\,\\[2ex] R^{i+1} = R \circ R^i \end{cases}$$

$$V_{0}=\lbrace\epsilon \rbrace\,$$

$$V_{i+1}=\lbrace wv:w\in V_{i}\wedge v\in V\rbrace\, 这里的\ i>0\,$$

$$V^{*}=\bigcup_{i=0}^{+\infty} V_i=\left\lbrace\varepsilon \right\rbrace\cup V\cup V^{2}\cup V^{3}\cup \ldots$$

$$\,E(\lbrace p\rbrace)=\lbrace q\in Q:p{\stackrel {\epsilon }{\rightarrow }}q\rbrace。$$

$$E(P)=\bigcup \limits _{p\in P}E(\lbrace p\rbrace)$$

## 堆

• 任意节点小于（或大于）它的所有后裔，最小元（或最大元）在堆的根上（堆序性）。
• 堆总是一棵完全树。即除了最底层，其他层的节点都被元素填满，且最底层尽可能地从左到右填入。

Several authors began about 1975 to call the pool of available memory a “heap.” But in the present series of books, we will use that word only in its more traditional sense related to priority queues.
The Art of Computer Programming, Third Ed., Vol. 1, p. 435

CLRS 中也说：

The term “heap” was originally coined in the context of heapsort, but it has since come to refer to “garbage-collected storage,” such as the programming languages Java and Lisp provide. Our heap data structure is not garbage-collected storage, and whenever we refer to heaps in this book, we shall mean a data structure rather than an aspect of garbage collection.
Introduction to Algorithms, Third Ed, p. 151