1. Home
  2. Computing & Technology
  3. Visual Basic
Symbolic Logic
Part 2: The Basics of Symbolic Logic
 More of this Feature
• Part 1: Symbolic Logic
• Part 3: Mapping Out Symbolic Logic
• Part 4: Going Behind the Symbolic Logic Mask
• Part 5: Visualize Symbolic Logic
 
 Join the Discussion
Is this the kind of article that helps you?
Let us know!
 
 Related Resources
• Calculating a Contrasting Color Code
The first article in the series. • The Imp Logical Operator
• VB .NET New Logical Operators AndAlso and OrElse
 
 Elsewhere on the Web
• Association for Symbolic Logic
• Karnaugh Maps
• A game for understanding Venn Diagrams
 

A university course on Symbolic Logic, for example, might start by defining the possible values for the most elementary logical function as follows:

Truth Functions for One Variable

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.
Truth Functions for One Variable in Binary

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:

Two variable function

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:

Two to the Fourth Power

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:

Two Variable Truth 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
Explore Visual Basic
By Category
About.com Special Features

The Best Web Trends of the Decade

A look back at the best innovations, ideas and technologies over the last 10 years, More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Visual Basic

©2010 About.com, a part of The New York Times Company.

All rights reserved.