13,801,188 members
Tip/Trick
alternative version

#### Stats

22.1K views
10 bookmarked
Posted 16 Jun 2014
Licenced CPOL

# Truth Table and Simplification of a Boolean Expression

, 30 Oct 2016
Generation of Karnaugh table

## Introduction

The Karnaugh map, also known as the K-map, is a method to simplify boolean algebra.

Karnaugh maps are used to facilitate the simplification of Boolean algebra functions. Take the Boolean function described by the following truth table.

This article, and especially the attached code, is for those want to know how KARNAUGH table reduice an algebra expression.

## Requirements

The reader should have basic notions of boolean algebra; Knowledge of the Quine McKluskey algorithm is optimal. Basic notions of C# are required for understanding the code.

## Using of the Application

First, we have to introduce the boolean expression in the textbox. This one must use only (a;b:c:d;!,+) characters, then we click the button of table truth generation to fill our listview by the appropriate values.

Once the truth table is filled, we can process to generation of the Karnaugh table by clicking the button named Kanaugh.

To simplify the expression in codesource, we use two methods, the first is to simplify two terms and return the simplified expression.

``` public string simplifier1(int i,int j,int order)
{
int pos = -1;
var dd = Form1.local_tab[i];
var ff = new StringBuilder(dd);
if (shift(Form1.local_tab[i], Form1.local_tab[j]) == 1)
{
ff.Remove(pos, 1);
ff.Insert(pos, "-");
lstTerms[order].SetItemChecked(i, true);
lstTerms[order].SetItemChecked(j, true);
}
return ff.ToString();
}
```

The second makes all simplifications possible in the Karnaugh table.

```public void evaluer(int order)
{
int s = 0;
for (int i = 0; i < Form1.j; i++)
{
for (int k = i; k < Form1.j; k++)
{
simplifier1(i, k, order);
if ((lstTerms[order].GetItemCheckState(i) == CheckState.Checked) &&
(lstTerms[order].GetItemCheckState(k) == CheckState.Checked))
{
if (!tab.Contains(simplifier1(i, k, order)) &&
!Form1.local_tab.Contains(simplifier1(i, k, order)))
{
tab[s] = simplifier1(i, k, order);
lstTerms[order+1].SetItemChecked(s, false);
s++;
}
}
}
}
for (int i = 0; i < Form1.j; i++)
{
Form1.local_tab[i] = " ";
}
Form1.j = s;
for (int i = 0; i < Form1.j; i++)
{
Form1.local_tab[i] = tab[i];
tab[i] = " ";
}
if (s == 0)
arret = true;
}
```

This is what we have as result:

[1} https://commons.wikimedia.org/wiki/File:K-map_minterms_A.svg

## Share

 Algeria
No Biography provided

## You may also be interested in...

 First Prev Next
 Thanks Phil Ouellette29-Oct-16 9:42 Phil Ouellette 29-Oct-16 9:42
 Re: Thanks Amar zaidi30-Oct-16 11:51 Amar zaidi 30-Oct-16 11:51
 My vote of 2 Philippe Mori28-Oct-16 4:19 Philippe Mori 28-Oct-16 4:19
 Re: My vote of 2 Amar zaidi30-Oct-16 3:06 Amar zaidi 30-Oct-16 3:06
 Missing attribution for image Jochen Arndt28-Oct-16 3:34 Jochen Arndt 28-Oct-16 3:34
 Cannot Download the ZIP File Member 1004250111-Oct-16 5:59 Member 10042501 11-Oct-16 5:59
 [My vote of 1] Vote 1 TonBill18-Jun-14 3:30 TonBill 18-Jun-14 3:30
 Re: [My vote of 1] Vote 1 Amar zaidi30-Oct-16 12:22 Amar zaidi 30-Oct-16 12:22
 My vote of 1 LostTheMarbles16-Jun-14 3:48 LostTheMarbles 16-Jun-14 3:48
 Re: My vote of 1 Amar zaidi30-Oct-16 12:23 Amar zaidi 30-Oct-16 12:23
 Last Visit: 16-Dec-18 16:49     Last Update: 16-Dec-18 16:49 Refresh 1