Venn Diagrams for Boolean Algebra

Venn Diagrams for Boolean Algebra
Renata
de Freitas
Petrucio
Viana
IME
UFF
II Workshop on Logic and Semantics
Ilha Grande, August 26-30, 2013
This is a “post-workshop” version.
We thank the participants of the II WLS
for the fruitful discussions.
Outline
I
Euler diagrams
I
Venn diagrams
I
Shin’s system Venn II
I
Venn diagrams for Boolean algebra
Reasoning on categorical propositions
The four different standard forms of categorical propositions are:
(A)
Every A is B.
(O)
Not every A is B.
(I)
Some A is B.
(E)
No A is B.
where A and B are classes of objects.
Categorical propositions are naturally related to statements written
in a fragment of the language of Set Theory:
(A)
Every A is B
:
A⊆B
(O)
Not every A is B
:
A 6⊆ B
(I)
Some A is B
:
A ∩ B 6= ∅
(E)
No A is B
:
A∩B =∅
We know some ways to reason about sets.
I
Ask a mathematician: this is probably correct, but maybe
incomplete.
I
Translate to first order logic: this is provably correct and,
depending of the target theory, complete.
I
Apply the algebra of sets: this can be made correct, complete,
and mechanized but I don’t like it!
It does have a real road for inferences on categorical propositions?
Euler to Princess
Euler diagrams
(A) Every A is B
A
:
B
A⊆B
Euler diagrams
(O) Not every A is B
A
B
:
A 6⊆ B
Euler diagrams
(I) Some A is B
:
A B
A ∩ B 6= ∅
Euler diagrams
(E) No A is B
A
:
A∩B =∅
B
Example 1
All men are mammals.
All mammals are mortal.
All men are mortal.
A
B
=⇒
B
C
A
C
Diagrammatic proof
Unify — superposing curves with the same label
A
B
=⇒
A
B
C
B
C
Diagrammatic proof
Erase curve
A
B
C
=⇒
A
C
Example 2
Some men are wise.
All men are philosophers.
Some philosophers are wise.
A B
=⇒
A
C
C B
Diagrammatic proof
Unify — superposing curves with the same label
?
?
?
?
?
?
?
?
?
A?
?
?
?
?
?
?
?
?
?A B?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
A
?
B
A B
=⇒
A
C
?
?
C
?
C
?
C
Which choice we should make?
?
B
?
General diagrams
I
General diagrams are diagrams representing “every way” an
element of an universe can-or-cannot be an element of a
certain number of subsets of this universe.
I
In a general diagram, sets are represented by simple, closed
and connected curves on the plane. In the simpler cases, these
curves are represented by circles or elipses.
not connected
I
not simple
not closed
Let us call minimal region each region on the plane
determined by the curves representing the sets that cannot be
described as the union of other regions.
General diagram to 1 set:
U
A
The minimal regions in this diagram are A and A.
General diagram to 2 sets:
U
A
B
The minimal regions in this diagram are (A ∩ B), (A ∩ B), (A ∩ B)
and (A ∩ B).
General diagram to 3 sets:
U
A
B
C
The minimal regions in this diagram are (A ∩ B ∩ C ), (A ∩ B ∩ C ),
(A ∩ B ∩ C ), (A ∩ B ∩ C ), (A ∩ B ∩ C ), (A ∩ B ∩ C ), (A ∩ B ∩ C )
and (A ∩ B ∩ C ).
Proposition (Venn, 1880)
Given any n ∈ N∗ , there exists a general diagram to n sets. The
general diagram to n sets has 2n minimal regions.
These diagrams can be difficult to draw, when n ≥ 4.
http://www.combinatorics.org/Surveys/ds5/VennEJC.html
Venn diagrams
All men are mammals.
All mammals are mortal.
All men are mortal.
A
B
A
=⇒
B
C
C
Diagrammatic proof
Add curve
A
A
B
B
=⇒
C
A
B
B
C
=⇒
C
Diagrammatic proof
Unify — superposing curves with the same labels
A
B
C
A
B
=⇒
A
B
C
C
Diagrammatic proof
Erase shading
A
A
B
B
=⇒
C
C
Diagrammatic proof
Erase curve
A
B
A
=⇒
C
C
Peirce’s diagrams
Some men are wise.
All men are philosophers.
Some philosophers are wise.
A
B
×
C
=⇒
A
C
B
×
Diagrammatic proof
Add curve
A
A
B
×
=⇒
B
×
×
C
A
A
B
C
=⇒
C
Diagrammatic proof
Unify
A
B
×
×
C
A
=⇒
A
B
C
B
×
×
C
Diagrammatic proof
Delete shaded ×
A
B
×
×
A
=⇒
C
B
×
C
Diagrammatic proof
Erase shading
A
A
B
×
=⇒
C
B
×
C
Diagrammatic proof
Erase curve
A
B
C
×
=⇒
C
B
×
Non-valid syllogism
All men are philosophers.
Some philosophers are wise.
All men are wise.
A
B
A
=⇒
B
C
×
C
Add curve
A
A
B
B
=⇒
C
A
B
C
×
=⇒
B
×
×
C
Unify
A
B
C
A
=⇒
A
B
×
×
C
B
×
×
C
???
A
B
×
A
=⇒
/
×
C
C
Possible conclusion
A
B
×
A
=⇒
×
C
C
× ×
Split ×-sequence
A
C
×
A
C
× ×
=⇒
A
C
×
Compound diagram
Some men are wise, or some wise people are not men, or both.
A
C
×
A
C
×
Syntax
Let Var be a set of variables for sets.
A unitary diagram is a triple d = (L, S, X ), where L ⊆ Var is a
finite set of labels, S ⊆ P(L) is the set of shaded regions of d, and
X ⊆ P(P(L)) \ {∅} is the set of ×-sequences of d.
A
B
×
×
C
d = (L, S, X )
L = {A, B, C }
S = {{A}, {A, C }}
X = {{{A, B, C }, {B, C }}}
Syntax
A compound diagram is a finite set D of unitary diagrams.
D = {d1 , d2 }
A
C
×
A
C
×
d1 = (L1 , S1 , X1 )
L1 = {A, C }
S1 = ∅
X1 = {{{A, C }}}
d2 = (L2 , S2 , X2 )
L2 = {A, C }
S2 = ∅
X2 = {{{C }}}
Syntax
A multi-diagram is a finite set ∆ of compound diagrams.
∆ = { {d}, {d1 , d2 } }
A
C
×
A
B
×
×
C
A
C
×
Semantics
A model is a pair M = (M, I ), where M is a set and
I : Var → P(M).
Let d = (L, S, X ) be a unitary diagram and M = (M, I ) be a
model. We say that M satisfies d, denoted by M |= d, when
I
for each r ∈ S, we have
\
\
{IY : Y ∈ r } ∩ {IZ : Z 6∈ r } = ∅,
I
for each s ∈ X , we have
o
[ n\
\
{IY : Y ∈ r } ∩ {IZ : Z 6∈ r } : r ∈ s 6= ∅.
Semantics
Let D be a compound diagram and M = (M, I ) be a model. We
say that M satisfies D, denoted by M |= D, when
M |= d, for some d ∈ D.
Let ∆ be a multi-diagram and M = (M, I ) be a model. We say
that M satisfies ∆, denoted by M |= ∆, when
M |= D, for every D ∈ ∆.
Semantics
Let Σ be a set of multi-diagrams and ∆ be a multi-diagram. We
say that ∆ is a consequence of Σ, denoted by Σ |= ∆, when
for every model M, if M |= σ, for each σ ∈ Σ, then M |= ∆.
Let ∆ be a multi-diagram. We say that ∆ is valid, denoted by
|= ∆, when
∅ |= ∆.
Inference rules
Rule 0
Axiom
{{(∅, ∅, ∅)}}
Inference rules
Rule 1
Erase shading
∆ ∪ {D ∪ {(L, S ∪ S 0 , X )}} =⇒ ∆ ∪ {D ∪ {(L, S, X )}}
A
B
A
=⇒
B
Inference rules
Rule 1
Erase ×-sequence
∆ ∪ {D ∪ {(L, S, X ∪ X 0 )}} =⇒ ∆ ∪ {D ∪ {(L, S, X )}}
A
B
×
×
×
A
=⇒
B
×
Inference rules
Rule 1
Erase curve
∆ ∪ {D ∪ {(L, S, X )}} =⇒ ∆ ∪ {D ∪ {(L0 , S 0 , X 0 )}}, with
L0 = L − {c}
S 0 = {r 0 ∈ P(L0 ) : r 0 ∈ S and r 0 = r − {c}, for some
r ∈ P(L) st r ∈ S and r 6= r 0 }
0
0
X = {s ∩ P(L ) : s ∈ X }
A
B
×
A
=⇒
×
C
C
× ×
Inference rules
Rule 2
Erase a shaded part of an ×-sequence
∆ ∪ {D ∪ {(L, S, X )}} =⇒ ∆ ∪ {D ∪ {(L, S, (X − {T }) ∪ {T 0 })}},
with T 0 = T − {s} =
6 ∅, for some T ∈ X , s ∈ S st s ∈ T
A
B
×
×
A
=⇒
C
B
×
C
Inference rules
Rule 3
Spread ×’s
∆∪{D ∪{(L, S, X )}} =⇒ ∆∪{D ∪{(L, S, (X −{T })∪{T ∪T 0 })}}
A
B
×
×
A
=⇒
B
×
×
×
Inference rules
Rule 4
Add a curve
∆∪{D ∪{(L, S, X )}} =⇒ ∆∪{D ∪{(L∪{c}, S +c,{T +c : T ∈ X })}},
with T +c = {s ∪ {c} : s ∈ T }
A
A
B
×
=⇒
×
×
C
B
Inference rules
Rule 5
Contradiction
∆ ∪ {D ∪ {(L, S ∪ T , X ∪ {T })}} =⇒ ∆0
A
×
×\
× ×
B
=⇒
×
C
∆0
Inference rules
Rule 6
Unify
∆∪{D∪{(L,S1 ,X1 ), (L,S2 ,X2 )}} =⇒ ∆∪{D∪{(L, S1 ∪S2 , X1 ∪X2 )}}
A
B
A
C
B
=⇒
A
B
C
C
Inference rules
Rule 7
Split an ×-sequence
∆ ∪ {D ∪ {(L, S, X )}} =⇒
∆ ∪ {D ∪ {(L, S, (X − {T }) ∪ {T1 }), (L, S, (X − {T }) ∪ {T2 })}},
if T ∈ X and {T1 , T2 } is a partition of T .
A
C
×
A
C
× ×
=⇒
A
C
×
Inference rules
Rule 8
Excluded middle
∆∪{D ∪{(L, S, X )}} =⇒ ∆∪{D ∪{(L, S ∪T , X ), (L, S, X ∪{T })}}
A
A
C
A
C
C
=⇒
× ×
Inference rules
Rule 9
Connect a diagram
∆ ∪ {D ∪ {d}} =⇒ ∆ ∪ {D ∪ {d, d 0 }}
A
C
× ×
A
C
× ×
=⇒
A
B
C
Inference rules
Rule 10
Proof by Cases
{{d1 , d2 , . . . , dn }} =⇒ {{d}},
if {{di }} =⇒ {{d}}, for each i = 1, . . . , n.
d1
d2
...
dn
=⇒
d
d1
=⇒
d
d2
=⇒
d
..
.
if
dn
=⇒
d
Let Σ be a set of multi-diagrams and ∆ be a multi-diagram. We
say that ∆ is derivable from Σ, denoted by Σ ` ∆, when there is a
sequence (∆1 , . . . , ∆n ) such that
I
∆1 ∈ Σ ∪ { {{(∅, ∅, ∅)}} },
I
∆i+1 is a consequence of ∆i by one of the inference rules, for
all i = 1, . . . , n,
I
∆n = ∆.
Soundness and completeness
Theorem (Shin / Hammer-Danner)
Σ and multi-diagram ∆,
For all set of multi-diagrams
Σ ` ∆ ⇐⇒ Σ |= ∆.
Problem
How one can use this system to prove that a Boolean equality, like
A ∪ (B ∩ C ) ∪ A ∩ B = A ∩ B,
is a valid?
Not so good solution
Introduce new variables D, E , F , G , H, I , J, K and consider
A ∪ (B ∩ C ) ∪ A ∩ B = A ∩ B
iff
B = D, A ∩ D = E , E = F , B ∩ C = G ,
A ∪ G = H, H = I , I ∪ F = J, J = K
=⇒
K =E
Example 3
Let’s see how it works in a simpler example.
A=A
iff
A = B, B = C =⇒ C = A
Example 3
A = B, B = C =⇒ C = A
A
B
A
=⇒
B
C
C
Diagrammatic proof
Add curve
A
A
B
B
=⇒
C
A
B
B
C
=⇒
C
Diagrammatic proof
Unify — superposing curves with the same labels
A
B
C
A
B
=⇒
A
B
C
C
Diagrammatic proof
Erase shading
A
A
B
B
=⇒
C
C
Diagrammatic proof
Erase curve
A
B
A
=⇒
C
C
A better ideia
We propose an alternative diagrammatic system in which,
to test the validity of an inclusion X ⊆ Y , we can do the following:
I
build the diagram of X ,
I
put the diagram of X in normal form,
I
build the diagram of Y ,
I
put the diagram of Y in normal form,
I
compare the normal forms.
In our system, diagrams do not represent relations between sets.
In our system, diagrams represent sets.
The normal form of the diagram of A is the diagram of A
A
A
A
•
⇐⇒
⇐⇒
•
•
Example 4
Let’s go back to the not so simple example and use our system to
prove that the following Boolean equality is a valid.
A ∪ (B ∩ C ) ∪ A ∩ B = A ∩ B
Diagram of X
A ∪ (B ∩ C ) ∪ A ∩ B
•
Putting the diagram of X in normal form
A ∪ (B ∩ C ) ∪ A ∩ B
A ∪ (B ∩ C ) ∪ A ∩ B
=⇒
•
•
Putting the diagram of X in normal form
A ∪ (B ∩ C ) ∪ A ∩ B
=⇒
•
A ∪ (B ∩ C )
A∩B
•
•
Putting the diagram of X in normal form
A ∪ (B ∩ C )
A∩B
=⇒
•
•
A ∪ (B ∩ C )
•
A∩B
•
Putting the diagram of X in normal form
A ∪ (B ∩ C )
A∩B
=⇒
•
•
A
•
A
B
•
B ∩C
•
•
Putting the diagram of X in normal form
A
•
A
B
•
B ∩C
=⇒
•
•
A
A
•
•
A
•
C
B
•
B
•
•
Putting the diagram of X in normal form
A
A
•
•
A
=⇒
•
C
B
B
•
•
•
A
A
C
•
•
•
A
A
B
•
C
•
•
B
•
•
Putting the diagram of X in normal form
A
A
C
•
•
•
A
A
B
B
•
•
=⇒
•
C
•
•
A
•
A
C
•
B
•
•
A
B
•
•
•
Putting the diagram of X in normal form
A
•
A
C
•
•
A
B
•
=⇒
•
B
•
•
A
•
A
C
•
B
•
•
A
C
•
B
•
•
•
Putting the diagram of X in normal form
A
•
A
C
•
•
A
•
C
•
B
•
B
•
•
=⇒
A
•
A
C
•
B
B
•
•
•
Putting the diagram of X in normal form
A
•
A
C
•
B
=⇒
•
B
•
•
A
B
•
•
A
C
•
A
B
•
•
B
•
•
Putting the diagram of X in normal form
A
B
•
•
A
C
•
A
B
=⇒
•
B
•
•
•
A
B
•
•
•
A
C
•
B
•
•
Putting the diagram of X in normal form
A
B
•
•
A
•
C
•
B
=⇒
•
•
A
B
•
•
•
A
C
•
•
A
B
•
•
Putting the diagram of X in normal form
A
B
•
•
A
•
C
•
A
•
B
=⇒
•
•
A
B
•
A
C
•
•
Putting the diagram of X in normal form
A
B
A
•
C
•
=⇒
•
A
B
•
A
•
•
C
B
•
• •
C
Putting the diagram of X in normal form
A
B
A
•
•
•
C
B
•
• •
=⇒
C
A
B
•
•
C
The normal form of the diagram of X
A
B
•
•
C
Putting the diagram of Y in normal form
A∩B
=⇒
•
A
B
•
•
Putting the diagram of Y in normal form
A
B
•
=⇒
•
A
B
•
•
Putting the diagram of Y in normal form
A
B
=⇒
•
•
A
B
•
•
A
B
•
•
Putting the diagram of Y in normal form
A
B
•
A
•
B
=⇒
•
•
A
B
•
Putting the diagram of Y in normal form
A
B
=⇒
•
A
B
•
•
C
The normal form of the diagram of Y
A
B
•
•
C
Comparing the normal forms
A
B
A
•
B
•
=
•
C
•
C
Syntax
Let Var be a set of variables for sets and Trm be the set of terms
given by
X := U | O | A | X | X ∩ X | X ∪ X
A unitary diagram is a pair d = (L, B), where L ⊆ Trm is a finite
set of labels and B ⊆ P(L).
Compound diagrams are sets of unitary diagrams and
multi-diagrams are sets of compound diagrams.
Example
C
• •
•
•
A∪B
O
•
d = (L, B)
L = {C , O, A ∪ B}
B = {{C }, {C , O}, {O}, {C , O, A ∪ B}, ∅}
Semantics
A model is a pair M = (M, I ), where M is a set and
I : Var → P(M).
Let d = (L, B) be a unitary diagram and M = (M, I ) be a model.
The meaning of d in M is
[
[[d]]M = {Ib : b ∈ B},
where Ib =
Define also
T
{It : t ∈ b} ∩
T
[
{[[d]]M : d ∈ D}
\
= {[[D]]M : d ∈ ∆}
[[D]]M =
[[∆]]M
{It : t 6∈ b}.
Diagram of a Boolean term
Let t ∈ Trm. The diagram of t is
∆t = { {({t}, {{t}})} }.
t
•
Proposition
For all term t ∈ Trm and model M,
[[t]]M = [[∆t ]]M .
Normal form
Let ∆ be a multi-diagram and L ⊆ Trm. We say that ∆ is in
normal form w.r.t. L when
∆ = { {(L, B)} } and L ⊆ Var.
Rules to put a diagram in normal form
U in
∆ ∪ {D ∪ {({U}, {{U}})}} ⇐⇒ ∆ ∪ {D ∪ {(∅, {∅})}}
U
•
⇐⇒
•
Rules to put a diagram in normal form
U out
∆ ∪ {D ∪ {({U}, {∅})}} ⇐⇒ ∆ ∪ {D ∪ {(∅, ∅)}}
U
⇐⇒
•
Rules to put a diagram in normal form
O in
∆ ∪ {D ∪ {({O}, {{O}})}} ⇐⇒ ∆ ∪ {D ∪ {(∅, ∅)}}
O
•
⇐⇒
Rules to put a diagram in normal form
O out
∆ ∪ {D ∪ {({O}, {∅})}} ⇐⇒ ∆ ∪ {D ∪ {(∅, {∅})}}
O
⇐⇒
•
•
Rules to put a diagram in normal form
∩ in
∆ ∪ {D ∪ {({A ∩ B}, {{A ∩ B}})}} ⇐⇒
∆ ∪ {D ∪ {({A}, {{A}})}, {({B}, {{B}})}}
A∩B
A
•
⇐⇒
B
•
•
Rules to put a diagram in normal form
∩ out
∆ ∪ {D ∪ {({A ∩ B}, {∅})}} ⇐⇒
∆ ∪ {D ∪ {({A}, {{A}}), ({B}, {{B}})}}
A
A∩B
•
⇐⇒
•
B
•
Rules to put a diagram in normal form
∪ in
∆ ∪ {D ∪ {({A ∪ B}, {∅})}} ⇐⇒
∆ ∪ {D ∪ {({A}, {{A}}), ({B}, {{B}})}}
A
•
A∪B
•
⇐⇒
B
•
Rules to put a diagram in normal form
∪ out
∆ ∪ {D ∪ {({A ∪ B}, {{A ∪ B}})}} ⇐⇒
∆ ∪ {D ∪ {({A}, {{A}})}, {({B}, {{B}})}}
A∪B
A
B
⇐⇒
•
•
•
Rules to put a diagram in normal form
− in
∆ ∪ {D ∪ {({A}, {{A}})}} ⇐⇒ ∆ ∪ {D ∪ {({A}, {∅})}}
A
A
•
⇐⇒
•
Rules to put a diagram in normal form
− out
∆ ∪ {D ∪ {({A}, {∅})}} ⇐⇒ ∆ ∪ {D ∪ {({A}, {{A}})}}
A
A
⇐⇒
•
•
Rules to put a diagram in normal form
Add curve
∆∪{D ∪{(L, B)}} ⇐⇒ ∆∪{D ∪{(L∪{c}, B ∪{r ∪{c} : r ∈ B})}}
A
A
B
•
⇐⇒
B
•
•
C
Rules to put a diagram in normal form
Unify
∆ ∪ {D ∪ {(L, B2 ), (L, B2 )}} ⇐⇒ ∆ ∪ {D ∪ {(L, B1 ∪ B2 })}}
A
B
•
A
•
A
B
⇐⇒
•
B
•
•
•
•
∆ ∪ {D ∪ {(L, B2 )}, {(L, B2 )}} ⇐⇒ ∆ ∪ {D ∪ {(L, B1 ∩ B2 })}}
A
B
•
•
A
A
B
⇐⇒
•
•
B
•
Equivalence between diagrams
Let ∆1 and ∆2 be multi-diagrams. We say that ∆1 and ∆2 are
equivalent when, for every model M,
[[∆1 ]]M = [[∆2 ]]M .
Lemma For all diagram ∆ = (L, B) and L0 ⊇ Var(L), there is a
diagram ∆0 st
I
∆0 and ∆ are equivalent,
I
∆0 is in normal form w.r.t. L0 .
Theorems
We say that an inclusion ∆1 ⊆ ∆2 is a theorem, denoted by
` ∆1 ⊆ ∆2 ,
when NFL ∆1 can be derived from NFL ∆2 by rule Add bullet
(next slide).
NFL ∆1 (respect. NFL ∆2 ) is a diagram in normal form
w.r.t.SL that is equivalent to ∆1 (respect. ∆2 ) and
L = {Var(t) : t is a label in ∆1 or ∆2 }.
Rule to compare diagrams in normal form
Add bullet
∆ ∪ {D ∪ {(L, B)}} =⇒ ∆ ∪ {D ∪ {(L, B ∪ B 0 })}}
A
A
B
=⇒
•
•
B
•
•
•
(Weak) Soundness and completeness
Theorem
For every inclusion ∆1 ⊆ ∆2 ,
` ∆1 ⊆ ∆2 ⇐⇒ [[∆1 ]]M ⊆ [[∆2 ]]M , for every model M.
Proof outline (weak completeness):
Suppose 6` ∆1 ⊆ ∆2 .
Hence, given NFL ∆1 = (L, B1 ) and NFL ∆2 = (L, B2 ), we have
that there is some a ∈ L st a ∈ B1 and a 6∈ B2 .
Take a model M = (M, I ) st M = {a} and
{a}, if X ∈ L and a ∈ X
IX =
∅, otherwise
We have that [[∆1 ]]M = {a} 6⊆ [[∆2 ]]M .
Perpectives
I
Consequence from hypotheses.
I
Extension to “non-inclusions” X 6⊆ Y .