How to unlock the pattern lock
Do you mean, how to bypass the screen lock you forgot?
Before you do anything. Remove your SD card and back it up to your PC.
Try this. Turn the screen off. Activate the screen. Choose the 'emergency call' option. Do not dial a number! Instead use the keypad to input *#*#7378423#*#* (which spells 'service' alphanumerically btw). If your phone allows the bypass you will get the service menu up. (If the service menu does not appear go to step 2). Within the service menu there is an option to erase personal setup data. Choosing this erases all you personalization settings from the phone, it may also reset the phone back to factory state, so you also lose all your data from the phone too (I dare say it does this for security reasons, ie if you lost your phone and someone found it, they could also use this well known bypass method to activate the phone and see all your stuff!, you wouldn't want that would you?!). So, in the service menu, scroll down to 'customisation settings' and open it. Find the tab that indicates 'removal or erasing' of the custom settings and choose it and follow the prompts. Your phone will reset and you can then use it again. I would recommend making a more easy to remember pattern next time, or use a pin.
Step two, you need to re-flash the firmware via the Sony update center. Connect your phone to a pc via the usb cable. Assuming you already have the phones software installed on your pc, navigate to the service area of the software and choose the 'repair my phone option'. NOTE, you lose everything off your phone, so, if you have a removable SD card, backup everything off that before you do the re-flash (you should be warned about that by the software as well!). Depending on your internet connect the process can take up to 2 hours, in which time you just need to leave the phone and wait til the process is done. An onscreen progress bar will let you know how long is left. And, when the phone restarts the first time it will take a few minutes to set up and initialize all the apps, so be patient.