Formal Analysis of Architectural Patterns