How can we know something for sure? What methods are available in Logic to reach a necessary truth?

These principles are the foundation of all knowledge and rational thought, they are the fundamental building blocks of all necessary truths. They do not rely on anything. They require no proof, as you are only becoming aware of an obvious and undeniable truth. 

Law One : The law of identity

The law of identity: ‘Whatever is, is.”

For any proposition A: A = A.

Regarding this law, Aristotle wrote:

First then this at least is obviously true, that the word “be” or “not be” has a definite meaning, so that not everything will be “so and not so”. Again, if “man” has one meaning, let this be “two-footed animal”; by having one meaning I understand this:—if “man” means “X”, then if A is a man “X” will be what “being a man” means for him. (It makes no difference even if one were to say a word has several meanings, if only they are limited in number; for to each definition there might be assigned a different word. For instance, we might say that “man” has not one meaning but several, one of which would have one definition, viz. “two-footed animal”, while there might be also several other definitions if only they were limited in number; for a peculiar name might be assigned to each of the definitions. If, however, they were not limited but one were to say that the word has an infinite number of meanings, obviously reasoning would be impossible; for not to have one meaning is to have no meaning, and if words have no meaning our reasoning with one another, and indeed with ourselves, has been annihilated; for it is impossible to think of anything if we do not think of one thing; but if this is possible, one name might be assigned to this thing.)

— Aristotle, Metaphysics, Book IV, Part 4 (translated by W.D. Ross)

More than two millennia later, George Boole alluded to the very same principle as did Aristotle when Boole made the following observation with respect to the nature of language and those principles that must inhere naturally within them:

There exist, indeed, certain general principles founded in the very nature of language, by which the use of symbols, which are but the elements of scientific language, is determined. To a certain extent these elements are arbitrary. Their interpretation is purely conventional: we are permitted to employ them in whatever sense we please. But this permission is limited by two indispensable conditions, first, that from the sense once conventionally established we never, in the same process of reasoning, depart; secondly, that the laws by which the process is conducted be founded exclusively upon the above fixed sense or meaning of the symbols employed.

— George Boole, An Investigation of the Laws of Thought
Effectively this is definition “what” things are, conceptualising things so they can be understood and processed.

Law Two : The law of non-contradiction

The law of non-contradiction ( see here) : ‘Nothing can both be and not be.’ In other words: “two or more contradictory statements cannot both be true in the same sense at the same time”.

In the words of Aristotle, that “one cannot say of something that it is and that it is not in the same respect and at the same time”. As an illustration of this law, he wrote:

It is impossible, then, that “being a man” should mean precisely not being a man, if “man” not only signifies something about one subject but also has one significance … And it will not be possible to be and not to be the same thing, except in virtue of an ambiguity, just as if one whom we call “man”, and others were to call “not-man”; but the point in question is not this, whether the same thing can at the same time be and not be a man in name, but whether it can be in fact.

— Aristotle, Metaphysics, Book IV, Part 4 (translated by W.D. Ross)


Law Three : The law of excluded middle

The law of excluded middle: ‘Everything must either be or not be.”

In accordance with the law of excluded middle or excluded third, for every proposition, either its positive or negative form is true: A∨¬A.

Regarding the law of excluded middle, Aristotle wrote:

But on the other hand there cannot be an intermediate between contradictories, but of one subject we must either affirm or deny any one predicate. This is clear, in the first place, if we define what the true and the false are. To say of what is that it is not, or of what is not that it is, is false, while to say of what is that it is, and of what is not that it is not, is true; so that he who says of anything that it is, or that it is not, will say either what is true or what is false

— Aristotle, Metaphysics, Book IV, Part 7 (translated by W.D. Ross)
This is perhaps the most vague or difficult to understand of the three laws. Essentially it means that whilst we know something can not both be and not be in the same respect from the second law, the law of non-contradiction, we are here asserting that everything must either be Or not be, they can not half be, or 99% be. For example, a banana. Either the banana exists, or it does not exist. If someone says, “but wait, I ate a bit out of the banana, so now it does not completely exist”. Now we would return to law one, define what we mean by a banana, then present the question again.