Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Elements of Computer Science Workshop5. Logic in Language [CBPrice. 01-03-15] Color Coding for this Worksheet Information Guided Enquiry Details for the Portfolio Extension Material Purpose (a) To learn how logic is used in language. (b) To explore the similarities between digital logic and logic in languages. (c) To use Boolean Algebra Portfolio This session addresses ILO1 There is a lot of work here, too much for one session. Any of the activities from 3 onwards are suitable for inclusion in your portfolio. I suggest after attempting activities 1 and 2, you choose one or more โConsistencyโ tests and one or more โValidationโ tests. But try to have some fun solving some interesting problems. Activities 1 Logic Connectives : The AND, OR connectives and the NOT Let us take the two atomic sentences P = <Holmes was on the case> Q = <Watson was on the case> and consider the compound sentence Either Holmes was on the case, or both Holmes and Watson were on the case. (a) Work from this compound sentence to fill in the final column in the truth table below which gives the truth of the compound sentence for the various values of P and Q Q 0 1 0 1 P 0 0 1 1 mini-terms (b) Now write down the min-terms (using Boolean algebra) for both rows in the table which have a 1 in the final column. (c) The Boolean expression for the compound sentence is the conjunction of your mini-terms (๐. ๐ฬ + ๐. ๐) Complete the truth table below for both mini-terms and for the conjunction. You may omit the Os to make it more readable. Check it agrees with your answer to (a) P 0 0 1 1 Q 0 1 0 1 ๐. ๐ฬ ๐. ๐ (๐. ๐ฬ + ๐. ๐) (d) For the rows where the conjunction of the mini-terms is 1, write down the meaning of the miniterm in simple English using the atomic sentences P and Q. (e) Construct a simulated electronic circuit to represent the problem and its solution. Remember to: (i) create each mini-term using and AND gate (ii) create the conjunction of the mini-terms using a single OR gate (f) Express the solution to the problem as code. Start with each mini-term, then form the conjunction. Test out your code on the Arduino (g) Use Boolean Algebra to simplify your expression in (c). You should find it becomes P. 2. A Simple Logic Problem Consider the sentence P = <Cows can fly>. (a) Write down, in English, the meaning of the sentence ๐ท. ๐ท (b) Now work out the truth table for it, by thinking P ๐ท. ๐ท 0 1 (c) Find a rule from Boolean algebra which will prove the result. 3 The Conditional IF. First Investigation. The Philonian Conditional; โIf P then Qโ can be represented by the truth functor โ(Not P) or Qโ, โIf P then Qโ is represented by P ๏ฎ Q and is equivalent to ๐ท + ๐ธ in logic Letโs consider the two atomic sentences P = <The switch is pressed> Q = < The Light is on> (a) Now consider the compound sentence If the switch is pressed the light is on Write down the Boolean expression for this sentence. (b) Now consider the compound sentence If the light is on the switch is pressed Write down the Boolean expression for this sentence (c) In the truth table below write your Boolean expression from (a) at the top of the third column and fill in the rows where the expression is true. (d) Repeat this for your second expression using the fourth column (e) Now look at each row, and in the fifth column write a 1 where both terms are true together, ie where columns 3 and 4 both contain 1s. (f) Now in the sixth column write the mini-terms corresponding to these rows P 0 0 1 1 Q 0 1 0 1 (g) Finally in the seventh column write down in simple English the state of the switch and light where the compound expression is true. Do your sentences agree with the compound expression. (h) Now letโs apply some Boolean algebra. Take your two terms and AND them together and you should obtain (๐ฬ + ๐). (๐ฬ + ๐) Expand this using the distributive rule and you should obtain two non-0 terms. Check that these agree with your mini-terms in the above table. (i) Build two simulated digital circuits, one for the expression given in (h) and the second for your simplified expression in (h). Check that both give identical results. (j) Write code for both expressions and test that they too have identical behaviour when run on the Arduino. 4. The Conditional IF. Second Investigation Repeat 3. for the compound sentence If the switch is pressed the light is on AND If the light is on the switch is not pressed. 5. Consistency โ Holmes, Watson and Lestrade. Letโs use the following atomic sentences P = <Holmes solved the crime> Q = <Lestrade took the criminal> R = <The criminal escaped> Consider the following text "If Holmes. solved the crime, then Lestrade took the criminal. Of course, if the criminal escaped, then Lestrade did not take him. On this particular day, Holmes solved the crime, but the criminal escaped" (a) Convert each of the sentences in the above text into Boolean terms involving combinations of P,Q,R (b) Add your terms at the top of each column in the truth table below P 0 0 0 0 1 1 1 1 Q 0 0 1 1 0 0 1 1 R 0 1 0 1 0 1 0 1 (c) You should find that there is only one row where all terms are true together. This identifies the consistent set of atomic sentences. Write the corresponding mini-term down and the associated sentence in the row. Does the sentence make sense? Now you should attempt either (d) or (e) (d) Construct a Boolean expression by AND-ing your three terms. Simplify this using Boolean algebra. You should end up with a single term (e) Construct a simulated digital circuit using your three terms and verify that this produces the consistent set of sentences you have found in the truth table. 6. Consistency โ Watson and Holmes in Confusion. Test the consistency of this set of sentences using the method above. a) Holmes and Watson were on the case. b) If Holmes was on the case, then Watson was not. (a) First find the atomic sentences P and Q; P = Q = (b) Now transcribe the set of sentences a) and b) in terms of P and Q using Boolean Algebra a) b) (c) Now AND these sentences using Boolean algebra (d) Now complete the truth table as above and look for any consistent solutions. Did you expect this result? Look at the starting sentences and think out the answer. P 0 0 1 1 7. Q 0 1 0 1 Consistency โ Smileyโs People Test the consistency of this set of sentences; "Smiley is an English spy. Smiley is not both a Russian and an English spy. If Smiley is a Cad, then he is a Russian spy". (a) Find atomic sentences for this text P = Q = R = (b) Convert each of the sentences in the above text into Boolean terms involving combinations of P,Q,R (c) Add your terms at the top of each column in the truth table below P 0 0 0 0 1 1 1 1 Q 0 0 1 1 0 0 1 1 R 0 1 0 1 0 1 0 1 (d) You should find that there is only one row where all terms are true together. This identifies the consistent set of atomic sentences. Write the corresponding mini-term down and the associated sentence in the row. Does the sentence make sense? Now you should attempt either (d) or (e) (e) Construct a Boolean expression by AND-ing your three terms. Simplify this using Boolean algebra. You should end up with a single term (f) Construct a simulated digital circuit using your three terms and verify that this produces the consistent set of sentences you have found in the truth table. 8. Consistency โ Too Many Detectives (VERY OPTIONAL) Test the consistency of these sentences; "If Holmes. solved the crime, then Lestrade took the criminal. Of course, if the criminal escaped, then Lestrade did not take him. On this particular day, Holmes solved the crime, but the criminal escaped" P Q R = = = (a) Now transcribe each of the three sentences in to a boolean expression. (b) Now write down the boolean expression for all three sentences together (c) Build a circuit using the boolean expression and find the truth table. (d) Identify any consistent solution. The Method of testing Validity of Arguments An argument will have several premises and one conclusion. Testing the validity of an argument is done by constructing a Boolean expression for each premise. To this is added the Boolean expression for the inverse of the conclusion, ie the conclusion is taken to be false. All expressions are then tested for consistency. If a consistent solution (a true solution) is found then this is an example of where the conclusion is false. Hence the argument is proved to be invalid. If there are no consistent solutions then the conclusion cannot be false for the premises, in other words the argument is true. This approach is called reductio ad absurdum. 9. Argument Validity โ God, Matter and Homer Simpson. Take the following atomic sentences P = < Matter always existed> Q = < God Exists > R = < Homer Simpson created the Universe > and consider the text Matter always existed If God exists then Homer Simpson created the Universe If Homer Simpson created the Universe then Matter did not always exist Therefore there is no God (a) Transcribe the three premises of the argument into individual Boolean expressions (b) Now transcribe the conclusion and negate this (Reductio ad Absurdum) (c) Add your four expressions to the headings of columns in the truth table below P 0 0 0 0 1 1 1 1 Q 0 0 1 1 0 0 1 1 R 0 1 0 1 0 1 0 1 (d) For each expression insert a 1 into any row where the expression is true. (e) Look for any row where all expressions are true. If you find one then this is a counter example and the argument is invalidated. (f) Optional. Write down an expression consisting of the products of your terms (ANDed). Now simplify this and show that it evaluates to 0. Start with the distributive rule. (g) Optional. Either construct a digital circuit which combines (ANDs) all of your individual expressions and check that this agrees with your truth table or write the combination of your expressions as code and check this agrees with your truth table using Arduino. 10. Argument Validity โ From Monty Python Take the three atomic sentences P = < sheโs made of wood> Q = < she weighs the same as a duck > R = < sheโs a witch > and the following argument whose validity you must investigate If sheโs made of wood sheโs a witch If she weighs the same as a duck sheโs made of wood She weighs the same as a duck Therefore sheโs a witch (a) Transcribe the premises of the argument into Boolean expressions (b) Now transcribe the conclusion and negate this (Reductio ad Absurdum) (c) Add your four expressions to the headings of columns in the truth table below P 0 0 0 0 1 1 1 1 Q 0 0 1 1 0 0 1 1 R 0 1 0 1 0 1 0 1 (d) For each expression insert a 1 into any row where the expression is true. (e) Look for any row where all expressions are true. If you find one then this is a counter example and the argument is invalidated. (f) Optional. Write down an expression consisting of the products of your terms (ANDed). Now simplify this and show that it evaluates to 0. Start with the distributive rule. (g) Optional. Either construct a digital circuit which combines (ANDs) all of your individual expressions and check that this agrees with your truth table or write the combination of your expressions as code and check this agrees with your truth table using Arduino. 11. Argument Validity โ Fallacy of Denying the Antecedent Take the atomic sentences P = <There is a fault> Q = <It will blow up> and working as above prove that the following argument is invalid If there is a fault, it will blow up. There is no fault therefore it will not blow up. 12. Argument Validity โ Fallacy of Affirming the Consequent Take the atomic sentences P = <There is a fault> Q = <It will blow up> and working as above prove that the following argument is invalid If there is a fault, it will blow up. It will blow up, therefore there is a fault 13. Argument Validity โ Fallacy of Conversion Take the atomic sentences P = <There is a fault> Q = <It will blow up> and working as above prove that the following argument is invalid If there is a fault then it will blow up, therefore if it blows up, then there is a fault! 14. Argument Validity โ Modus Tollens Take the atomic sentences P = <There is a fault> Q = <It will blow up> and working as above test the validity of the following argument If there is a fault it will blow up. It will not blow up, therefore there is no fault 15. Consequentia Mirabilis (a) Here a proof which is true and a little challenging to understand. Prove the validity of the following argument using either the truth-table approach or Boolean algebra. Try to understand why the proof is so strange. If there is proof, then there is proof If there is no proof, then there is proof Therefore there is proof (b) Now letโs drop the first line. Again prove the validity of the argument and try to understand If there is no proof, then there is proof Therefore there is proof 16. Aristotelian Syllogism Prove that the following argument is correct. It is presented in a general form then an example. If P then Q and If Q then R Therefore P then R All men are mortals Socrates is a man Therefore Socrates is mortal