Math Wiki
No edit summary
Line 9: Line 9:
 
Boolean logic statements can only return one of two values - true or false.
 
Boolean logic statements can only return one of two values - true or false.
   
===Boolean Operators 'and', 'or', 'not' and 'equals'===
+
===Boolean Operators ''and'', ''or'' and ''equals''===
   
The main operators in Boolean statements are 'and', 'or', 'not' and 'equals'.
+
The main operators in Boolean statements are ''and'', ''or'' and ''equals''.
 
To keep the statements succinct we use symbols to represent each of these operators. Programming languages use a range of abbreviations for these operators but in mathematics the following are used:
 
To keep the statements succinct we use symbols to represent each of these operators. Programming languages use a range of abbreviations for these operators but in mathematics the following are used:
   
Line 17: Line 17:
   
 
or - <math>\lor</math>
 
or - <math>\lor</math>
 
not - <math>\lnot</math>
 
   
 
equals - <math>=</math>
 
equals - <math>=</math>
Line 24: Line 22:
 
Equals is used to test whether the value on the left side of the statement is equivalent to the value on the right side. If it is then the returned value is true.
 
Equals is used to test whether the value on the left side of the statement is equivalent to the value on the right side. If it is then the returned value is true.
   
e.g. <math>2+3=5</math> returns true. We can read this as "The statement 'two plus three equals five' is true."
+
e.g. <math>2+3=5</math> returns true. We can read this as "The statement ''two plus three equals five'' is true."
   
while <math>3+4=6</math> returns false. We can read this as "The statement 'three plus four equals six' is false."
+
while <math>3+4=6</math> returns false. We can read this as "The statement ''three plus four equals six'' is false."
 
(Note that the addition operator, +, is not a boolean operator)
 
(Note that the addition operator, +, is not a boolean operator)
   
These statements can now be combined using the 'and' operator or the 'or' operator as follows:
+
These statements can now be combined using the ''and'' operator or the ''or'' operator as follows:
   
 
<math>(2+3=5) \land (4+2=6)</math> returns true because both statements are true. (The brackets are only added to clarify what is happening.)
 
<math>(2+3=5) \land (4+2=6)</math> returns true because both statements are true. (The brackets are only added to clarify what is happening.)
   
This can be read as follows: Because 'two plus three equals five' is true '''and''' 'four plus two equals six' is true then the overall statement is true.
+
This can be read as follows: Because ''two plus three equals five'' is true '''and''' ''four plus two equals six'' is true then the overall statement is true.
   
 
Conversely we have this:
 
Conversely we have this:
Line 39: Line 37:
 
<math>(2+3=5) \land (4+2=7)</math> returns false because one statement is true while one is false and with the 'and' operator it is necessary for both statements to be true for the overall one to return true.
 
<math>(2+3=5) \land (4+2=7)</math> returns false because one statement is true while one is false and with the 'and' operator it is necessary for both statements to be true for the overall one to return true.
   
This can be read as follows: 'two plus three equals five' is true '''and''' 'four plus two equals seven' is false so the overall statement is false.
+
This can be read as follows: ''two plus three equals five'' is true '''and''' ''four plus two equals seven'' is false so the overall statement is false.
   
The 'or' operator works differently from the 'and' operator. With 'or' it is only necessary that one part of the statement is true for the overall statement to be true.
+
The ''''or'''' operator works differently from the ''and'' operator. With ''or'' it is only necessary that one part of the statement is true for the overall statement to be true.
 
Thus:
 
Thus:
   
<math>(2+3=5) \lor (4+2=7)</math> returns true because one statement is true while one is false and with the 'or' operator it is only necessary for one statement to be true for the overall one to return true.
+
<math>(2+3=5) \lor (4+2=7)</math> returns true because one statement is true while one is false and with the ''or'' operator it is only necessary for one statement to be true for the overall one to return true.
   
 
If both statments are true then the overall statement is still true.
 
If both statments are true then the overall statement is still true.
Line 100: Line 98:
   
   
  +
===Boolean Operators - the ''not'' operator===
   
  +
The ''''not'''' operator reverses the value of the statement. This amkes sense since ''not true'' is obviously ''false'' and vice versa.
  +
 
not - <math>\lnot</math>
   
   

Revision as of 10:35, 2 May 2007

Boolean logic is a complete system for logical operations. It was named after George Boole, an English mathematician at University College Cork who first defined an algebraic system of logic in the mid 19th century. Boolean logic has many applications in electronics, computer hardware and software. In 1938, Claude Shannon showed how electric circuits with relays were a model for Boolean logic. This fact soon proved enormously consequential with the emergence of the electronic computer.

Boolean logic is used extensively in creating computer programs particularly to control flow of the program. 'If' statements are flow control instructions which are encountered in nearly every computer language and which use boolean logic. The 'if' statment returns a value of either true or false and the program is redirected accordingly.

Boolean Statements

True and False

Boolean logic statements can only return one of two values - true or false.

Boolean Operators and, or and equals

The main operators in Boolean statements are and, or and equals. To keep the statements succinct we use symbols to represent each of these operators. Programming languages use a range of abbreviations for these operators but in mathematics the following are used:

and -

or -

equals -

Equals is used to test whether the value on the left side of the statement is equivalent to the value on the right side. If it is then the returned value is true.

e.g. returns true. We can read this as "The statement two plus three equals five is true."

while returns false. We can read this as "The statement three plus four equals six is false." (Note that the addition operator, +, is not a boolean operator)

These statements can now be combined using the and operator or the or operator as follows:

returns true because both statements are true. (The brackets are only added to clarify what is happening.)

This can be read as follows: Because two plus three equals five is true and four plus two equals six is true then the overall statement is true.

Conversely we have this:

returns false because one statement is true while one is false and with the 'and' operator it is necessary for both statements to be true for the overall one to return true.

This can be read as follows: two plus three equals five is true and four plus two equals seven is false so the overall statement is false.

The 'or' operator works differently from the and operator. With or it is only necessary that one part of the statement is true for the overall statement to be true. Thus:

returns true because one statement is true while one is false and with the or operator it is only necessary for one statement to be true for the overall one to return true.

If both statments are true then the overall statement is still true.

Since all this can become quite verbose we use another abbreviation to help. Instead of showing statements such as we represent and true statement by the value and any false statement by the value .

Now our statement becomes which is true and therefore equals .

Further our statement becomes which is false and therefore equals .

Extending this to our 'or' statements we get:

and

Truth Tables

This now allows us to introduce the concept of truth tables. Truth tables allow us to show the results of our boolean statements in concise form.

For And we have

  If statement 1 is false and statement 2 is false then the result is false
  If statement 1 is false and statement 2 is true then the result is false
  If statement 1 is true and statement 2 is false then the result is false
  If statement 1 is true and statement 2 is true then the result is true

For Or we have

   If statement 1 is false or statement 2 is false then the result is false
   If statement 1 is true or statement 2 is false then the result is true
   If statement 1 is false or statement 2 is true then the result is true
   If statement 1 is true or statement 2 is true then the result is true


Boolean Operators - the not operator

The 'not' operator reverses the value of the statement. This amkes sense since not true is obviously false and vice versa.

not -