Questions tagged [truthtable]

A truth table is a mathematical table used in logic—specifically in connection with Boolean algebra, boolean functions, and propositional calculus—to compute the functional values of logical expressions on each of their functional arguments, that is, on each combination of values taken by their logical variables.

In particular, truth tables can be used to tell whether a propositional expression is true for all legitimate input values, that is, logically valid.

Practically, a truth table is composed of one column for each input variable (for example, A and B), and one final column for all of the possible results of the logical operation that the table is meant to represent (for example, A XOR B). Each row of the truth table therefore contains one possible configuration of the input variables (for instance, A=true B=false), and the result of the operation for those values.

210 questions
67
votes
5 answers

True and False for && logic and || Logic table

Table true/false for C Language I have heard of a table true false for C Language for and && or || is kind of the mathematics one for which they say if true+true=true and false+true=false I'm just kind of confuse on this and I tried to do the…
Ali
  • 9,997
  • 20
  • 70
  • 105
23
votes
8 answers

python build a dynamic growing truth table

My question is simple: "how to build a dynamic growing truth table in python in an elegant way?" for n=3 for p in False, True: for q in False, True: for r in False, True: print '|{0} | {1} | {2} |'.format(int(p),int(q),…
evildead
  • 4,607
  • 4
  • 25
  • 49
16
votes
5 answers

How can I build a Truth Table Generator?

I'm looking to write a Truth Table Generator as a personal project. There are several web-based online ones here and here. (Example screenshot of an existing Truth Table Generator) I have the following questions: How should I go about parsing…
KingNestor
  • 65,976
  • 51
  • 121
  • 152
11
votes
7 answers

Truth tables in code? How to structure state machine?

I have a (somewhat) large truth table / state machine that I need to implement in my code (embedded C). I anticipate the behavior specification of this state machine to change in the future, and so I'd like to keep this easily modifiable in the…
HanClinto
  • 9,423
  • 3
  • 30
  • 31
11
votes
4 answers

How can I avoid an impossible boolean state in c#?

Consider this function, which you can think of as a truth table: public Foo doSomething(bool a, bool b) { if ( a && b) return doAB(); else if ( a && !b) return doA(); else if (!a && b) return doB(); else if (!a && !b) return…
Bobby B
  • 2,287
  • 2
  • 24
  • 47
11
votes
8 answers

Generating truth tables in Java

I'm trying to print some truth tables as part of a school assignment. How can I generate a dynamic size truth table in Java? So that printTruthTable(1) prints: 0 1 printTruthTable(3) prints: 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 And so…
David Weng
  • 4,165
  • 12
  • 42
  • 51
10
votes
2 answers

Truth-table reduction to ternary logic operations, vpternlog

I have many truth-tables of many variables (7 or more) and I use a tool (eg logic friday 1) to simplify the logic formula. I could do that by hand but that is much too error prone. These formula I then translate to compiler intrinsics (eg…
HJLebbink
  • 719
  • 1
  • 11
  • 32
10
votes
5 answers

Generate a truth table in excel

I need to make a formula that gives you the truth table for a variable number of columns. Example
Jonathan Camilleri
  • 611
  • 1
  • 6
  • 17
7
votes
7 answers

Outputting a truth table in PHP

I ran across this truth table generator site, and tried to mimic it in PHP (i realize the source code is available, but i know 0 perl). Now my question is not about evaluating the expression, but how to output the table so that every combination of…
sqram
  • 7,069
  • 8
  • 48
  • 66
7
votes
3 answers

Truth Tables from Anonymous Functions in Haskell

I'm trying to generate a truth table for a given boolean expression. I could do this with creating a new Datatype BoolExpr, but I want to do it with an anonymous function. It's supposed to work like this: > tTable (\x y -> not (x || y)) output: F F…
Moriz Büsing
  • 368
  • 3
  • 17
6
votes
3 answers

Filtering with truth tables

Imagine a Person class with a boolean flag indicating whether or not the person is employable - set to false by default. public class Person{ boolean employable = false; ... } Now imagine having some external boolean methods which act on…
6
votes
3 answers

Name for the logical operator A & (~B)

Is there a name for logical AND with the negation (~) of the second variable, i.e: A & (~B) The truth table for such operation is: 0 & (~0) = 0 0 & (~1) = 0 1 & (~0) = 1 1 & (~1) = 0 And in longer sequences of bits, A = 10110011 B =…
Adam Matan
  • 128,757
  • 147
  • 397
  • 562
5
votes
2 answers

Digital Logic - Karnaugh Map

The initial problem starts like this. There are 6 states. At each state when w=1 move to the next state, when w=0 then stay at the current state. At each state display a number using a standard 7 led display (BCD). Those numbers are 8 -> 1 -> 9 -> 4…
CMacDady
  • 227
  • 2
  • 8
5
votes
2 answers

Prolog First Order Logic - Printing a Truth Table

I have to write program that prints a truth table of expressions. So, I wrote the following function: bool(true). bool(fail). tableBody(A,B,E) :- bool(A), bool(B) , write(A) , write(' '), write(B), write(' '), …
Artium
  • 5,147
  • 8
  • 39
  • 60
4
votes
6 answers

Looking for advice on project. Parsing logical expression

I'm looking for some advice on my school project. I am supposed to create a program that takes a logical expression and outputs a truth table for it. The actually creating of the truth table for me is not difficult at all and I've already wrote the…
Rumel
  • 917
  • 1
  • 9
  • 21
1
2 3
13 14