forked from tomhanika/conexp-clj
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tamari-lattice.clj
43 lines (33 loc) · 1 KB
/
tamari-lattice.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
;; Daniel Borchmann, 2010
;; This file is in the public domain.
;; Computes the Tamari lattice T_n of all bracketings of a set of n+1
;; symbols. See GW97, 5.4, example 11.
(require 'conexp.main)
(in-ns 'conexp.main)
;;;
(defn T
"Returns a context for the Tamari lattice of all bracketings of n+1
symbols."
[n]
(let [elements (set-of-range n),
base-set (set-of [a b] [a elements, b elements, :when (< a b)])]
(make-context base-set
base-set
(set-of [[i j] [p q]]
[[i j] base-set,
[p q] base-set,
:when (not (and (<= p i q j)
(not= i q)))]))))
(defn tamari-lattice
"Returns a lattice isomorphic to the one of bracketings of n+1
symbols."
[n]
(concept-lattice (T n)))
;;; Now we draw
(use 'conexp.contrib.draw)
(defn draw-tamari-lattice
"Draws the Tamari lattice for parameter n."
[n]
(draw-lattice (tamari-lattice n)))
;;;
nil