6
$\begingroup$

I want to simplify this expression:

BooleanMinimize[(A ∧ ¬ B ∧ C ∧ ¬ D) ∨ (A ∧ B ∧ ¬ C ∧ ¬ D) ∨ (A ∧ B ∧ C ∧ ¬ D)]

And I get this:

(A ∧ B ∧ ¬ D) ∨ (A ∧ C ∧ ¬ D)

But using a Karnaugh Map and "don't cares" I get ¬ D. Is there anyway that I can get similar answer in Mathematica?

$\endgroup$
5
  • $\begingroup$ can you complete your question with the "don't care cases" ? otherwise we can't guess what you wish. $\endgroup$
    – andre314
    Commented Nov 4, 2017 at 18:18
  • $\begingroup$ I Consider hexadecimal and my "don't cares" are 0-9 $\endgroup$
    – Bardulf
    Commented Nov 4, 2017 at 18:30
  • $\begingroup$ So you mean that A,B,C,D are 10,11,12,13(decimal) in your code ? , that is to say constants ? Apparently, you use them as is they where some variables (like x,y,z) $\endgroup$
    – andre314
    Commented Nov 4, 2017 at 18:45
  • $\begingroup$ I mean from (A ∧ ¬ B ∧ C ∧ ¬ D) this "1010" that represent "A" in hexadecimal and some thing like (A ∧ ¬B ∧ ¬C ∧ ¬ D) consider as "don't cares" $\endgroup$
    – Bardulf
    Commented Nov 4, 2017 at 18:55
  • $\begingroup$ OK, I understand now $\endgroup$
    – andre314
    Commented Nov 4, 2017 at 19:13

2 Answers 2

5
$\begingroup$

An arbitrary function with "don't cares" can be defined using either BooleanFunction or BooleanConvert, but in those cases, Mathematica makes no effort to find the minimal representation of such a function.

Instead, use BooleanMinimize with the optional third argument: an assumed condition on the variables. In your case, you can specify that your "don't cares" are 0-9 by making the condition be A ∧ (B ∨ C).

Then the calculation

BooleanMinimize[
  (A ∧ ¬ B ∧ C ∧ ¬ D) ∨ (A ∧ B ∧ ¬ C ∧ ¬ D) ∨ (A ∧ B ∧ C ∧ ¬ D),
  "DNF", 
  A ∧ (B ∨ C)] 

will produce the desired output of !D.

$\endgroup$
4
$\begingroup$

Thank's to @Misha Lavrov (a great thanks !), here is how you can solve the problem :

BooleanMinimize[  
    BooleanFunction[{
        {1,0,1,0}-> 1,
        {1,0,1,1}-> 0,
        {1,1,0,0}-> 1,
        {1,1,0,1}-> 0,
        {1,1,1,0}-> 1,
        {1,1,1,1}-> 0
      },{a,b,c,d}],  
    "SOP" (* = "DNF" *),
    BooleanFunction[{
        {1,1,_,_}-> 1, (* all cases above ... *)
        {1,_,1,_}-> 1, (* ... are "do care" *)
        {_,_,_,_}-> 0 (* other cases are "don't care" *)
      },{a,b,c,d}]]  
! d

Note :

@Misha Lavrov's comment (just below) was written before I added the third argument to BooleanMinimize. At this time there were some "don't care" states in the first BooleanFunction[...]

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.