A mathematical approach to adaptability in buildings