C Tutorial

This is a brief tutorial on how to use C. Many things can be done with C if you have the patience to program things from the scratch. C is a programming language that is half way down to assembly and machine code. The language set of instructions are small and everything is done through pointers, that are really a source of headache as well as solution. Who's never left a NULL pointer dangling inside the code, and then BANG! Segmentation fault! Fatal Error! and the sort? I remember a time when I spent the whole night killing bugs in my C++ programs. It was more than 20 years ago. I was young and obstinate to get things done. The bugs were all too simple. Missing delimiters, pointers errors, infinite loops and some wild behaviour concerning data structures. I was young, and I had to learn, it'd become my profession later. Now, I'm middle aged, and with lots of problems, but coding takes me out of the world. It is like TRON, you enter a world of digital machines, and they behave very well, if well handled.

Project - A Tautology Checker Machine (TCM)

Tautologies play a central role in logic and Bertrand Russell complained that his work only included them. A tautology is an logical expression that only returns true no matter what the interpretation (values substituted) is. For example, the expression \[ P \wedge (Q \vee R) \iff (P \wedge Q)\vee(P \wedge R)\] is a tautology. To show it we can demonstrate it or build a truth table. We will focus on data structures called trees to represent the expressions and evaluate them. For this project you'll need gcc or clang compiler, a good text editor, and lots of patience. I know the AI agent likes to suggest things, but I'd like you to put your hands on the code. If you're a begginer, don't worry. I'll explain the code from zero to hero. If you can afford, you might use Replit online platform. How to solve the problem. We have to build our data strucures first. Then, we should code the interface, which is command line passed to the program. We will build the tree, evaluate the expression and say if it is a tautology or no. We expect to evaluate any tautology using the TCM machine. I expect we can have a great time coding. This TCM code can be used in a compiler project later, and is a quite useful code.

TCM - A Tautology Checker Machine
Tautology Checker Trees

The tree tableau search is done by contradiction. We negate the statement and start searching the tree branches for a counterexample. If a contradiction is found the branch is closed. If all the branches are closed we have a tautology.

Elements of Programming

We attempt to describe some elements that are philosophically relevant to the computer science. We have abstract entities and concrete entities. The former are unchanged over time, while the latter comes and goes out of existence. These entities have species and genus, that is, they have specific properties that are common to a set of entities. In object oriented languages, the genus is the class, while species is an instanciation of that class. Functions are associations of abstract or concrete entities containing arguments and after some transformation leads to a result.

In a computer, a value is a datum, that is, zeroes and ones 0100100101, mapped to an entity name. The value int x := 0100_1001_0010b creates a value type. The 0100_1001_0010b is the representation of x, while x is the interpretation of 0100_1001_0010b. Sometimes we have identity defined as the representational identity, for example, if two files have the same binary data, they are just equal to each other even if one file is an image and the other is text.

Elements of Programming

3. Calculator