13,197,527 members (45,498 online)
Tip/Trick
Add your own
alternative version

#### Stats

16K views
184 downloads
10 bookmarked
Posted 16 Jun 2014

# Truth Table and Simplification of a Boolean Expression

, 30 Oct 2016
 Rate this:
Please Sign up or sign in to vote.
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].Items.Add(tab[s]);
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:

### Reference an Attribution

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

## License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

## About the Author

 Algeria
No Biography provided

## Comments and Discussions

 First Prev Next
 Thanks Phil Ouellette29-Oct-16 8:42 Phil Ouellette 29-Oct-16 8:42
 Re: Thanks Amar zaidi30-Oct-16 10:51 Amar zaidi 30-Oct-16 10:51
 My vote of 2 Philippe Mori28-Oct-16 3:19 Philippe Mori 28-Oct-16 3:19
 Re: My vote of 2 Amar zaidi30-Oct-16 2:06 Amar zaidi 30-Oct-16 2:06
 Missing attribution for image Jochen Arndt28-Oct-16 2:34 Jochen Arndt 28-Oct-16 2:34
 Cannot Download the ZIP File Member 1004250111-Oct-16 4:59 Member 10042501 11-Oct-16 4:59
 Re: Cannot Download the ZIP File ronen4428-Oct-16 19:30 ronen44 28-Oct-16 19:30
 download TerryM7928-Feb-15 8:19 TerryM79 28-Feb-15 8:19
 Re: download Amar zaidi30-Oct-16 11:20 Amar zaidi 30-Oct-16 11:20
 [My vote of 1] Vote 1 TonBill18-Jun-14 2:30 TonBill 18-Jun-14 2:30
 Re: [My vote of 1] Vote 1 Amar zaidi30-Oct-16 11:22 Amar zaidi 30-Oct-16 11:22
 My vote of 1 LostTheMarbles16-Jun-14 2:48 LostTheMarbles 16-Jun-14 2:48
 Re: My vote of 1 Amar zaidi30-Oct-16 11:23 Amar zaidi 30-Oct-16 11:23
 Last Visit: 31-Dec-99 18:00     Last Update: 20-Oct-17 22:34 Refresh 1

General    News    Suggestion    Question    Bug    Answer    Joke    Praise    Rant    Admin

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171020.1 | Last Updated 30 Oct 2016
Article Copyright 2014 by Amar zaidi
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid