Joining Parentheses

TODO: Maybe just draw boxes?

Parentheses are used to ‘group together’ parts of an expression; for example 8 + ((3+2)×(1+4)). When many parentheses are nested, a common problem is having to physically count them to figure out which ones match up; or, in other words, to determine the extent of what’s in them.

Prior to the use of parentheses, it was common to use an over-bar (called a ‘vinculum’) to express grouping. This would render the above like: $8 + \overbar{\overbar{3 + 2} \times \overbar{1 + 4}}$

The vinculum makes its extent more clear, since it is physically present above its entire contents. However, I still appreciate the way parentheses ‘split up’ their interior from their exterior: we can combine both by using the vinculum to ‘join the parentheses’, like so: $\ensuremath{\bigl(\text{$\overline{\mathstrut\smash{\text{3 + 2}}}$}\bigr)} \times \ensuremath{\bigl(\text{$\overline{\mathstrut\smash{\text{1 + 4}}}$}\bigr)}$

Note that this may cause clutter when using overbars for negatives, in which case it may be preferable to join parentheses below their enclosed expression: $\ensuremath{\bigl(\text{$\underline{\mathstrut\smash{\text{3 + 2}}}$}\bigr)} \times \ensuremath{\bigl(\text{$\underline{\mathstrut\smash{\text{1 + 4}}}$}\bigr)}$

When there’s no overbar ambiguity, and we have heavily-nested parentheses, I find it helpful to alternate between over- and under-bars at each level of nesting. This original example above would thus become:

$$ 8 + \ensuremath{\bigl(\text{$\overline{\mathstrut\smash{\text{\ensuremath{\bigl(\text{$\underline{\mathstrut\smash{\text{3 + 2}}}$}\bigr)} \times \ensuremath{\bigl(\text{$\underline{\mathstrut\smash{\text{1 + 4}}}$}\bigr)}}}}$}\bigr)} $$

I use this extensively when working in combinatory logic (which makes extensive use of nested tree structures!). For example, here’s function composition:

$$ \ensuremath{\bigl(\text{$\overline{\mathstrut\smash{\text{\ensuremath{\bigl(\text{$\underline{\mathstrut\smash{\text{\ensuremath{\bigl(\text{$\overline{\mathstrut\smash{\text{C f}}}$}\bigr)} g}}}$}\bigr)} x}}}$}\bigr)} &= \ensuremath{\bigl(\text{$\overline{\mathstrut\smash{\text{\ensuremath{\bigl(\text{$\underline{\mathstrut\smash{\text{\ensuremath{\bigl(\text{$\overline{\mathstrut\smash{\text{\ensuremath{\bigl(\text{$\underline{\mathstrut\smash{\text{\ensuremath{\bigl(\text{$\overline{\mathstrut\smash{\text{S \ensuremath{\bigl(\text{$\underline{\mathstrut\smash{\text{K S}}}$}\bigr)}}}}$}\bigr)} K}}}$}\bigr)} f}}}$}\bigr)} g}}}$}\bigr)} x}}}$}\bigr)} \\ &= \ensuremath{\bigl(\text{$\overline{\mathstrut\smash{\text{\ensuremath{\bigl(\text{$\underline{\mathstrut\smash{\text{\ensuremath{\bigl(\text{$\overline{\mathstrut\smash{\text{\ensuremath{\bigl(\text{$\underline{\mathstrut\smash{\text{\ensuremath{\bigl(\text{$\overline{\mathstrut\smash{\text{K S}}}$}\bigr)} f}}}$}\bigr)} \ensuremath{\bigl(\text{$\underline{\mathstrut\smash{\text{K f}}}$}\bigr)}}}}$}\bigr)} g}}}$}\bigr)} x}}}$}\bigr)} \\ &= \ensuremath{\bigl(\text{$\overline{\mathstrut\smash{\text{\ensuremath{\bigl(\text{$\underline{\mathstrut\smash{\text{\ensuremath{\bigl(\text{$\overline{\mathstrut\smash{\text{S \ensuremath{\bigl(\text{$\underline{\mathstrut\smash{\text{K f}}}$}\bigr)}}}}$}\bigr)} g}}}$}\bigr)} x}}}$}\bigr)} \\ &= \ensuremath{\bigl(\text{$\overline{\mathstrut\smash{\text{\ensuremath{\bigl(\text{$\underline{\mathstrut\smash{\text{\ensuremath{\bigl(\text{$\overline{\mathstrut\smash{\text{K f}}}$}\bigr)} x}}}$}\bigr)} \ensuremath{\bigl(\text{$\underline{\mathstrut\smash{\text{g x}}}$}\bigr)}}}}$}\bigr)} \\ &= \ensuremath{\bigl(\text{$\overline{\mathstrut\smash{\text{f \ensuremath{\bigl(\text{$\underline{\mathstrut\smash{\text{g x}}}$}\bigr)}}}}$}\bigr)} \\ $$