Formal specification is a way of describing the details of what a computer program should do, usually in a kind of special language. It's sort of like a recipe for a computer program, which tells it all the instructions it needs to do certain tasks. For example, you might write a formal specification for a program that adds two numbers together, like this:
Input: two numbers A and B
Output: the sum of A and B
Algorithm: Add A and B together
The formal specification tells the computer exactly what to do, so it knows exactly which numbers to add and when to give the result.