Is there a halachik definition of a tzadik?
There is the rambam's definition in hilchos teshuva 3:1 That it's someone who is 51% mitzvos. But according to this definition basically everyone is a tzadik, and it's definitely not how people use the term.
One application would be https://judaism.stackexchange.com/a/90988/6788