CS40-S13: Functional Completeness

Similar documents
Homework 1. Due Date: Wednesday 11/26/07 - at the beginning of the lecture

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

Propositional Calculus: Boolean Algebra and Simplification. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

BOOLEAN ALGEBRA AND CIRCUITS

2. BOOLEAN ALGEBRA 2.1 INTRODUCTION

CS February 17

Propositional Calculus. Math Foundations of Computer Science

2.2 Set Operations. Introduction DEFINITION 1. EXAMPLE 1 The union of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 2, 3, 5}; that is, EXAMPLE 2

Introduction to Computer Architecture

Binary Decision Diagrams

CS Bootcamp Boolean Logic Autumn 2015 A B A B T T T T F F F T F F F F T T T T F T F T T F F F

Boolean networks, local models, and finite polynomial dynamical systems

Propositional Calculus. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Semantics via Syntax. f (4) = if define f (x) =2 x + 55.

[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics

COMP combinational logic 1 Jan. 18, 2016

Formal Methods of Software Design, Eric Hehner, segment 1 page 1 out of 5

Starting Boolean Algebra

PCP and Hardness of Approximation

Combinational Circuits

COMP260 Spring 2014 Notes: February 4th

Mathematically Rigorous Software Design Review of mathematical prerequisites

(a) (4 pts) Prove that if a and b are rational, then ab is rational. Since a and b are rational they can be written as the ratio of integers a 1

CSC Discrete Math I, Spring Sets

Propositional Logic. Part I

Example of a Demonstration that a Problem is NP-Complete by reduction from CNF-SAT

(d) If the moon shares nothing and the sun does not share our works, then the earth is alive with creeping men.

Propositional Calculus. Math Foundations of Computer Science

Chapter 3. Set Theory. 3.1 What is a Set?

Mathematical Logic Prof. Arindama Singh Department of Mathematics Indian Institute of Technology, Madras. Lecture - 9 Normal Forms

for all x, the assertion P(x) is false. there exists x, for which the assertion P(x) is true.

Propositional Calculus: Boolean Functions and Expressions. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

An Evolution of Mathematical Tools

HW1. Due: September 13, 2018

(Refer Slide Time 3:31)

Algebra of Sets. Aditya Ghosh. April 6, 2018 It is recommended that while reading it, sit with a pen and a paper.

AP Calculus. Slide 1 / 213 Slide 2 / 213. Slide 3 / 213. Slide 4 / 213. Slide 4 (Answer) / 213 Slide 5 / 213. Derivatives. Derivatives Exploration

Lecture 5. Logic I. Statement Logic

IT 201 Digital System Design Module II Notes

Algebra of Sets (Mathematics & Logic A)

Order from Chaos. Nebraska Wesleyan University Mathematics Circle

Graphs (MTAT , 6 EAP) Lectures: Mon 14-16, hall 404 Exercises: Wed 14-16, hall 402

Diagonalization. The cardinality of a finite set is easy to grasp: {1,3,4} = 3. But what about infinite sets?

Ma/CS 6a Class 8: Eulerian Cycles

Informatics 1 - Computation & Logic: Tutorial 3

Boolean algebra. June 17, Howard Huang 1

CS 3512, Spring Instructor: Doug Dunham. Textbook: James L. Hein, Discrete Structures, Logic, and Computability, 3rd Ed. Jones and Barlett, 2010

Polynomial SAT-Solver Algorithm Explanation

Grade 7/8 Math Circles Fall November 6/7/8 Boolean Logic

1 Linear programming relaxation

Notes. Notes. Introduction. Notes. Propositional Functions. Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry.

Chapter 1.3 Quantifiers, Predicates, and Validity. Reading: 1.3 Next Class: 1.4. Motivation

1 Algorithm and Proof for Minimum Vertex Coloring

Program Verification & Testing; Review of Propositional Logic

Lecture Transcript While and Do While Statements in C++

Grade 7/8 Math Circles Fall November 6/7/8 Boolean Logic

Notes on Turing s Theorem and Computability

LECTURE 2 An Introduction to Boolean Algebra

9/19/12. Why Study Discrete Math? What is discrete? Sets (Rosen, Chapter 2) can be described by discrete math TOPICS

Math Week in Review #5. A proposition, or statement, is a declarative sentence that can be classified as either true or false, but not both.

Order from Chaos. University of Nebraska-Lincoln Discrete Mathematics Seminar

The Resolution Algorithm

4 KARNAUGH MAP MINIMIZATION

Section 2.2: Introduction to the Logic of Quantified Statements

Recursively Enumerable Languages, Turing Machines, and Decidability

Lecture 22 Tuesday, April 10

Combinational Circuits Digital Logic (Materials taken primarily from:

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/27/18

6.001 Notes: Section 8.1

Discrete Mathematics and Probability Theory Fall 2016 Seshia and Walrand Midterm 1

Reductions and Satisfiability

Review. EECS Components and Design Techniques for Digital Systems. Lec 05 Boolean Logic 9/4-04. Seq. Circuit Behavior. Outline.

Formal Methods of Software Design, Eric Hehner, segment 24 page 1 out of 5

Math 55 - Spring 04 - Lecture notes # 1 - Jan 20 (Tuesday)

Ramsey s Theorem on Graphs

Chapter 2. Boolean Expressions:

Mixed Integer Linear Programming

MC 302 GRAPH THEORY 10/1/13 Solutions to HW #2 50 points + 6 XC points

On Meaning Preservation of a Calculus of Records

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

The following is a summary, hand-waving certain things which actually should be proven.

Propositional Logic. Application of Propositional logic

Some Hardness Proofs

NP-Completeness of 3SAT, 1-IN-3SAT and MAX 2SAT

(Refer Slide Time 6:48)

TA: Jade Cheng ICS 241 Recitation Lecture Notes #12 November 13, 2009

Standard Boolean Forms

MATH 682 Notes Combinatorics and Graph Theory II

CS 3EA3: Sheet 9 Optional Assignment - The Importance of Algebraic Properties

Boolean Representations and Combinatorial Equivalence

CSC 501 Semantics of Programming Languages

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter p. 1/27

Disjunctive and Conjunctive Normal Forms in Fuzzy Logic

The complement of PATH is in NL

Definition 1 (Hand-shake model). A hand shake model is an incidence geometry for which every line has exactly two points.

The Structure of Bull-Free Perfect Graphs

MITOCW watch?v=4dj1oguwtem

6.001 Notes: Section 1.1


Transcription:

CS40-S13: Functional Completeness Victor Amelkin victor@cs.ucsb.edu April 12, 2013 In class, we have briefly discussed what functional completeness means and how to prove that a certain system (a set) of logical operators is functionally complete. In this note, I will review what functional completeness is, how to prove that a system of logical operators is complete as well as how to prove that a system is incomplete. 1 Introduction When we talk about logical operators, we mean operators like,,,,. Logical operators work on propositions, i.e. if we write a b, then both a and b are propositions. The mentioned propositions may be either simple or compound, as in a (x y) }{{} b here, a is simple, while b is compound. For a logical operator it does not matter whether it operates on simple or compound propositions; the only thing that matters is that all the arguments are propositions, i.e., either True of False. Since logical operators apply to propositions and return either True or False, they can be seen as boolean functions. For example, conjunction (x 1, x 2 ) = x 1 x 2 is a binary boolean function, i.e., it accepts two arguments (hence, binary ) that can be either True of False and returns either True of False (hence, boolean ). As another example, negation can be seen as a unary (accepts only one argument) boolean function (x) = x. We, however, rarely use the functional notation (x 1, x 2 ) (like in f(x)); instead, we usually use the operator notation, e.g., x 1 x 2. (Similarly, when you do algebra, you probably write a + b instead of +(a, b), unless you do algebra in Lisp.) Further, instead of talking about logical operators, we will talk about boolean functions, but, having read the material above, you should understand that these two are the same. Additionally, as it is usually done with boolean functions, instead of using True and False, we will write 1 for True and 0 for False, but this change is just notational. 1

2 Functional completeness Now, we can talk about functional completeness of a system (a set) of boolean functions (or logical operators, as you wish). def. A system S of boolean functions (or, alternatively, logical operators) is functionally complete if every boolean function (or, alternatively, every compound proposition) can be expressed in terms of the functions from S. For example, let us look at the following system of boolean functions S = {,, }. For this system to be functionally complete, by definition, every possible boolean function (or, alternatively, every compound proposition) should be expressible using only functions from S. For instance, if we have a boolean function (a compound proposition) P (x 1, x 2, x 3 ) = x 1 (x 2 x 3 ) (x 1 x 3 ), we should be able to rewrite P using only,, and. In case with P, it is easy to rewrite it using only functions from set S: we know that x y ( x y) (x y) and x y x y, and we can rewrite P using these equivalences. Alternatively, we can build the truth table for P and then write down P s disjunctive normal form (DNF). DNF, as you remember, uses only,, and, so the goal to rewrite P using only functions from S is achieved. We can use similar reasoning to prove that any other system of boolean functions is functionally complete. For example, in one of the homeworks, you should have proven that system S = {, } is functionally complete. Your proof might have looked as follows: Proof. For every boolean function (or, alternatively, every compound proposition), we can write down its truth table. Using the truth table, we can construct the DNF. DNF uses only,, and, all of whom are expressible in terms of S = {, }. For and, it is obvious why they are expressible they are members of S. And the remaining function can be expressed in terms of and using one of De Morgan s laws: Thus, S = {, } is functionally complete. x y = ( x y). 2

3 Incompleteness Sometimes, however, the problem is opposite we may need to prove that a certain system S of boolean functions is not functionally complete. According to the definition of functional completeness, it means that not every function/proposition can be expressed using only functions from S. For example, a system S = {, } is not functionally complete, i.e., some boolean functions cannot be rewritten using only and. We can guess that is probably one of those functions not expressible in terms of and, but the problem is to prove it. 3.1 A programming contest metaphor Prior to plunging into proving and disproving functional completeness, imagine a team of students participating in a programming contest. In this contest, the problems require knowledge of some (maybe even all) of the following: knowledge of C++, knowledge of search algorithms, good understanding of the material given in CS40 at UCSB (in Spring, 2013). We have a team of three students, each of whom knows some of the mentioned topics. Let us display this information in a table form: knows C++ knows search aced CS40 Alice + + Bob + Clive + In the table above, for every team member, we specify whether he or she is familiar with each topic. For example, Bob apparently does not know C++ and has no idea how to search, so we put in the corresponding cells. However, Bob has aced CS40; thus, we put + in the corresponding cell. It is clear that if a certain programming problem requires knowledge of C++, then at least one team member should know C++, so that the team can solve this problem. It is easy to see that for every of three mentioned topics (C++, search, CS40), there is at least one team member familiar with it (in every column of our table, there is at least one +). Thus, we can claim that regardless of what problem this team is presented with, as long as this problem only requires knowledge of C++ and/or search and/or CS40, then this team can solve it. This sounds very similar to the definition of functional completeness ( regardless of what function we are presented with, we can express it using the functions from the system ). We will see that testing functional completeness is very similar to what we did with the programming contest team. 3

3.2 Back to functions Indeed, things are very similar when we deal with functional completeness. Instead of a team of students, we have a team (a system) of functions. And instead of three topics that students may know (C++, search, CS40), we will deal with five properties functions may or may not have. The completeness test itself will be similar to identifying whether a team has at least one member knowing each topic. First, let us describe those five properties of boolean functions. Property 1: We say that boolean function f preserves zero, if on the 0-input it produces 0. By the 0-input we mean such an input, where every input variable is 0 (this input usually corresponds to the first row of the truth table). We denote the class of zero-preserving boolean functions as T 0 and write f T 0. Here are the truth tables for a few boolean functions we are familiar with: x x 0 1 1 0 x 1 x 2 x 1 x 2 0 1 0 1 0 0 x 1 x 2 x 1 x 2 0 1 1 1 0 1 We see that on 0-input, both and produce 0, while produces 1. Thus, and preserve zero, and does not. We write T 0 and T 0, but / T 0. Property 2: Similarly to T 0, we say that boolean function f preserves one, if on 1-input, it produces 1. The 1-input is the input where all the input variables are 1 (this input usually corresponds to the last row of the truth table). We denote the class of one-preserving boolean functions as T 1 and write f T 1. Looking at the truth tables of out three functions, we see that does not preserve one since it produces 0 on 1-input. However, both and preserve 1, since their values on 1-input are both 1. x x 0 1 1 0 x 1 x 2 x 1 x 2 0 1 0 1 0 0 x 1 x 2 x 1 x 2 0 1 1 1 0 1 Thus, T 1 and T 1, but / T 1. 4

Property 3: We say that boolean function f is linear if one of the following two statements holds for f: For every 1-value of f, the number of 1 s in the corresponding input is odd, and for every 0-value of f, the number of 1 s in the corresponding input is even. or For every 1-value of f, the number of 1 s in the corresponding input is even, and for every 0-value of f, the number of 1 s in the corresponding input is odd. If one of these statements holds for f, we say that f is linear 1. We denote the class of linear boolean functions with L and write f L. Now, let us check whether our three functions are linear. x x 0 1 1 0 x 1 x 2 x 1 x 2 0 1 0 1 0 0 x 1 x 2 x 1 x 2 0 1 1 1 0 1 In the case of, for every 1-value of this function, the number of 1 s among the input variables is always even. Actually, there is only one 1-value of, and the number of 1 s in the corresponding input is 0, which is an even number. Similarly, for every 0-value of (and there is only one such value), the number of 1 s in the input is odd (we have the only input variable, and it is 1 in the corresponding row). Thus, is linear. Using the same reasoning, we can show that neither nor is linear. is not linear because on 0 outputs, the number of 1 s in the corresponding inputs is sometimes even and sometimes odd. Thus, neither of two conditions from our definition can hold for. Similarly, is not linear because on 1-outputs, the number of 1 s in the corresponding inputs is sometimes even and sometimes odd. Thus, L, but / L and / L. 1 You may wonder why such functions are called linear, yet there is no sign of linearity as we know it from calculus. The terrible truth about the given definition of linear boolean functions is that it is not a definition, but a criterion (i.e., a necessary and sufficient condition for linearity of a boolean function). The definition of a linear boolean function, yet, clearly manifests linearity, is too complicated, and, as such, has been omitted. If, however, you are still curious: a boolean function is linear by definition (this time, real definition) if its Zhegalkin polynomial is linear. 5

Property 4: We say that boolean function f is monotone if for every input, switching any input variable from 0 to 1 can only result in the function s switching its value from 0 to 1, and never from 1 to 0. We denote the class of monotone boolean functions with M and write f M. Yet the given definition looks slightly intimidating, it is actually very easy to check monotonicity by looking at the following Hasse diagrams: 1 0 11 1 11 1 01 0 0 10 0 10 0 1 00 0 00 0 Figure 1: Checking monotonicity with Hasse diagrams Here is how these diagrams are built. For a function you want to check for monotonicity, draw a vertex (or a circle, as it is done on the diagrams above) for every row in the function s truth table. Next to each vertex, write the corresponding input from the truth table. Inside each vertex, write the value of the function on the corresponding input. Finally, draw arrows using the following rule: if input B can be obtained from input A by switching exactly one input variable from 0 to 1, then draw an arrow from the vertex corresponding to input A to the vertex corresponding to input B. For example, the middle diagram is built for. Its truth table contains 4 rows, thus there are 4 vertices (circles) on the diagram. Next to each vertex, we write input values and connect vertices with arrows using the mentioned rule. (For example, 01 can be obtained from 00 by switching exactly one input variable from 0 to 1. Thus, there is an arrow from 00 to 01. However, 11 cannot be obtained from 00 by switching exactly one input variable from 0 to 1. Thus, there is no arrow from 00 to 11.) Now, to check whether a function is monotone, follow every path on this function s Hasse diagram from 0-input (all input variables are 0) to 1-input (all input variables are 1). The boolean function is monotone if on every such path, it never decreases its value (never goes from 1 to 0), yet, it can remain constant or grow (i.e., switch from 0 to 1). For example, for, there are two paths from 00-input to 11-input, and on both these paths, is either constant or it changes from 0 to 1. Thus, is monotone. The same is true for there are two paths from 00 to 11 on its Hasse diagram, and on both of these paths never decreases. The things are different, however, in case of. There is only one path from 0-input to 1-input, and on this path, decreases (switches its value from 1 to 0). Thus, is not monotone. We have M and M, but / M. 6

Property 5: We say that boolean function f(x 1,..., x n ) is self-dual if f(x 1,..., x n ) = f( x 1,..., x n ). The function on the right in the equality above (the one with negations) is called the dual of f. We will call the class of self-dual boolean functions S and write f S. Finally, something that can be easily checked. Let us start with negation. The dual for x is ( ( x)) = x. Thus, it is clear that is self-dual. The things are different for and. The dual for x y is (( x) ( y)), and the latter, according to one of De Morgan s laws is x y. It is clear that x y and its dual x y have different values on some inputs and, thus, are not equivalent. Thus, is not self-dual. Using the same reasoning, we can show that is also not self-dual. Thus, S, but / S and / S. We are done with properties and ready to state the criterion of functional completeness of a system of boolean functions. Theorem. A system of boolean functions is functionally complete if and only if this system does not entirely belong to any of T 0, T 1, L, M, S. The mentioned theorem is called Post s completeness criterion and is due to Emil Post. What this criterion says is that in order for a system of boolean functions to be functionally complete, this system should have at least one function that does not preserve zero (i.e. it is not in T 0 ), and at least one function that does not preserve one (i.e. it is not in T 1 ), and at least one function that is not linear (i.e. it is not in L), and at least one function that is not monotone (i.e. it is not in M), and at least one function that is not self-dual (i.e. it is not in S). Of course, one function may combine some of these roles, e.g., a function may not preserve one and, at the same time, not be monotone. Next, we will see how to use this criterion in practice. 7

4 Testing completeness Let us now apply Post s criterion to test completeness of some systems of boolean functions. We will specify which function belongs to which classes and display the results in a table as we did with the students and skills for the programming contest. Fortunatelly, we have already established what classes each of,, and belongs to, so we will just collect these results. + + + + + + + According to Post s criterion, for a system {,, } of boolean functions to be functionally complete, there should be at least one + in every column of the table above, which is obviously true. Thus, by Post s criterion, the system {,, } is functionally complete. But we have already knew it, so let us now try to look at different systems of functions. Let us look at an abridged system {, }. + + + + + Still, every column of the table contains at least one +. Thus, system {, } is also functionally complete. This result should match the result you should have obtained in your homework (though, you should have proven completeness of this system differently). Now, how about system {, }? + + + + The columns corresponding to classes T 0, T 1, and M have no + es, which means that system {, } is not functionally complete. An easy way to understand Post s criterion is as follows: if all of the functions in our system of boolean functions, say, preserve zero, i.e., all of them are in T 0, then regardless of how we combine our functions, the resulting function will also preserve zero. This is true for each of the mentioned classes of functions. If all functions of our system are inside one of the five mentioned classes, then every function expressible in terms of these functions also belongs to this class. Consequently, functions outside of this class cannot be expressed in term of the functions of our system. This property of our five classes is called closedness, and, hence, the classes T 0, T 1, L, M, and S are usually called the closed classes of boolean functions. If we are inside one of these classes, there is no escape. To escape, at least one of our functions should be outside. 8

5 Sheffer stroke and Peirce s arrow As a finishing touch, let us look at another boolean function (or, alternatively, logical operator). It is a binary boolean function called Sheffer stroke or NAND, denoted with (or, sometimes, ) x 1 x 2 x 1 x 2 0 0 1 0 1 1 1 0 1 1 1 0 By looking at the truth table of Sheffer stroke, it becomes clear why it also goes under the name NAND it is equivalent to not-and, i.e., (x 1 x 2 ). The surprising fact about Sheffer stroke is that it posesses the ultimate expressive power, that is, the system of boolean functions consisting of only Sheffer stroke is functionally complete. In other words, regardless of what boolean function we have, it can be rewritten using only Sheffer stroke. Let us check whether it is true using Post s criterion. We need to check whether belongs to any of the classes T 0, T 1, L, M, S. According to Post s criterion, the system { } consisting only of Sheffer stroke will be functionally complete iff Sheffer stroke does not belong to any of T 0, T 1, L, M, S, i.e., all the cells in the following table should be filled with +.????? By looking at the truth table of, we see that it does not preserve zero, since it is 1 on the 0-input. Similarly, it does not preserve one. Thus, we have + +??? The linearity conditions cannot hold for, since on 1-outputs, the number of 1 s among the input variables is sometimes even and sometimes odd. Thus, is not linear: + + +?? 9

To check monotonicity, let us draw a Hasse diagram for : 11 0 0 10 00 1 Figure 2: Checking monotonicity of On both paths from 00 to 11, function decreases its value from 1 to 0 when moving from 01 or 10 to 11. Thus, is not monotone: + + + +? Finally, let us check self-duality: dual(x 1 x 2 ) = ( x 1 x 2 ) = ( ( x 1 x 2 )) = (x 1 x 2 ) = x 1 x 2. The boolean function we obtained as the dual for is called Peirce s arrow or NOR (guess why?) and it is clearly not the same as. Thus, is not self-dual. + + + + + We see that every column in the obtained table contains at least one +, which means that the system consisting of single function is functionally complete. To resolve any doubts, let us see how and can be expressed using only Sheffer stroke: x = x x, x 1 x 2 = (x 1 x 2 ) (x 1 x 2 ). As an excercise, check whether a system of boolean functions consisting only of Peirce s arrow 2 is functionally complete. 2 x 1 x 2 = (x 1 x 2 ) 10