Count all trues in truth tables

RackNerd Leaderboard Banner

Let's just say you have a variable that contains either true or false, well, we're talking about truth tables aren't we?

The combinations

  Var A
+-------+
| true  |
+-------+
| false |
+-------+


  Var A   Var B
+-------+-------+
| true  | true  |
+-------+-------+
| true  | false |
+-------+-------+
| false | true  |
+-------+-------+
| false | false |
+-------+-------+


  Var A   Var B   Var C
+-------+-------+-------+
| true  | true  | true  |
+-------+-------+-------+
| true  | true  | false |
+-------+-------+-------+
| true  | false | true  |
+-------+-------+-------+
| true  | false | false |
+-------+-------+-------+
| false | true  | true  |
+-------+-------+-------+
| false | true  | false |
+-------+-------+-------+
| false | false | true  |
+-------+-------+-------+
| false | false | false |
+-------+-------+-------+

You see where this is going? Truth tables basically gives a representation of possible combinations of truths and lies (I mean true and false :/).

Count all combinations

So how do we count all combinations of true and false?

Let's say variable is called v.

Let's say true and false is a pair (2).

Let's say a variable can contain either true or false.

Let's say we have 1 variable:

(2v)v=(21)1(2^v)*v = (2^1)*1

(21)1=(2)1(2^1)*1 = (2)*1

(2)1=2(2)*1 = 2

2 total combinations of true and false

Let's say we have 2 variables:

(2v)v=(22)2(2^v)*v = (2^2)*2

(22)2=(4)2(2^2)*2 = (4)*2

(4)2=8(4)*2 = 8

8 total combinations of true and false

Count only true (or false)

So how do we count all true occurences? it's simple, we half the total.

We already know that e.g. 2 variables have a total combination of 8.

So that's 4 trues (and 4 falses also).