190 likes | 452 Views
Need for “simplification”. From Textbook Chapter 3. “If the reactor is on-line and the operator has typed in a query command, then the query log will be updated” What causes the query log to be updated? Reactor is on-line AND Operator has typed a query command.
E N D
Need for “simplification” From Textbook Chapter 3 • “If the reactor is on-line and the operator has typed in a query command, then the query log will be updated” • What causes the query log to be updated? • Reactor is on-line AND • Operator has typed a query command. • What if reactor were off-line and the operator types in a query command --- will there still be query log? Working with English text is a cumbersome task and quite error prone. Let’s simplify this- - - using symbols (variables) to stand for English statements.
Proposition • What is a proposition? • An offering for consideration • A statement • An expression in some language or in some set of signs. • Def: A proposition is a statement (in English or some other language) that has a value of either true or false but not both. For example - • It is raining in Atlanta right now (temporal?) • 15 > 56 (always?) • This system has a login function
Propositional Calculus • A branch of logic that studies the propositions, which may be represented by symbols, and the connectors (or operators) of these propositions. • Logic provides us the basis for reasoning (what is reasoning ?) • Propositional calculusprovides us the basis of reasoning through the analysis of • the propositions and • the connectors of the propositions.
Why Do We in Software Engineering Care ? • Some obvious applications to computer science and software engineering: • specifying and analyzing requirement statements • specifying and analyzing design statements • specifying and analyzing test scenarios and test results • specifying a computational statement
Assigning a Name for the Proposition • In order to simplify the operations and communications of propositions, it is easier to utilize a symbol for a proposition. • S1: It is raining in Atlanta • S2: It is raining in San Francisco • S3: It is raining in Atlanta, and it is raining in San Francisco. S3 may be written as : S1 and S2
Truth Value in Propositional Calculus • A proposition or statement, S, is either true or false, but not bothor neither. • It is raining in Atlanta today ---- True • 54 < 103 ---- True • S comes after T in English alphabet ---- False • If a statement, S, is true, then it’s negation is false. • S is true, then NOT S can not also be true
Propositional Connectors or Operators • There are 5 “basic” connectors that allows us to manipulate propositions and form compound proposition from combining the individual propositions with the connectors • Not : ~ (or ¬ ) • AND (conjunction): /\ • OR (disjunction): \/ • Implies: => • Equals: <=> • -- and -- • Exclusive OR: \/e Note: The order of evaluation is also from ~ to . e.g. ~ A v B is (~A) v B The author often assumes this instead of using parenthesis
Truth Table and Logical NOT • A tool, in the form of table, that allows us to depict the truth value of propositions. • For statement S and the NOT operator, ~ S, we have the following truth table: S ~ S Statements: T F Truth Values: F T
Logical AND • For two different statements, S1 and S2, the AND connector logically connects the two statements in such a manner that the following truth table depicts the truth value of the combined statements, S1/\S2. S2 S1 /\ S2 S2 /\ S1 S1 T T T T F F T F F T F F F F F F Logical AND operator is “commutative”
Logical OR • For two different statements, S1 and S2, the OR connector logically connects the two statements in such a manner that the following truth table depicts the truth value of the combined statements, S1\/S2. S2 S1 \/ S2 S2 \/ S1 S1 T T T T T T T F F T T T F F F F Logical OR operator is “commutative”
Logical Implies • For two different statements, S1 and S2, the Implies connector (or “if --- then--”) logically connects the two statements in such a manner that the following truth table depicts the truth value of the combined statements, S1=>S2. S2 S1 => S2 S1 T T T F T F F T T F F T
More on Logical Implies • There is something strange about logical implies when we face real statements. Consider the following situation: • Assume that number of chairs in the conference room is 200 • the number of conference attendees is greater than 200 implies that some attendee will be standing • let s1: number of attendees is greater than 200 • let s2: some attendee will be standing • If S1 is true would imply that S2 must also be true • Can some attendees be standing, if S1 was false? -Note that when S1 is not TRUE, the composite proposition, S1=>S2 is true ! -The logical truth values of “implies” tells us that the traditional English term of “cause and effect” is not what “implies” means here. -Some logicians prefer to say Not S1 OR S2, instead. S1 S2 S1 => S2 ~S1 \/ S2 T T T T T F F F F T T T F F T T
Logically Equivalent • Two statements or propositions, S1 and S2, are logically equivalent if they have the same truth values in the truth table: • When S1 is true so is S2 and vise versa and • When S1 is false so is S2 and vise versa.
Logical Equals • For two different statements, S1 and S2, the “EQUALS” connector (or “if and only if”) logically connects the two statements in such a manner that the following truth table depicts the truth value of the combined statements, S1<=>S2. S2 S1 <=> S2 S1 T T T F T F F T F F F T
Expressing <=> with Just, ~, \/ and /\ Connectors S1 S2 ~S1 ~S2 S1<=>S2 ~S1\/S2 ~S2\/S1 (~S1\/S2)/\(~S2\/S1) T T F F T T T T F T F T F F T F F F T T F F T F F F T T T T T T Note : just like A=>B has the same truth values as ~A\/B, A<=>B has the same truth values as (A=>B) /\ (B=>A) which is the same as (~A\/B) /\ (~B \/A))
Some Examples of Compound Statements utilizing the Connectors A) “ No work, no pay” or “if no work then no pay” can be expressed as Let : P stand for : work Q stand for : pay then we have : ~ P => ~Q B) or “work if paid” or “if paid then must have worked” Q => P P ~P Q ~Q ~P => ~Q Q => P T F T F T T T T T F F T F T T F F F F T F T T T “No work, no pay” <=> “work if paid”
Well Formed Formula (WFF) • A well formed formula (wff) is a string generated by a formal grammar. • A wff in propositional calculus is a string generated with the following rule (grammar): • A proposition X is a wff • If X is wff then so is ~X • If X, Y are wff then so are: • X Λ Y • X V Y • X => Y • X Y • X \/e Y • If X is a wff then so is (X) Later we will deal with proofs. A proof is just a sequence of wff’s. Manipulations of these wffs is similar to manipulating syntax.
What About “True” and “False”? • Does Propositional Calculus allow expression such as Is-Raining \/ TRUE ? • So, we should include TRUE and FALSE as “constants” into the vocabulary of Propositional calculus • A wff in propositional calculus is a string generated with the following rule (grammar): • A proposition X is a wff • TRUE, FALSE are wff (these have constant value of true and false) • If X is wff then so is ~X • If X, Y are wff then so are: • X Λ Y • X V Y • X => Y • X Y • X \/e Y • If X is a wff then so is (X)
Is “=>” operator “transitive” ?Does (S1 => S2 AND S2=> S3) => (S1 =>S3) ?What about “equal”Does (S1=>S2 AND S2 => S3) EQUAL (S1 =>S3) ? Something for you to think about ------