Monday, March 30, 2009

DISJUNCTION (v) or INCLUSIVE OR

DISJUNCTION (v) or INCLUSIVE OR

If p and q are statements, then the disjunction of p and q is “p or q”, denoted as “p v q” It is true when at least one of p or q is true and is false only when both p and q are false.

Note that in the table F is only in that row where both p and q have F and all other values are T. Thus for finding out the truth values for the disjunction of two statements we will only first search out where the both statements are false and write down the F in the corresponding row in the column of p v q and in all other rows we will write T in the column of p v q.

Remark:

Note that for Conjunction of two statements we find the T in both the statements, But in disjunction we find F in both the statements. In other words we will fill T first in the column of conjunction and F in the column of disjunction.

CONJUNCTION

CONJUNCTION


If p and q are statements, then the conjunction of p and q is “p and q”, denoted as “p ^ q”.
It is true when, and only when, both p and q are true. If either p or q is false, or if both are false, p^q is false.


Note that in the table T is only in that row where both p and q have T
and all other values are F. Thus for finding out the truth values for the conjunction of two statements we will only first search out where the
both statements are true and write down the T in the corresponding row
in the column of p ^ q and in all other rows we will write F in the
column of p ^ q.

NEGATION (~)

NEGATION (~)

If p is a statement variable, then negation of p, “not p”, is denoted as “~p”
It has opposite truth value from p i.e., if p is true, ~p is false; if p is false,
~p is true.
EXAMPLES
“Ali is not a Computer Science student” then its negation is “Ali is a computer Science student”
“I like my course of Discrete mathematics ”then its negation is “I don't like my Discrete mathematics course”
“2 + 3 is equal to 5” then its negation is “2 + 3 is not equal to 5”

TRUTH TABLE

TRUTH TABLE


TRUTH TABLE is A convenient method for analyzing a compound statement is to make a truth table for it.
A truth table specifies the truth value of a compound proposition for all possible truth values of its constituent propositions.


The truth values “true” and “false” are respectively denoted by the letters T and F.






Truth Table:


Often we want to discuss properties/relations common to all propositions. In such a case rather than stating them for each individual proposition we use variables representing an arbitrary proposition and state properties/relations in terms of those variables. Those variables are called a propositional variablePropositional variables are also considered a proposition and called a proposition since they represent a proposition hence they behave the same way as propositions. A proposition in general contains a number of variables. For example (P  Q) contains variables P and Q each of which represents an arbitrary proposition. Thus a proposition takes different values depending on the values of the constituent variables. This relationship of the value of a proposition and those of its constituent variables can be represented by a table. It tabulates the value of a proposition for all possible values of its variables and it is called a truth table


For example the following table shows the relationship between the values of P, Q and P  Q: 


OR
PQ(P  Q)
FFF
FTT
TFT
TTT



















In the table, F represents truth value false and T true. 
This table shows that P  Q is false if P and Q are both false, and it is true in all the other cases. 

SYMBOLIC REPRESENTATION

SYMBOLIC REPRESENTATION

Statements are symbolically represented by letters such as p, q, r,...

EXAMPLES
p = “Islamabad is the capital of Pakistan”
q = “17 is divisible by 3”

LOGICAL CONNECTIVES

CONNECTIVE MEANINGS SYMBOL CALLED
Negation not ~ Tilde
Conjunction and  Hat
Disjunction or  Vel
Conditional if…then…  Arrow
Biconditional if and only if  Double arrow


EXAMPLES
p = “Islamabad is the capital of Pakistan”
q = “17 is divisible by 3”
p  q = “Islamabad is the capital of Pakistan and 17 is divisible by 3”
p  q = “Islamabad is the capital of Pakistan or 17 is divisible by 3”
~p = “It is not the case that Islamabad is the capital of Pakistan” or simply “Islamabad is not the capital of Pakistan”

COMPOUND STATEMENT

COMPOUND STATEMENT

Simple statements could be used to build a compound statement.

EXAMPLES

1. “3 + 2 = 5” and “Lahore is a city in Pakistan”
Here 3 + 2 = 5 is a statement and Lahore is a city in Pakistan is another statement we combine these two statements by using and to form another statement and you can talk about its truth value. Similarly in the next example we combine two statements by using or to form another statement.
2. “The grass is green” or “ It is hot today”

3. “Discrete Mathematics is not difficult to me”
Here the original statement is Discrete Mathematics is difficult to me and we form the new statement by using not.

AND, OR, NOT are called LOGICAL CONNECTIVES.


OR

COMPOUND STATEMENT
compound statement (or block) is a sequence of statements, enclosed by braces, that stands in place of a single statement. Simple and compound statements are completely interchangeable as far as the syntax of the C language is concerned. Therefore, the statements that comprise a compound statement may themselves be compound; that is, blocks can be nested. Thus, it is legal to write

// 3 wide 16 bit signed median filter
short median(short n1,short n2,short n3){
    if(n1>n2){
      if(n2>n3)
        return(n2);    // n1>n2,n2>n3    n1>n2>n3
      else{
      if(n1>n3)
        return(n3);    // n1>n2,n3>n2,n1>n3 n1>n3>n2
      else
        return(n1);    // n1>n2,n3>n2,n3>n1 n3>n1>n2
      }
    }
    else{
      if(n3>n2)
        return(n2);    // n2>n1,n3>n2     n3>n2>n1
      else{
        if(n1>n3)
          return(n1);  // n2>n1,n2>n3,n1>n3 n2>n1>n3
        else
          return(n3);  // n2>n1,n2>n3,n3>n1 n2>n3>n1
      }
    }
}

Example of nested compound statements.
Although C is a free-field language, notice how the indenting has been added to the above example. The purpose of this indenting is to make the program easier to read. On the other hand since C is a free-field language, the following two statements are quite different

if(n1>100) n2=100; n3=0;
if(n1>100) {n2=100; n3=0;}

In both cases n2=100; is executed if n1>100. In the first case the statement n3=0; is always executed, while in the second case n3=0; is executed only if n1>100.


Ref: http://users.ece.utexas.edu/~valvano/embed/chap1/chap1.htm



UNDERSTANDING STATEMENTS

UNDERSTANDING STATEMENTS


x + 2 is positive.
The above sentence is not a statement because it is true for some value of x and false for some values of x. We can say that the truth value of the statement is vague
2. May I come in?
The above sentence is permission and hence we can't talk about its truth values so it is also not a statement.
Logic is interesting.
Logic is interesting is a statement because logic is interesting and its truth value is T.
It is hot today.
It is hot today is also a statement because whenever we say this sentence then that day either hot or not so we can assign a truth value to this sentence.
5. -1 > 0 is also a statement with truth value F
x + y = 12 is not a statement.

EXAMPLES

x = 1 is a sentence which gives us the information about the variable which is in the below sentence. .
x > 2 now using the value above we can see that our sentence takes the form 1 > 2 now we can talk about its truth value . So
x > 2 is a statement with truth-value FALSE.
Similarly in the next example

Sunday, March 29, 2009

What is Discrete Mathematics?

What is Discrete Mathematics?


Discrete Mathematics concerns processes that consist of a sequence of individual steps.
This distinguishes it from calculus, which studies continuously changing processes. While the ideas of calculus were fundamental to the science and technology of the industrial revolution, the ideas of discrete mathematics underline the science and technology specific to the computer age.


MAIN TOPICS
  1. Logic.
  2. Sets and Operations on sets.
  3. Relations and Their Properties.
  4. Functions.
  5. Sequences and Series.
  6. Recurrence Relations.
  7. Mathematical Induction.
  8. Loop Invariants.
  9. Loop Invariants.
  10. Combinatorics.
  11. Probability.
  12. Graphs and Trees.

EXAMPLES OF SENTENCES WHICH ARE NOT PROPOSITIONS:

EXAMPLES OF SENTENCES WHICH ARE NOT PROPOSITIONS:


Consider the following sentences
Close the door.
x is greater than 2.
He is very rich
What time is it ?
Read this carefully.
x + z = 10
are not propositions.


REMARK:
If sentence is a question or command , or it is vague or nonsensical, then it cannot be classified as true or false then the sentence cannot be a statement or proposition, as easily seen in the above sentences.
The statements which involve variable or pronoun and there are some information about the variable or pronoun which make the role of variable clear then the sentence becomes statement.
For example in the last sentence if we say that x=3 and z=7 then this become a statement and its truth value is T and if we say x=8 and z=4 then the sentence has its truth value as F.
Here is the rule given below


RULE
If the sentence is preceded by other sentences that make the pronoun or variable reference clear, then the sentence is a statement.

EXAMPLES OF STATEMENTS OR PROPOSITIONS:

EXAMPLES OF STATEMENTS OR PROPOSITIONS:
  1. Grass is green. == Grass is green is a statement (or proposition) because the sentence is true and its truth value is T.( Because everyone knows that grass is green)
  2. 4 + 2 = 6 == 4 + 2 = 6 is also a statement and its truth value is T.(Because 4+2 is 6)
  3. 4 + 2 = 7 == 4 + 2 = 7 is also a statement and its truth value is F. ( Because we know that 4+2 is 6 not 7).Here you should note that both 2 and 3 are statements although 4+2=7 is mathematically wrong.
  4. There are four fingers in a hand. ==There are four fingers in a hand is also a statement and its truth value is false.
  5. Washington, D.C, is the capital of the United States of America. == The above statement is also a proposition and its truth value is T.
  6. Karachi is the capital of Pakistan. Karachi is the capital of Pakistan is also a statement and its truth value is F.
  7. Pervaiz Musharaf is the president of America.== The above sentence is a statement and its Truth value is false.
REMARK: Every sentence is not a statement.

Saturday, March 28, 2009

SIMPLE STATEMENT

SIMPLE STATEMENT


A statement is a declarative sentence that is either true or false but not both.
or
A statement is also referred to as a proposition. So when we say a statement or Proposition this must be clear to you that these are the same.




If a proposition is true, we say that it has a truth value of "true”.
If a proposition is false, its truth value is "false".


The truth values “true” and “false” are, respectively, denoted by the
letters T and F.

LOGIC

LOGIC


Logic is the study of the principles and methods that distinguishes between a valid and an invalid argument.