Session 01 – Basic Concepts of Logic Session 1 Introduction to Logic Contents Introduction, p 1 1.1. Propositions, p 1 1.2 Truth Tables, p 3 1.3. Logical connectives and compound propositions, p 5 Summary, p 12 Learning outcomes, p 13 Introduction The basic concepts of mathematical logic will be discussed in this session, together with the logical notations and assigning meanings to them. Logic is crucial to many different branches of computer science, including architecture (logic gates), software engineering (specification and verification), programming languages (logic programming), databases (relational algebra and SQL), artificial intelligence (automatic theorem proving), algorithms (complexity and expressiveness), and theory of computation (general notions of computability). 1.1 Propositions Definition 1.1 A proposition is a declarative statement which is either true or false, but not both simultaneously. 1 Session 01 – Basic Concepts of Logic Example 1.1 The following are some examples of propositions. 1. Snow is white. 2. A triangles has three sides. 3. 2 + 5 > 9 . 4. This boy is wearing a red shirt. 5. It rained last night. We can see that in example 1.1, propositions 1 and 2 are true, whereas proposition 3 is false. The truth or falsity of proposition 4 depends on the context in which it was stated. The truth or falsity of proposition 5 depends on when and where it was stated. The truth or falsity of a proposition is called its truth value and is denoted by π (true) and F (false) respectively. We use lowercase letters such as π, π, π, … . to denote propositions. Example 1.2 π: Snow is white. π: This boy is wearing a red shirt. Note that commands, requests, questions, and exclamations etc. are not propositions since we cannot declare them as true of false. Example 1.3 The followings are not propositions. 1. Do not bring mobile phones in to the examination hall. 2 Session 01 – Basic Concepts of Logic 2. Please bring me a cup of tea. 3. Did you forget to bring your umbrella? 4. Long live the king! The propositions 1-5 in Example 1.1 are called simple propositions as they make only a single statement. But a proposition can be made by combining two or more statements which are simple propositions. For example, let the proposition p be ‘if you study hard then you will pass the examination’. If you carefully study the proposition π you will see it hides some of the sentences and their relation inside the proposition π. We can identify that ‘you study hard’ and ‘you pass the examination’ are the hidden sentences in π which are two simple propositions. Our language would tell us more if we could capture the relation between the parts of a given proposition, instead of hiding them. In the next two topics we will discuss how to connect/compound two simple propositions and how to identify their truth value in detail. 1.2 Truth tables We note that from the definition of propositional logic a proposition can have only two possible values: either true or false. Here we will be presenting the truth value of a proposition using a table that will later be helpful for our further studies in logic. It is called a Truth table. As we will see later, truth tables have three uses: • to provide the truth value for a sentence • to determine under what conditions a complex sentence is true or false • to determine if an argument is valid. In this session we are describing only the first two uses only. We will find the truth value of a statement by identifying all the simple propositions that compose the statement and then on the left side of the table we stipulate all the possible truth values of these simple propositions and 3 Session 01 – Basic Concepts of Logic write these out. On the right side of the table, we then identify under what conditions the sentence (that is composed by simple propositions) is true or false. Now let us consider the simplest situation which is, the proposition π is a simple proposition. So here the left side of the truth table gets only a single simple proposition which take two possible truth values True (π) or False( πΉ ) giving only two rows to the table. π π πΉ To complete the truth table, we place the dependent sentence on the top right side and describe its truth value in relation to the truth value of its parts i.e., we want to identify the truth value of π , which has only one part, π. The truth table thus has the final form: π π π π πΉ πΉ Now let π be a statement that is made of two simple propositions π and π . Then we can write the truth table as below. π π π T π π πΉ π πΉ πΉ π 4 Session 01 – Basic Concepts of Logic First two column of the table gives us all the possible combinations of truth values that can have by both simple propositions π and π which is 4 totally. Here we cannot complete the right side of the table since we do not know how the proposition π depends on simple propositions π and π . Under the next topic we will see how two propositions combined and how their truth values represent using a truth table. 1.3 Logical connectives and compound propositions Simple propositions can be combined with logical connectives to form compound propositions representing various forms of complicated ideas. Here, we will be using four commonly used logical connectives; ‘NOT’, ‘AND’, ‘OR’, ‘IF β― THEN β―’. NOT (Notation: ο) Logical connective ‘Not’ has the meaning of the word “not” in English. Now let π be a proposition. Then the compounded proposition ¬ π is read as “the negation of π” or “not π”. Input π π΅πΆπ» ο Output ¬π And it reverses the truth value of the proposition i.e., ¬ π is true when π is false, and ¬ π is false when p is true. Example 1.4 1. Let p denote the proposition “the child is injured”. Then the ¬ π can be written as “the child is not injured.” 5 Session 01 – Basic Concepts of Logic 2. Let q denote the proposition “all children are innocent”. Then ¬ π states that “not all children are innocent” or “some children are not innocent”. This relationship between π and ¬ π is summarized in the following table by giving the truth value of ¬ π for all possible truth values of π. Truth table of ¬ π p οp π πΉ πΉ π AND (Notation: ο) Logical connective ο has the meaning of the word “and” in English. Now let propositions π and π as our inputs. Then the compounded proposition π ∧ π read as “ π and π”. Input 1 π π¨π΅π« Output ∧ π∧π Input 2 π The compounded proposition π ∧ π are true. Otherwise, π ∧ π is false. will be true only when both p and q Example 1.5 1. Let p be the proposition “student attends lectures” and π be “student studies hard”. Then π ∧ π means that the student attends lectures and studies hard. 2. Let π be the proposition “it is raining” and π be “it is lightning”. Then π ∧ π means that it is raining and lightning. 6 Session 01 – Basic Concepts of Logic The corresponding truth table can be given as below. Truth table of p ∧ π P Q pοq π π π π πΉ πΉ πΉ π πΉ πΉ πΉ πΉ Example 1.6 Let π be the statement “I give you Rs 500 and I buy you a ticket to the concert tonight”. Then we can decompose this proposition as π : I give you Rs 500 π : I buy you a ticket to the concert tonight. Then we can present π as π ∧ π. Now you can see the followings: • • • • If I give you the money and also, I buy you the ticket, then I have done as the statement r claims. So, that “I give you Rs 500 and I buy you a ticket to the concert tonight” become true (represent the first row in the truth table). If I give you the money but I don’t buy you the ticket, then I have violated my claim and so, it becomes false (represent the second row in the truth table). If I do not give you Rs 500, but I buy you a ticket for the concert still make the statement r false (represent the third row in the truth table). If I don’t give you money, and I don’t buy you a ticket then still I have lied, and my claim become false (represent the fourth row in the truth table). 7 Session 01 – Basic Concepts of Logic OR (Notation: ∨) Logical connective ∨ has the meaning of the word “inclusive or” in English. Now let propositions π and π as our inputs. Then the compound proposition π ∨ π is read as “ π or π”. Input 1 π OR ∨ Input 2 π Output π∨π Then the compound proposition π ∨ π will be true if at least one of π π is true. Otherwise, π ∨ π is false. and Example 1.7 Let π be the proposition “it is raining” and π be “sprinkler is on”. Then π ∧ π means that it is raining, or sprinkler is on (or both). The corresponding truth table can be given as below. Truth table of p ∧ π π π π ∨π π π π π πΉ π πΉ π π πΉ πΉ πΉ Example 1.8 Let π be the statement “I give you Rs 500 or I buy you a ticket to the concert tonight”. 8 Session 01 – Basic Concepts of Logic Then we can decompose this proposition as π: I give you Rs 500, π : I buy you a ticket to the concert tonight. Then we can present π by π ∨ π. Now you can claim the followings: • • • • If I give you the money and, I buy you the ticket, my claim that “I give you Rs 500 or I buy you a ticket to the concert tonight” is true (represent the first row in the truth table). If I give you the money but I don’t buy you the ticket, and my claim is still true (represent the second row in the truth table). If I do not give you Rs 500, but I buy you a ticket for the concert do still make the statement r true (represent the third row in the truth table). But if I don’t give you money, and I don’t buy you a ticket then I have lied, and my claim become false (represent the fourth row in the truth table). IF β― THEN β― (Notation: →) Logical connective → has the meaning of the word “if β―then β―” in English. Let π. and π. be propositions. Then the compound proposition π → π is read as “π implies π” or “if π then π”. Input 1 π Input 2 π IF β―THEN β― → Output π→π The compound proposition π → π will be false only when p is true and π is false. Otherwise π → π is true i.e., π → π is true irrespective of the truth value of π when π is false. Example 1.9 1. Let p be the proposition “sun is shining” and π be “sky is blue”. Then π → π means that if the sun is shining then the sky is blue. 9 Session 01 – Basic Concepts of Logic 2. Let π: it is raining, π: grass is wet. Then π → π means that the grass is wet whenever it is raining. 3. Let π: 2 + 3 = 6, snow is red. Then π → π is true because π is false. The corresponding truth table can be given as below. Truth table of p → π π π π→ π π π π π πΉ πΉ πΉ π π πΉ πΉ π Example 1.10 Let π be the statement “if you give me Rs 500, then I will buy you a ticket to the concert tonight”. Then we can decompose this proposition as π: you give me Rs 500, π: I will buy you a ticket to the concert tonight. Then we can present π by π → π. Now you can claim the followings: • • • • If you give me the money and I will buy you the ticket, my claim that “If you give me Rs 500, then I will buy you a ticket to the concert tonight” is true (represent the first row in the truth table). if you give me the money and I don’t buy you the ticket, I lied, and my claim is false (represent the second row in the truth table). if you do not give me Rs 500, but I buy you a ticket for the concert as a gift (represent the third row in the truth table). if you don’t give me money, and I do not buy you a ticket also perfectly consistent with my claim (represent the fourth row in the truth table). Note: You might note here that the order of the proposition is matter in this connectivity → while not in the previous connectivity’s ο ,ο. 10 Session 01 – Basic Concepts of Logic That is, the compounded proposition π ∧ π is same as π ∧ π q and π ∨ π is same as π ∨ π but π → π is not same as π → π. Example 1.11 1. Represent the scenario: “If the girl cries but is not sick then she does not need a doctor.” as a compound proposition in propositional logic. Answer: First, we need to identify and symbolize the propositions present in the given scenario. Let us define the propositions π, π and π as: π: the girl cries. π: girl is sick. π: girl needs a doctor. Then the above scenario can be symbolized as (π ∧ (¬π)) → (¬π) 2. With respect to the propositions defined in Example 1.11 (1), express the compound proposition (¬ (π ∨ π)) → (¬π) in natural English. Answer: The girl does not need a doctor if she is neither sick nor cries. Note: The binding order of logical connectives from highest to lowest precedence is as follows: ¬ ,∨ ,∧, → We can omit unnecessary parentheses by using the binding order of connectives. For example, the compound proposition in Example 1.11 (1) can be written as π ∧ ¬π → ¬π. 11 Session 01 – Basic Concepts of Logic But you may still use additional parentheses as you wish in order to increase the clarity of your expressions. Activity 1.1 Let π, π be the propositions. Find the truth values of π → (π ∨ π) and (π ∨ π) → π using a same truth table. Activity 1.2 Let p be the proposition “she is sick” π be “she is injured”, π be “she needs a doctor.” and s be “she needs a lawyer”. 1. Symbolize the following compound propositions: i. She needs a lawyer or a doctor if she is sick or injured. ii. She does not need a doctor or a lawyer if she is neither sick nor injured. iii. If she needs a lawyer then she is both sick and injured. iv. She needs a doctor only if she is sick. 2. Express the following compound propositions in natural English: i. π ∧ π ¬π ∨ ( π ∨ π ) ii. iii. π → (π → π) Answers to the Activity 1.1 Truth table for π → (π ∨ π) and (π ∨ π) → π π π π∨ π π → (π ∨ π) (π ∨ π) → π π π π π π π πΉ π π π πΉ π π π πΉ πΉ πΉ πΉ π π 12 Session 01 – Basic Concepts of Logic Answers to the Activity 1.2 1. i. (π ∨ π) → (π ∨ π) ii. ο(π ∨ π) → ο(π ∨ π) iii. π → (π ∧ π) iv. π → π 2. i. She is both sick and injured. ii. She does not need a doctor unless she is sick or injured. iii. If she is sick, if she is injured, then she needs a doctor. Summary Propositional logic, the simplest symbolic logic system, is based on propositions which are declarative statements that are either true or false, but not both. Compound propositions representing complex ideas can be formed by combining propositions with logical connectives. Truth table is a convenient way to check the truth or falsity of a compound proposition. Learning outcomes After studying this session, you should be able to Express natural language sentences in symbolic language by means of symbolization. Explain the propositional logic system and its fundamentals. Explain and exemplify the true value status of a proposition by constructing a truth table. References: Craig DeLancey ; A Concise Introduction to Logic, Open SUNY Textbooks, 2017. 13