110 likes | 1.24k Views
Cardinality of a Set. Cardinality : the number of members in a set S is called the cardinality of S. The cardinality is often specified with the symbol, # Example 1 : A = { cpu, memory, printer} then #A = 3 Example 2 : S = { 34, 78, 0, 102, -3 } then #S = 5
E N D
Cardinality of a Set • Cardinality: the number of members in a set S is called the cardinality of S. • The cardinality is often specified with the symbol, # • Example 1 : A = { cpu, memory, printer} • then #A = 3 • Example 2 : S = { 34, 78, 0, 102, -3 } • then #S = 5 • Example 3 : • # { n: positive integers I n<9 } = 8 This concept is similar to the counting operator , Ω, introduced earlier
Reasoning and Proof in Set Theory • Using Rules of inference, we can also reason and derive theorems in set theory. • Some of the rules are: given A,B, and C are sets • x ε A, x ε B x ε ( A B) • x ε A, A B -> x ε B • A = B , B = C A = C • x ε A -> x ε ( A U B U ------U Z ) • A B, B C -> A C Do you believe in all these? Try proving them. Hint: one of them may be misleading (Look Carefully)
Example of Proving a Set Theory Rule • Show (A B) = (B A) • x ε (A B) = x ε A , x ε B • “ = x ε A /\ x ε B • “ = x ε B /\ x ε A • “ = x ε ( B A) • Thus (A B) = ( B A)
List of Set Theory Rules (Theorems) • A U A = A • A U O = A • A U B = B U A • (A U B) U C = A U (B U C) • A O = O • A B = B A • A A = A • (A B) C = A (B C) • A U (B C) = (A U B) (A U C) • A (B U C ) = ( A B) U ( A C)
Modeling (with Prop./Pred. Calculus & Set Theory) • Example of Sets & Statements: Let • S = set of all programs in a System X • A = set of all running programs in X • B = set of all non-running programs in X • We can say : • A U B = S : “ all programs in X are running or not running” • A B = O : “ a program is either running or not running but not both ”
More on Modeling • Consider : modeling “users are logged into a system if they key in valid username and password.” • Let : UserNames = set of user names • Pa_Code = set of pass words • Table = { UserName X Pa_Code} • S_Table = security table of this system • S_Table ε IP Table (S_Table is the security table and thus is an element of power set of Table.) • logged_in = set of logged in users • thus • logged_in UserNames • Also let ‘ to mean post-condition : so that S_Table’ would mean the post condition of S_Table.
More on Modeling (cont.) “users are logged into a system if they key in valid username and password.” • Express the Log-in function: • let: userAε UserNames , passε Pa_Code • Log-in (userA, pass) => (S_Table’ = S_Table) /\ (UserNames’ = UserNames) /\ (Pa_Code’ = Pa_Code) /\ { (userA,pass) ε S_Table -> ( logged_in’ = ( logged_in U userA ) ) } /\ { (userA, pass) ε S_Table -> ( logged_in’ = logged_in ) }
More on Modeling (cont.) • Express the Log-in function: • user ε UserNames , pass ε P_Code • log-in (user, pass) => (S_Table’ = S_Table) /\ (UserNames’ = UserNames) /\ (P_Code’ = P_Code) /\ { (user,pass) ε S_Table -> ( logged_in’ = ( logged_in U user ) ) } /\ { (user, pass) ε S_Table -> ( logged_in’ = logged_in ) } Some of you wanted to re-write this --- see next slide.
Alternative • Let A = (user, pass) S_Table • Let B = add user A B A -> B ~A -> ~B /\ A /\ B ~A /\ ~B \/ T T T T T F T T F T F F T F F F T T F F F F F F F T F T T F T T So you can rewrite the “circled” area of previous slide with a OR of two AND conditions.