Diagram#
- class discopy.grammar.abstract.Diagram(inside, dom, cod, _scan=True)[source]#
Bases:
discopy.closed.DiagramAn abstract diagram is a closed diagram with words as boxes, i.e. a derivation in an abstract categorial grammar.
The rules of a categorial grammar are its closed structure: application is evaluation, composition is the currying of two evaluations and crossed composition coincides with composition, since a closed category has one exponential.
- Parameters:
- classmethod fc(left, middle, right)[source]#
Forward composition
(left << middle) @ (middle << right) -> left << right.
- classmethod bc(left, middle, right)[source]#
Backward composition
(left >> middle) @ (middle >> right) -> left >> right.
- classmethod fx(left, middle, right)[source]#
Forward crossed composition, which coincides with
fc().
- classmethod bx(left, middle, right)[source]#
Backward crossed composition, which coincides with
bc().
- classmethod from_categorial(diagram)[source]#
The abstract diagram of a categorial diagram, or the abstract term of a categorial term, dropping planarity: left and right exponentials collapse, constants stay constants and words become boxes, crossed compositions become compositions and the composition and type-raising terms become lambda terms.
Example
>>> from discopy.grammar import categorial >>> n, s = categorial.Ty("n"), categorial.Ty("s") >>> Alice, loves, Bob = n("Alice"), ((n >> s) << n)("loves"), n("Bob") >>> print(Diagram.from_categorial(Alice(loves(Bob), left=True))) loves(Bob)(Alice)
- permutation_factory#
alias of
Permutation