A university course on Symbolic Logic, for example, might start by defining the possible values for the most elementary logical function as follows:
This is the type of precision that is required for academic work. The first function (the falsum of one variable), for example, simply notes that it's possible to have a function that returns False no matter what you do. Visual Basic doesn't provide one of these since there wouldn't be much use for it. In fact only the third function (Negation) is actually a function in Visual Basic.
There are really two points to be made here:
- If you do need to read the really disciplined stuff and you're having trouble understanding it, keep in mind that it might be simpler than you think rather than harder. One of the main things that they're trying to do in academic studies is to be absolutely sure they cover all the bases.
- Understanding the language is half the battle. We're going to be covering a lot of logic here and it's a good idea to become familiar with what it looks like in a simple case.
One of the differences between this formal statement of logic and a computer is that computers don't know anything about True and False, they only know 1 and 0. So the first thing that you have to do is decide how to "encode" True and False. One way would be to choose 1 as True and 0 as False. In this case, the table above would look like this:
Notice that the function number is the decimal value of the bit-pattern associated with the function. That is, decimal 2 is binary 10 for example.
Let's look at the same kind of animal, but with two variables. In other words, instead of being able to simply pass in a 1 or a 0 (True or False, that is), we are allowed to pass in any combination of two variables. In symbols, this could be written:
The first thing we know is that there are four possiblilies for the arguments that we can pass into our functions.
p: 0 0 1 1
q: 0 1 0 1
This is like counting from 0 to 3 in binary. And once we know that, we know that there are sixteen possible functions because 2 to the 4th power is 16. In other words, since there are two possibilities for each of the combinations of p and q, you can get the total number of new possibilities by multiplying:
As it turns out, most of these possible functions aren't useful in a VB program just as Negation was the only function of one variable that was actually useful. Here's all sixteen possible functions:
The functions that are useful (and are implemented in VB) are shown in blue. We used Truth Tables to illustrate these relations in the Color Code article. Another way these relations are commonly shown is called Karnaugh Maps. Karnaugh Maps are used a lot to simplify logical expressions and we'll look at how to do that in a few paragraphs.
Next page >
Mapping Out Symbolic Logic > Page
1,
2,
3,
4,
5