Download presentation
Presentation is loading. Please wait.
Published byBeatrice Francis Modified over 8 years ago
1
August 2003 CIS102/LECTURE 9/FKS 1 Mathematics for Computing Lecture 9 LOGIC Chapter 3
2
August 2003 CIS102/LECTURE 9/FKS 2 3.4 Logic Gates NOT p ¬p¬p p AND q p qp q OR p qp q p q Figure 3.8 The value of the output (0 or 1 ) for each value, or combination of values, for input (s) can be derived from the logic tables for ¬p, p q and p q ( see Figure 3.1 and Figure 3.2) Designing logic networks The logic gates can also be concatenated to represent more complicated compound statements. The circuits so formed are called logic networks.
3
August 2003 CIS102/LECTURE 9/FKS 3 Example 3.12 Design a logic network that has two inputs p and q and output p q NOT OR p q ¬ p q Figure 3.9 Example 3.13 Devise a logic network with four inputs p, q, r, s and output (p q )→ (r s).
4
August 2003 CIS102/LECTURE 9/FKS 4 Figure 3.10 NOT OR p q AND OR r s x y z Suppose we denote the output of p q by x and the output of r s by y. Then the required output is x y. The AND-gate gives output x for inputs p, q; the OR-gate gives the output y for inputs r, s; the network shown in Figure 3.9 gives output x y, for inputs x and y. Concatenating these components gives the network shown in Figure 3.10, where the final output is z = (p q) → (r s)
5
August 2003 CIS102/LECTURE 9/FKS 5 Working from left to right across the diagram, and determining the output of each gate in turn, we get: 1.Output r = ¬ q 2. Output s = p ¬ q 3. Output t = p q 4. Output w = ( p ¬ q) ( p q ) Hence the output of this network is ( p ¬ q ) ( p q ) Example 3.14 Determine the output of the logic network in Figure 3.11 Figure 3.11 NOT p q AND OR r s t w AND
6
August 2003 CIS102/LECTURE 9/FKS 6 By distributive law, we have : w = ( p ¬ q ) ( p q ) = p ( ¬ q q ) Now, (¬ q q ) = ( q ¬ q ) = T, by commutative law and the complement law. Thus, w = p T = p From the table, we see that the column for the output w = ( p ¬ q ) ( p q ) is identical to the column for p. Hence, this network can be replaced by the input p alone and no input q or gates are necessary. Example 3.15 Use truth tables to simplify the final output w = ( p ¬ q ) ( p q ) in Figure 3.11. p q ¬ qp ¬ qp qp q(p ¬ q) (p q) 0 0 1 1 0 1 10101010 00100010 00010001 00110011 Example 3.16 Use the laws of logic to simplify the final output w = ( p ¬ q ) ( p q ).
7
August 2003 CIS102/LECTURE 9/FKS 7 Mathematics for Computing Chapter 4. Functions 4.1 Definition of a function A function may be imagined as a machine that accepts various inputs and transforms each input into a uniquely determined image. A function f is a set of ordered pairs (x,y) of real numbers such that to each allowable value of x, there corresponds one and only one value of y Example 4.1 A “machine” that accepts as inputs the family names of all SIM students on the database and outputs the initial letter of each family name is an example of a function. For each family name (input), there is just one uniquely determined initial letter (output). A convenient set containing all possible outputs is the set of all letters of alphabet and the set of actual outputs is some subset of this. In a function, it may happen that several different inputs all give the same output.
8
August 2003 CIS102/LECTURE 9/FKS 8 Example 4.2 The integer scores awarded in a test are converted to grades as shown in the table. Explain briefly that it defines a function Score 0 - 4950 -5960 - 6970 -7980 -100 Grade FDCBA The above table defines a function since given any input score, the table determines just one possible grade as output. ● The set of inputs for this function is the set of integers {0,1,2,3,…,100} and the set of outputs is { A,B,C,D,F}. ● The definition of a function has three parts: 1. a set of inputs; 2.a rule that determines the unique output corresponding to each input ; 3. a set containing all outputs. ● We usually denote the rule of a function by a single letter, such as f or g. But some common functions are denoted by a string such as log, exp, ABS.
9
August 2003 CIS102/LECTURE 9/FKS 9 Definition 4.1 Suppose we given two sets X and Y and a rule f such that given any element x ? X, f assigns to x a unique y ? Y. Then we call f a function of X into Y, written f : X → Y. We denote the unique element y assigned to x by y = f (x). The set X ( the set of inputs) is called the domain of the function and the set Y (containing the outputs ) is called the co-domain of the function. The set of actual outputs is a subset of Y called the range of the function. Thus range of f = {f (x) : x X} Definition 4.2 Let f : X → Y be a function of X into Y. We call f (x) the image of x under f and we called x a pre-image ( or ancestor) of f (x). We say that f maps x onto f (x). Example 4.3 Suppose S is a set of all 3-bit binary strings. Let SUM: S → Z be the rule defined by SUM (s) = the number of ones in s. Then SUM accepts any 3-bit binary string as input and outputs the number of ones in the string. The rule SUM is a function with domain S and co-domain Z. Determine (a) the image of the string 010 and 111; (b) the pre-image of the outputs 0, 2, and 5; (c) the range of SUM
10
August 2003 CIS102/LECTURE 9/FKS 10 (a) The image of 010 is the number of ones in the string 010, which is 1. Similarly, the image of 111 is the number of ones in the string 111, which is 3. (b) The only 3-bit string s containing no ones is 000. Hence the pre-image of 0 is 000. There are three 3-bit strings containing 2 ones, and so 2 has the set of pre-images {110,101,011}.There is no 3-bit string containing 5 ones, and hence the set of pre- image of 5 is Ø. (c) The outputs of this function with the given set of inputs are 0, 1, 2, 3. Hence the range of SUM is the set {0,1,2,3}.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.