{- Given once we find leaf: take its real contents, a Bracket copy it n times. recursively adjust sizes based on sisters. wrap each copy in names. ~[[TA]{1,1} [...]{3,3}]{4,4} : [(2,2) (2,2)] -> [ [[TA]{1,1} [...]{3,3}]{4,4} [[TA]{1,1} [...]{3,3}]{4,4} ] -> [adj [ [TA]{1,1} [...]{3,3} ]{4,4} 2 2 adj [ [TA]{1,1} [...]{3,3} ]{4,4} 2 2 ] adj unit@(Unit _ _) = unit adj brkt@(Brkt crts m M) = ------ adj A0@[ = A0@[ A1{m1, M1} | adj A1@[...]{m1, M1} c1 C1 A2{m2, M2 | adj A2@[...]{m2, M2} c2 C2 ... | ... ]{m0, M0} n N | ]{n, N} where T = N - SUM Ci | Ck = min (Mk, N) | ck = max(0, T + Ck) example: adj [ [TA]{1,1} [...]{3,3} ]{4,4} 2 2 -> [ [TA]{1,1} [...]{3,3} ]{2,2} -> [ [TA]{1,min(1,2)} [...]{3,min(3,2)} ]{2,2} -> [ [TA]{max(0,2-3+1),1} [...]{max(0,2-3+2),2} ]{2,2} -> [ [TA]{0,1} [...]{1,2} ]{2,2} -> [ adj [TA]{1,1} 0 1 adj [...]{3,3} 1 2 ]{2,2} -> -> [ [[TA]{0,1} [...]{1,2}] [[TA]{0,1} [...]{1,2}] ] To find the correct inner mins and maxs: inner max <- min(inner max, outer max) inner min <- max(0, outer min - SUM all inner maxima + inner maximum) -}