Lösungen/Solutions/
B1S1Ue/Ex2

Generierung von Wahrheitswerttabellen für alle Ueb./
Générer des tableaux de vérité pour toutes les ex.

Remove["Global`@*"]

tab[1] = Table[{a}, {a, 0, 1}];
tabZ[1] = tab[1] /. {0 -> False, 1 -> True};
tab[2] = 
        Flatten[Table[{a, b}, {a, 0, 1}, {b, 0, 1}], 
          1];
tabZ[2] = tab[2] /. {0 -> False, 1 -> True};
tab[3] = 
        Flatten[Table[{a, b, c}, {a, 0, 1}, {b, 0, 1}, {c, 0, 1}], 
          2];
tabZ[3] = tab[3] /. {0 -> False, 1 -> True};
tab[4] = 
        Flatten[Table[{a, b, c, d}, {a, 0, 1}, {b, 0, 1}, {c, 0, 1}, {d, 0, 
              1}], 3];
tabZ[4] = tab[4] /. {0 -> False, 1 -> True};

{tab[2] // MatrixForm, tabZ[2] // MatrixForm}

Konstruktion des Programms / Construction du programme

Programm / Programme

Funktion / Fonction

implies[x_, y_] := Or[Not[x], y]; Attributes[implies] = {Listable}; 
    f0[a_, b_] := 
      And[implies[
          Not[Or[a, b]],   Or[Not[a], 
            Not[b]]], 
implies[ Or[Not[a], Not[b]], 
          Not[Or[a, b]]]];
Attributes[f0] = {Listable};
{implies[u, v], f0[x, y]}

Apply[f0, tabZ[2][[4]]]

Length[tabZ[2]]

Programmschritte / Etapes du programme

res = 
      Table[Apply[f0, tabZ[2][[n]]], {n, 1, 
          Length[tabZ[2]]}]

Print["res = ", res]

newtabX = Transpose[tabZ[2]]

u = Length[newtabX]

exttabX = Transpose[Append[newtabX, res]]

output = 
      Prepend[exttabX, Append[Range[u], {expr}]] // MatrixForm

output = 
      Prepend[exttabX, Append[Range[u], {expr}]] /. {True -> 1, False -> 0} // 
        MatrixForm /. {True -> 1, False -> 0}

Programm als Test-Module / 
Programme comme Module pour tester

Remove[WtabTest]

\(WtabTest[f_, tabX_] := 
      Module[{res, newtabX, u, exttabX, output, output1}, \ 
        res = Table[
            Apply[f, tabX[\([n]\)]], {n, 1, 
              Length[tabX]}]; 
Print["res = ", 
          res]; 
newtabX = 
          Transpose[tabX]; 
Print["newtabX = ", 
          newtabX]; 
u = 
          Length[newtabX]; 
Print["u = ", 
          u]; 
\ \ \ \ exttabX = 
          Transpose[
            Append[newtabX, 
              res]]; 
Print[" exttabX = ", \ 
          exttabX]; 
\ \ \ \ output = 
          Prepend[exttabX, Append[Range[u], {expr}]] // 
            MatrixForm; 
Print["  output = ", \ 
          output]; 
output1 = 
          Prepend[exttabX, Append[Range[u], {expr}]] /. {True -> 1, 
                False -> 0} // MatrixForm]\)

WtabTest[f0, tabZ[2]]

Fertiges Programm / 
Programme complet

\(Wtab[f_, tabX_] := 
      Module[{res, newtabX, u, exttabX, output, output1}, \ 
        res = Table[Apply[f, tabX[\([n]\)]], {n, 1, Length[tabX]}]; 
        newtabX = Transpose[tabX]; 
u = 
          Length[newtabX]; 
\ \ \ \ \ exttabX = 
          Transpose[
            Append[newtabX, res]]; 
\ \ \ \ \ Prepend[exttabX, 
              Append[Range[u], {expr}]] /. {True -> 1, False -> 0} // 
          MatrixForm]\)

Wtab[f0, tabZ[2]]

Funktionen definieren und Programm anwenden / 
Définir des fonctions et appliquer le programme

Versuch / Essayer

Definitionen / Définitions

f[x_, y_, z_, w_] :=  Or[And[Not[x], y], z]; 
    Attributes[f] = {Listable};
f[x, y, z, w]

Anwenden / Appliquer

Wtab[f, tabZ[4]]

Versuch / Essayer

Subjunktion neu / Subjonction de nouveau

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

imp[! a || ! b, ! (x1 || x2)]

Implies[ Or[Not[a], Not[b]], Not[Or[x1, x2]]]

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

?sub

f00[a_, b_] := 
        And[imp[Not[Or[a, b]],   Or[Not[a], 
              Not[b]]], 
imp[ Or[Not[a], Not[b]], 
            Not[Or[a, b]]]];
Attributes[f2a] = {Listable};

f00[x, y]

Bijunktion  / Bijonction

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

bij[x, y]

Lösungen / Solutions

Ueb / Ex 1

f1a[x1_, x2_] := Not[Or[x1, x2]]; 
    Attributes[f1] = {Listable};
f1b[x1_, x2_] := Or[Not[x1], Not[x2]]; 
    Attributes[f2] = {Listable};

Wtab[f1a, tabZ[2]] =!= Wtab[f1b, tabZ[2]]

Ueb / Ex 2

a

f2a[a_, b_] := 
        bij[Not[Or[a, b]], And[Not[a], Not[b]]];
Attributes[f2a] = {Listable};

Wtab[f2a, tabZ[2]]

b

Remove[f2b]

f2b[a_, b_, c_] := 
        bij[Not[Or[sub[a, b], c]], 
          And[Not[sub[a, c]], Not[b]]];
Attributes[f2b] = {Listable};

f2b[a, b, c]

Wtab[f2b, tabZ[3]]

c

f2c[a_, b_] := sub[And[a, b], a];
Attributes[f2c] = {Listable};

f2c[a, b]

Wtab[f2c, tabZ[2]]

d

f2d[a_, b_] := 
        sub[sub[sub[a, b], a], a];
Attributes[f2d] = {Listable};
Wtab[f2d, tabZ[2]]

Kurz /Bref

Remove[t];t =  
      Module[{f, 
          n}, 

f[a_, 
            b_] :=       sub[sub[sub[a, b], a], 
            a]
; 
n =                           2
; 
Attributes[f] = {Listable}; 
Wtab[f, 
          tabZ[n]]];t

Remove[t];t =  
      Module[{f, 
          n}, 

f[a_, 
            b_] :=       sub[sub[sub[a, b], a], 
            a]
; 
n =                           2
; 
Attributes[f] = {Listable}; 
Wtab[f, 
          tabZ[n]]];t

Ueb / Ex 3

a

Remove[t];t =  
      Module[{f, 
          n}, 

f[a_, 
            b_] :=       sub[And[sub[a, Not[b]], b], 
            Not[a]]
; 
n =                           2
; 
Attributes[f] = {Listable}; 
Wtab[f, 
          tabZ[n]]];t

Remove[t];t =  
      Module[{f, 
          n}, 

f[a_, 
            b_] :=       sub[And[sub[a, b], b], 
            a]
; 
n =                           2
; 
Attributes[f] = {Listable}; 
Wtab[f, 
          tabZ[n]]];t

Ueb / Ex 4

\[Implies] ∧\[Implies] A B B  ∨  A B

Ueb / Ex 5

a

(A ∧ ¬ B) \[Implies] C

(A ∧ ¬ B) \[Implies] C  /. Implies -> sub  // 
      LogicalExpand

⇥  aNF und / et kNF

Ueb / Ex 6

a

-3≠7∧-2≠7∧-1≠7∧0≠7∧1≠7∧2≠7∧

b

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

Tutoring:

Generierung von Wahrheitswerttabellen für alle Ueb./
Générer des tableaux de vérité pour toutes les ex.

tab[1] = 
        Table[{a}, {a, 0, 1}] /. {0 -> False, 1 -> True};
\(			\(tab[2] = 
        Flatten[Table[{a, b}, {a, 0, 1}, {b, 0, 1}], 1] /. {0 -> False, 
            1 -> True};\)\)
tab[3] = 
        Flatten[Table[{a, b, c}, {a, 0, 1}, {b, 0, 1}, {c, 0, 1}], 
            2] /. {0 -> False, 1 -> True};
\(		\(tab[4] = 
        Flatten[Table[{a, b, c, d}, {a, 0, 1}, {b, 0, 1}, {c, 0, 1}, {d, 0, 
                1}], 3] /. {0 -> False, 1 -> True};\)
\)

Vorstudien mit Funktionen /
Etudes de fonctions

x  &&  y  /.  {x -> False, y -> True}

x  &&  y  /.  {x -> "False", y -> "True"}

And[x ,  y]  /.  {x -> False, y -> True}

Implies[x ,  y]  /.  {x -> False, y -> True}

Or[x ,  y]  /.  {x -> False, y -> True}

x  ||  y  /.  {x -> False, y -> True}

!  y  /.  { y -> True}

¬ y  /.   {y -> True}

Wahrheitsfunktionen /
Fonctions de vérité

Definitionen / Définitions

Remove[f]

f[x_, y_, z_, w_] :=  Or[And[Not[x], y], z];
f[x, y, z, w]

f[{x_, y_, z_, w_}] :=  Or[And[Not[x], y], z];
f[{x, y, z, w}]

f[True, False, False, True]

Anwendung auf Listen ermöglichen / Faciliter l'application à des listes

Attributes[f] = {Listable}

Apply[f, tab3[[1]]]

Rechnung mit tab3 und f[x,y,z,w] /
Calcul avec tab3 et f[x,y,z,w]

res = Table[Apply[f, tab3[[n]]], {n, 1, Length[tab3]}]

newtab3 = Transpose[tab3]

exttab3 = Transpose[Append[newtab3, res]]

output = Prepend[exttab3, {x, y, z, w, expr}] // MatrixForm

In einem, wenn f und tab3 schon definiert sind /
Tout ensemble, si f et tab3 sont déjà définis

res = 
        Table[Apply[f, tab3[[n]]], {n, 1, Length[tab3]}];
newtab3 = Transpose[tab3];
exttab3 = Transpose[Append[newtab3, res]];
output = Prepend[exttab3, {x, y, z, w, expr}] // MatrixForm

\(\(\(
\)\(output /. {True -> 1, False -> 0}\)\)\)