1  Boolesche Algebra

1.1 Von der Wahrheitstabelle zur Booleschen Gleichung

Es soll mittels Boolescher Algebra die einfachste Boolesche Gleichung aus der Wahrheitstabelle ermittelt werden.

1.1.1 Wahrheitstabelle

Nummer D C B A Y Minterm Verwendet
1 0 0 0 0 0 - -
2 0 0 0 1 1 \(\bar{D} \land \bar{C} \land \bar{B} \land {A}\) x
3 0 0 1 0 0 - -
4 0 0 1 1 1 \(\bar{D} \land \bar{C} \land {B} \land {A}\) xy
5 0 1 0 0 0 - -
6 0 1 0 1 1 \(\bar{D} \land {C} \land \bar{B} \land {A}\) x
7 0 1 1 0 1 \(\bar{D} \land {C} \land {B} \land \bar{A}\) -
8 0 1 1 1 1 \(\bar{D} \land {C} \land {B} \land {A}\) y
9 1 0 0 0 0 - -
10 1 0 0 1 1 \({D} \land \bar{C} \land \bar{B} \land {A}\) x
11 1 0 1 0 0 - -
12 1 0 1 1 1 \({D} \land \bar{C} \land {B} \land {A}\) y
13 1 1 0 0 1 \({D} \land {C} \land \bar{B} \land \bar{A}\) -
14 1 1 0 1 1 \({D} \land {C} \land \bar{B} \land {A}\) -
15 1 1 1 0 0 - -
16 1 1 1 1 0 - -

1.1.2 Vereinfachen durch Vergleich von Thermen mit nur einem Unterschied

Da gilt \(A \lor A = A\) (Idempotenzgesetz der Disjunktion) können Therme mehrfach verwendet werden. Es muss nur so lange verglichen werden, bis alle Terme einmal benutzt wurden! Gibt es zu einem Term keinen weiteren Term mit nur einer abweichenden Negation, so ist dieser vollständig in das Ergebnis zu übernehmen.

\((\bar{D} \land \bar{C} \land \bar{B} \land {A}) \lor (\bar{D} \land \bar{C} \land {B} \land {A}) = \bar{D} \land \bar{C} \land {A}\) x
\((\bar{D} \land \bar{C} \land \bar{B} \land {A}) \lor (\bar{D} \land {C} \land \bar{B} \land {A}) = \bar{D} \land \bar{B} \land {A}\) y
\((\bar{D} \land \bar{C} \land \bar{B} \land {A}) \lor ({D} \land \bar{C} \land \bar{B} \land {A}) = \bar{C} \land \bar{B} \land {A}\) z
\((\bar{D} \land \bar{C} \land {B} \land {A}) \lor (\bar{D} \land {C} \land {B} \land {A}) = \bar{D} \land {B} \land {A}\) y
\((\bar{D} \land \bar{C} \land {B} \land {A}) \lor ({D} \land \bar{C} \land {B} \land {A}) = \bar{C} \land {B} \land {A}\) z
\((\bar{D} \land {C} \land {B} \land \bar{A}) \lor (\bar{D} \land {C} \land {B} \land {A}) = \bar{D} \land {C} \land {B}\)
\(({D} \land \bar{C} \land {B} \land {A}) \lor ({D} \land \bar{C} \land \bar{B} \land {A}) = {D} \land \bar{C} \land {A}\) x
\(({D} \land {C} \land \bar{B} \land \bar{A}) \lor ({D} \land {C} \land \bar{B} \land {A}) = {D} \land {C} \land \bar{B}\)

Nun wird erneut verglichen bis jeder Therm mindestens einmal verwendet wurde. Gibt es zu einem Term keinen weiteren Term mit nur einer abweichenden Negation, so ist dieser vollständig in das Ergebnis zu übernehmen.

\((\bar{D} \land \bar{C} \land {A}) \lor ({D} \land \bar{C} \land {A}) = \bar{C} \land {A}\)
\((\bar{D} \land \bar{B} \land {A}) \lor (\bar{D} \land {B} \land {A}) = \bar{D} \land {A}\)
\((\bar{C} \land \bar{B} \land {A}) \lor (\bar{C} \land {B} \land {A}) = \bar{C} \land {A}\)

Mit dem Idempotenzgesetz der Disjunktion \(A \lor A = A\) kann der letzte dieser Terme weg gelassen werden, da er bereits in der ersten Zeile vorkommt.

Das Ergebnis:
\[Y = (\bar{C} \land {A}) \lor (\bar{D} \land {A}) \lor (\bar{D} \land {C} \land {B}) \lor ({D} \land {C} \land \bar{B}) \tag{1.1}\]

1.1.3 Überprüfung

Zur Überprüfung wird das Ergebnis mittels Sympy berechnet.

Code
import pandas as pd
from sympy import *
from sympy.logic import SOPform
from sympy.logic.boolalg import to_cnf, to_dnf
from IPython.display import Markdown, Latex

df = pd.read_csv('Wahrheitstabelle.csv',sep=';')
display(Markdown(df.to_markdown(index=False, colalign ='left')))
D C B A Y
0 0 0 0 0
0 0 0 1 1
0 0 1 0 0
0 0 1 1 1
0 1 0 0 0
0 1 0 1 1
0 1 1 0 1
0 1 1 1 1
1 0 0 0 0
1 0 0 1 1
1 0 1 0 0
1 0 1 1 1
1 1 0 0 1
1 1 0 1 1
1 1 1 0 0
1 1 1 1 0
Tabelle 1.1: Wahrheitstabelle
Hinweis

\(\bar{A} = \neg A\)

Code
D = MySymbol('D',description='D Eingang')
C = MySymbol('C',description='C Eingang')
B = MySymbol('B',description='B Eingang')
A = MySymbol('A',description='A Eingang')
Y = MySymbol('Y',description='Y Ausgang')

#D,C,B,A,Y = symbols('D,C,B,A,Y')

mintermsY = df[df['Y'].isin([1])].iloc[:,0:4].values.tolist()
#Yeq = Eq(Y,POSform([D,C,B,A], mintermsY))
Yeq = Eq(Y,SOPform([D,C,B,A], mintermsY))

QBookHelpers.print_equation(Yeq,label='eq-Yeq')

QBookHelpers.print_description(Yeq.free_symbols)

\[ Y = \left(A \wedge \neg C\right) \vee \left(A \wedge \neg D\right) \vee \left(B \wedge C \wedge \neg D\right) \vee \left(C \wedge D \wedge \neg B\right) \tag{1.2}\]

\(D\) … D Eingang

\(A\) … A Eingang

\(B\) … B Eingang

\(C\) … C Eingang

\(Y\) … Y Ausgang

Gleichung 1.1 und Gleichung 1.2 stimmen überein, daher ist davon auszugehen, dass das Ergebnis stimmt.

1.1.4 Schaltung

Hinweis

Es handelt sich um eine automatisch generierte Schaltung mit amerikanischen Symbolen! Diese Schaltung entspricht NICHT europäischen Normen und ist rein informativ.

Code
from schemdraw.parsing import logicparse
#https://schemdraw.readthedocs.io/en/latest/elements/logic.html

Yeqstring = str(Yeq.rhs).replace('&','and').replace('|','or').replace('~','not ')
#print(Yeqstring)
Yeqstring = "(((A and not C) or (A and not D)) or (C and D and not B)) or (B and C and not D)" #Manuell editiert für besseres grafische Ergebnis
display(logicparse(Yeqstring, outlabel='$Y$'))
Abbildung 1.1: Logik Schaltung für Ausgang Y