Lösungen/Solutions/E1S1AlUe/Ex2

L=Lektion/Leçon-- Sprechstunde/heures de consultation
W=Work/Arbeit/Travail

Säubern • Nettoyer

Remove["Global`@*"]

Subjunktion neu • Encore la subjonction

Definieren • Définir

asUsual[f_] := 
        StringReplace[
          ToString[
            TraditionalForm[
              f]], {"!" -> "¬"}];

sub[x_, y_] := Or[Not[x], y]; Attributes[sub] = {Listable};

Testen, Vergleich • Tester, comparer

f00[a_, b_] := 
        And[sub[Not[Or[a, b]],   Or[Not[a], 
              Not[b]]], 
sub[ Or[Not[a], Not[b]], 
            Not[Or[a, b]]]];

f00[x, y] // asUsual

Bijunktion  • Bijonction

Definieren • Définir

bij[x_, y_] := And[sub[x, y], sub[y, x]]; 
    Attributes[bij] = {Listable};

Testen • Tester

bij[x, y] // asUsual

Programms für beliebig Wahrheitsfunktionen 
• Programme pour des fonctions de vérité quelconques

Programm • Programme

Fertiges Programm • Programme complet

Programm • Programme

\(Wtab[f_, m_] := 
      Module[{tabb, tabZ, res, newtabX, u, exttabX, output, 
          output1}, \ 
Attributes[
            f] = {Listable}; 
tabb[
            1] = {{0}, {1}}; 
tabb[u_] := 
          Flatten[Table[
              Append[\(tabb[u - 1]\)[\([k]\)], w], {k, 1, 
                Length[tabb[u - 1]]}, {w, 0, 1}], 1]; 
        tabZ[u_] := \ tabb[u] /. {0 -> False, 1 -> True}; 
        res = Table[Apply[f, \(tabZ[m]\)[\([n]\)]], {n, 1, Length[tabZ[m]]}]; 
        newtabX = Transpose[tabZ[m]]; 
u = 
          Length[newtabX]; 
\ \ \ \ \ exttabX = 
          Transpose[
            Append[newtabX, res]]; 
\ \ \ \ \ Prepend[exttabX, 
              Append[Range[u], {expr}]] /. {True -> 1, False -> 0} // 
          MatrixForm]\)

Programm anwenden • Appliquer le programme

Ueb/Ex 1      W

tabbe[1] = {{0}, {1}};
tabbe[u_] := 
      Flatten[Table[
          Append[tabbe[u - 1][[k]], w], {k, 1, 
            Length[tabbe[u - 1]]}, {w, 0, 1}], 1]; 
    tabZe[u_] :=  tabbe[u];

all = Transpose[tabZe[4]]; MatrixForm[all]

inp = tabZe[2]; MatrixForm[inp]

Table[Prepend[all[[n]], inp[[n]]], {n, 1, 4}] // 
      MatrixForm

Ueb/Ex 2      W

a

f2al[x1_, x2_] := Not[Or[x1, x2]];
f2ar[x1_, x2_] := And[Not[x1], Not[x2]];

Wtab[f2al,     2    ] == 
      Wtab[f2ar,     2    ]

b

schef[x1_, x2_] := Not[x1  &&  x2]

Wtab[schef,     2    ]

f2bl[x1_, x2_] := Or[x1, x2];
f2br[x1_, x2_] := schef[schef[x1, x1], schef[x2, x2]];

Wtab[f2bl,     2    ] == 
      Wtab[f2br,     2    ]

Ueb/Ex 3      W

a

f3a[a_, b_] := bij[Not[Or[a, b]],  And[Not[a], Not[b]]]

Wtab[f3a,     2    ]

b

f3b[a_, b_, c_] := 
      bij[Not[Or[sub[a, c], b]],  And[Not[sub[a, c]], Not[b]]]

Wtab[f3b,     3    ]

c

f3c[a_, b_] := sub[And[a, b], a]

Wtab[f3c,     2    ]

d

f3d[a_, b_] := sub[sub[sub[a, b], a], a]

Wtab[f3d,     2    ]

Funktionen • Fonctions

Anwenden: Vergleich von Wahrheitstabellen 
• Appliquer: Comparaison de tableaux de vétité

Ueb/Ex 4      W

a

f4a[a_, b_] := sub[sub[a, ¬ b] && b, ¬ a]

Wtab[f4a, 2]

f4b[a_, b_] := sub[sub[a, b] && b, a]

Wtab[f4b, 2]

Ueb/Ex 5      W

⇒ ∧ ⇒ A B B ∨ A B

Ueb/Ex 6      W

f6a[a_, b_, c_] := sub[a  &&  ¬ b, c]

Wtab[f6a, 3]

aNF = ¬ a && ¬ b && ¬ c  ||  ¬ a && ¬ b && 
          c  ||  ¬ a && b && ¬ c  ||  ¬ a && b && 
          c  || 
 a && ¬ b && c  ||  
        a && b && ¬ c  ||  a && b && c; asUsual[aNF]

aNF // LogicalExpand  // asUsual

Ueb/Ex 7     W

a

x ≠ -3  ∧  x ≠ -2  ∧  
      x ≠ -1  ∧  x ≠ -0  ∧  
      x ≠ -1  ∧  x ≠ -2

b

-3  <  0  ∨  -2  <  0  ∨  -1  <  
        0