Informatics 1 Computation and Logic Sets of States: Venn Diagrams - - PDF document

informatics 1
SMART_READER_LITE
LIVE PREVIEW

Informatics 1 Computation and Logic Sets of States: Venn Diagrams - - PDF document

Informatics 1 Computation and Logic Sets of States: Venn Diagrams and Truth Tables Michael Fourman @mp4man 1 This course provides a first glimpse of the deep connections between computation and logic. We will focus primarily on the simplest


slide-1
SLIDE 1

Informatics 1

Computation and Logic

Sets of States: Venn Diagrams and Truth Tables Michael Fourman @mp4man

1

This course provides a first glimpse of the deep connections between computation and logic. We will focus primarily on the simplest non-trivial examples of logic and computation: propositional logic and finite-state machines. In this lecture we look at an example that introduces some ideas that we will explore further in later lectures, and introduce some notation which should become more familiar in due course.

slide-2
SLIDE 2

properties & sets boolean circuits boolean formulæ boolean functions

2

Properties and sets are the things we want to talk about. Once we have chosen a language we consider two things that have the same properties to be identical.

slide-3
SLIDE 3

3

The possible states of the signal correspond to all possible combinations of lights, even though only four of them should

  • ccur in practice.

So there are 8 states. Our simple language with three variable will allow us to describe any set of states - all 256 of them

slide-4
SLIDE 4

4

In general, we consider a system with some finite number, n, of Boolean variables. Here we have three variables RAG reach represented by a light. The possible states of the system correspond to Boolean valuations of the variables: these are assignments giving a Boolean value for each variable. Here each light may be on (true) or off (false); we have 8 possible

  • valuations. In general, there will be 2

n

valuations. Each of our Boolean variables corresponds to a property of states.

slide-5
SLIDE 5

{x | R(x)}

5

This notation for set comprehension will be useful. Here x ranges over states. R(x) is the property that the red light is

  • n.

Similarly we have properties G(x) and A(x).

slide-6
SLIDE 6

{x | G(x)}

6

This notation for set comprehension will be useful. Here x ranges over states. R(x) is the property that the red light is

  • n.

Similarly we have properties G(x) and A(x).

slide-7
SLIDE 7

{x | A(x)}

7

This notation for set comprehension will be useful. Here x ranges over states. R(x) is the property that the red light is

  • n.

Similarly we have properties G(x) and A(x).

slide-8
SLIDE 8

8

Venn (1834–1923)

We can place the states in a Venn Diagram. This includes all eight possible combinations of values for the three Boolean state variables. For n larger than 3, the Venn diagram needs more dimensions than most of us can easily visualise. However, the notation of set comprehension can be used for any number of dimensions.

slide-9
SLIDE 9

{x | G(x) ⊕ R(x)}

9

xor

We can compute the set of states corresponding to any expression

slide-10
SLIDE 10

??

10

  • x | G(x) ⊕ (R(x) ⊕ A(x))

xor

To try in class

slide-11
SLIDE 11

✔ ✔ ✔ ✔

𐄃 𐄃 𐄃 𐄃

11

  • x | G(x) ⊕ (R(x) ⊕ A(x))

xor

We find that the solution is symmetric, so xor is associative.

slide-12
SLIDE 12

{x | G(x) ⊕ R(x) ⊕ A(x)}

✔ ✔ ✔ ✔

𐄃 𐄃 𐄃 𐄃

12

xor

We find that the solution is symmetric, so xor is associative.

slide-13
SLIDE 13

{x | G(x) ↔ R(x)}

✔ ✔ ✔ ✔

𐄃 𐄃 𐄃 𐄃

13

iff

slide-14
SLIDE 14

??

14

iff

  • x | G(x) ↔ (R(x) ↔ A(x))

To do in class

slide-15
SLIDE 15

{x | G(x) ↔ R(x) ↔ A(x)}

✔ ✔ ✔ ✔

𐄃 𐄃 𐄃 𐄃

15

iff

G(x) ↔R(x) ↔ A(x) ≡ G(x)⊕R(x) ⊕ A(x)

To determine whether to expressions are equivalent, we can check whether they give the same values for all 2^n states of the system Venn diagram is just a presentation of truth table for two or three variables.

slide-16
SLIDE 16

OR XOR AND NOT

16

The computation of the next state can be implemented by some basic logic gates. These are circuits that take signals representing binary values as inputs (on the left of each gate in our diagram) and produce a signal representing the output value specified by the relevant truth table. The symbols are idealisations the actual circuits may have other

connections, for example, to provide power.

slide-17
SLIDE 17

] A B C (A ⋁ ¬B) ⋀ (¬B ⨁ C) ] A B C B

let bbar = not B 
 in (A || bbar) && (bbar ⨁ C) (A || not B) && (not B ⨁ C)

Exercise: define ⨁ in Haskell

The computation of the next state can be implemented by some basic logic gates. These are circuits that take signals representing binary values as inputs (on the left of each gate in our diagram) and produce a signal representing the output value specified by the relevant truth table. The symbols are idealisations the actual circuits may have other

connections, for example, to provide power. The sharing, or reuse, of a computed value corresponds to the let … in … pattern in Haskell. Write a Haskell function to print out the truth table for a boolean function.

slide-18
SLIDE 18

] A B C (A ⋁ ¬B) ⋀ (¬B ⨁ C)

A B B C ¬ ¬ ⋁ ⨁ ⋀

Circuit Formula Syntax tree

ABC A⋁¬B ¬B⨁C

  • ut

000 1 1 1 001 1 010 011 1 100 1 1 1 101 1 110 1 111 1 1 1

Function

A B C ¬ ⋁ ⨁ ⋀

DAG

Two Boolean circuits or formulæ are equivalent if they compute the same Boolean function. That is, they have the same truth table,

  • r equivalently, they are represented by the same set of valuations.

A circuit can express the re-use of a subcomputation, in a way that an expression cannot. A formula is represented abstractly by a syntax tree. A circuit can be represented abstractly by a Directed Acyclic Graph (DAG)

slide-19
SLIDE 19

??

19

Find a proposition

slide-20
SLIDE 20

Basic Boolean operations

1, > true, top _ disjunction, or ^ conjunction, and ¬ negation, not 0, ? false, bottom

20

Boole (1815 – 1864)

slide-21
SLIDE 21

The algebra of sets

P(S) = {X | X ⊆ S}

21

X ∨ Y = X ∪ Y union X ∧ Y = X ∩ Y intersection ¬X = S \ X complement 0 = ∅ empty set 1 = S entire set