80 likes | 282 Views
EVALUATING BASIC LOGIC STATEMENTS. INTRO TO SYSTEM DESIGN. What is a Statement?. – a meaningful, declarative sentence that can only be either true or false. Examples of sentences that are (or make) statements : STATEMENT EVALUATES AS: "Socrates is a man." TRUE
E N D
EVALUATING BASIC LOGIC STATEMENTS INTRO TO SYSTEM DESIGN
What is a Statement? • – a meaningful, declarative sentence that can only be either true or false. • Examples of sentences that are (or make) statements: • STATEMENT EVALUATES AS: • "Socrates is a man." TRUE • "A triangle has three sides." TRUE • "Paris is the capital of Spain." FALSE • x = 6 TRUE (only if there are 6 ‘x’s) The first two (make statements that) are true, the third is (or makes a statement that is) false, the fourth is an evaluative statement (assigns a value).
There are only 2 possible logic states: True = ON, HI, YES, CLOSED, NOT FALSE, any integer greater than 0 False = OFF, LO, NO, OPEN, NOT TRUE, zero
Not all sentences are statements… Examples of sentences that are not (or do not make) statements: "Who are you?" "Run!" "Greenness walks slowly." "I had one cucumber but the eggplant over there." "The King of France is wise." "Pegasus exists."
EXPRESSIONS: • Evaluating logical statements always occurs by comparing 2 statements in an EXPRESSION: AND – the expression evaluates to TRUE only if both statements are TRUE OR – the expression evaluates to TRUE only if either statement is TRUE NAND – the expression evaluates to TRUE only if neither statement is TRUE (This is called an inverse statement) NOR – the expression evaluates to TRUE only if neither statement is TRUE NOT – the expression always evaluates as the OPPOSITE of the statement. This is not an evaluative or comparative statement. It is called a LOGIC INVERTER.
Truth Table • A truth table is composed of one column for each input variable (for example, A and B), and one final column for all of the possible results of the logical operation that the table is meant to represent. • Each row of the truth table contains one possible configuration of the input variables (for instance, A=true B=false), and the result of the operation for those values.
Conditional Expressions • the input conditions in the expression must be either TRUE or FALSE (depending on the expression) in order for the output condition to be evaluated as either TRUE or FALSE. Conditional expressions are always written as IF (STATEMENT A) LOGICAL OPERATOR (STATEMENT B) THEN (OUTPUT) REMEMBER: Statement A and Statement B can only be evaluated to TRUE or FALSE and the OUTPUT will only evaluate to TRUE or FALSE, depending on the operator.