C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 9th, 2003, 06:05 PM
dynamo_wku dynamo_wku is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 2 dynamo_wku User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Boolean algebra expressions

Hey all,

I'm trying to find components or a technique that allows manipulation of Boolean expressions that is not so complex that its unmanageable. Specifically I am looking for a way I could input a string such as A*(B+C) and it would simplify it down to AB+AC using the laws of boolean algebra.

I have been trying to work on this for a week or so and I cannot seem to get anywhere on this. I would appreciate any links, references, and/or oppinions on how I may achieve this.

Thanks!!!

Reply With Quote
  #2  
Old October 9th, 2003, 08:14 PM
mitakeet's Avatar
mitakeet mitakeet is offline
Last Day: May 28, 2005
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2003
Location: Maryland
Posts: 4,575 mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 9 h 51 m 4 sec
Reputation Power: 21
You have several problems to overcome. First you need to be able to read in the data from your input source, then you need to parse it to individual tokens, validating that you only have acceptable tokens. Next you have to run through the tokens and note which ones are 'data' and which ones act on those data (which, I suppose, could be done as you parse the data), then you need to write logic to associate the 'active' tokens (appropriate names escape me) with blocks of data tokens. Once all that is done, then you can start running your algebra logic on the various token sets so you can simplify, reduce, whatever (I am a biochemist, I don't need math much higher than add/subtract/mult/divide). It sounds like a really challenging project, one I would expect to take a really experienced programmer much more than a week to code and test fully. You might want to look up some references on compiling, because after all, you are doing many of the same functions. The compiler books I have looked at have lots of math you might find familiar (just greek to me). If you want to continue trying to solve this yourself instead of googling for packages that surely exist to do these sorts of things, I recommend that you break it down into the elements I have listed and tackel them one at a time, testing and checking with each change to be sure nothing has introduced any bugs. Be sure to keep backups of your working code! C, and to a bit lesser extent C++, allows you almost total freedom to shoot yourself in the foot (or worse), so unless you are an experienced C programmer, you may want to consider a more forgiving language like Java (if you want to stick with C like syntax) so you can avoid some of the worst of the mistakes newbies tend to make.

Good luck!
__________________

Left DevShed May 28, 2005. Reason: Unresponsive administrators.
Free code: http://sol-biotech.com/code/.
Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.

It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
--Me, I just made it up

The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
--George Bernard Shaw

Reply With Quote
  #3  
Old October 9th, 2003, 09:10 PM
dynamo_wku dynamo_wku is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 2 dynamo_wku User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
A valid expression can only contain operands (variables), operators and parantheses.

For my particular project the only operators are logic gates (NOT, AND, NAND, OR, NOR, XOR, XNOR). I am only allowing 8 operands and to make it easier only A-H will be used. To validate my string I will check each character of the expression against a string "ABCDEFGH()!*&+|%#" that is made up of only the allowed characters.

The steps I feel are needed for my project are as follows:
1) Take a string expression
2) validate the string (check for allowed variables, operators, parantheses matching
3) parse the string into tokens (as you've said) and store tokens into some sort of data structure (leaning more toward binary trees at the moment)
4) use boolean algebra rules to minimize original expression....at this point i have 2 expressions (original and reduced)
5) draw both expressions using actual bitmaps of digital logic gates
6) misc operations (printing, saving, etc)

I feel confident in 1, 2, 5, and 6. Parsing and minimizing the original expression is what I am totally confused on how to tackle. Drawing might be difficult to but it's something I can definitely play with and solve.

I should explain that the main goal of this project is to visually compare the original expression with its minimized form. It is not to create digital circuits or anything (I will leave that to electrical engineers hehe )

Reply With Quote
  #4  
Old October 9th, 2003, 10:38 PM
mitakeet's Avatar
mitakeet mitakeet is offline
Last Day: May 28, 2005
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2003
Location: Maryland
Posts: 4,575 mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 9 h 51 m 4 sec
Reputation Power: 21
I would guess that would be a full-time project for at least several months. I hope you are getting paid for this! What OS are you writing for? For me the challenge would be to do the bitmap design and printing, the parsing is not that different from other projects I have done. Are you planning on using C or C++? Since I don't expect this is a performance demanding process, I recommend C++ so you can take advantage of vectors, lists, maps, etc. as well as lots of other tools to avoid the need to manually deal with memory.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Boolean algebra expressions


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT