COMPSCI 230 — Homework 7 Due on March 24, 2015 You may talk about this assignment with others, but do not write down anything while you talk. After that, do the assignment alone. What you hand in must be your work only. See Mechanics!Homework on the class web page for details on the homework policy. WHAT TO DO. Follow these instructions accurately. There will be penalties for improperly formatted answers. This assignment comes with auxiliary files template.tex and mystery.rkt. Rename the file template.tex as usual before starting to work with it. For each of the problems below, write a clear description of your solution under the proper heading in your .tex file. The file mystery.rkt is for reading only, so you will not need to modify it or hand it in. An extra-credit question in this assignment asks you to write a Racket program. If you choose to do that, place your solution into an appropriately-named .rkt file. Starting with this assignment, you will learn to write well-formed proofs. A sloppy proof is useless (and gets little credit, by the way), so pay close attention to the formatting instructions. Good style matters also in proofs, not only in programming. 1. A formula of propositional logic is said to be a tautology if it is true regardless of the truth values of its elementary propositions. For instance, the truth of P ! Q depends on the truth values of P and Q, but the formula P ^ Q ! P is true regardless of the truth values of P and Q. A mechanical way to show that a formula of propositional logic is a tautology is to first build its truth table, which for the last formula above is as follows: PQ ((P ^ Q) ! P ) TT T T TF F T FT F T FF F T 1 2 (more about truth-table format below). The formula is a tautology iff1 the column corresponding to the full formula (that is, column 2, which is under the highest-level operator in the formula) contains only the ’T’ symbol, as is the case in the example. A conditional formula that is also a tautology is rewritten with the symbol ‘)’ instead of the symbol ‘!’. So the formula above can be rewritten as P ^ Q ) P to emphasize that it is a tautology, and reads “P ^ Q implies P .” So an implication is a conditional that is always true because of its structure. Similarly, a biconditional ($) that is always true because of its structure is called an equivalence and is denoted by the symbol ‘,’. Determine which of the following conditionals or biconditionals are tautologies by building full truth tables in the format specified below. Show your truth tables and state your conclusion for each formula explicitly. (a) (((P !Q)!Q)!((Q!P )!P )) (b) (((P ^Q)!R)!((P !R)_(Q!R))) TRUTH-TABLE FORMAT. The format described here is slightly different from that used in FDM, and and example follows. In a full truth table, every simple proposition (P , Q, ...) and every operator (∼, ^, _, !, $) in the formula gets its own column, as done in the example above. Simple propositions go into the leftmost columns of the table, listed in alphabetical order, just as shown in FDM. Rows are in the standard order: If T represents zero and F represents 1, then the truth-value entries for the simple propositions read like binary numbers in increasing order if you read the table top-down. Parenthesize formulas fully, with exactly one pair of parentheses for each operator. This includes the top-level operator, so the entire formula is enclosed in parentheses, as done above. Parentheses do not get their own columns in the table. Open parentheses are inserted just before the first simple proposition they precede. Closed parentheses are inserted just after the last simple proposition they follow. Truth values for simple propositions are only given once in the first column in which they appear. Do not repeat truth values for subsequent columns associated with simple propositions. 1The abbreviation iff stands for “if and only if.” COMPSCI 230 — Duke — March 16, 2015 An additional row at the bottom of the table contains one integer in each operator column. This integer is analogous to the one used in FDM, and shows the order in which you computed each column of the truth table. This ordering is not unique, and different people may legitimately come up with different orderings. Of course, not all orderings are valid. The smallest order integer is 1. There is no need to include a vertical arrow (as is done in FDM). Instead, separate this last row from the others with a horizontal line. There is one horizontal line separating the column headers from the other rows, one horizontal line separating the truth table from the bottom row of order numbers, and no other horizontal line. There is one vertical line separating the simple propositions from the other formulas, and no other vertical line. As an example, the truth table for the formula (((P ^(∼ Q))_((∼ P )^R))!(Q_R)) is as follows PQR (((P ^ (∼ Q)) _ ((∼ P ) ^ R)) ! (Q _ R)) TTT FF FF F T T TTF FF FF F T T TFT TT TF F T T TFF TT TF F F F FTT FF TT T T T FTF FF FT F T T FFT FT TT T T T FFF FT FT F T F 2 1 5 3 4 7 6 Note that the full formula is not a tautology because column 7 contains an ‘F’. The LATEX code used to generate this table (and center it on the page) is as follows: \begin{center} \begin{tabular}{*{3}{c}|*{13}{c}} $P$ & $Q$ & $R$ & $(((P$ & $\logand$ & $(\lognot$ & $Q))$ & $\logor$ & $((\lognot$ & $P)$ & $\logand$ & $R))$ & $\logthen$ & $(Q$ & $\logor$ & $R))$ \\\hline \logT & \logT & \logT & & \logF & \logF & & \logF & \logF & & \logF & & \logT & & \logT & \\ \logT & \logT & \logF & & \logF & \logF & & \logF & \logF & & \logF & & \logT & & \logT & \\ \logT & \logF & \logT & & \logT & \logT & & \logT & \logF & & \logF & & \logT & & \logT & \\ \logT & \logF & \logF & & \logT & \logT & & \logT & \logF & & \logF & & \logF & & \logF & \\ \logF & \logT & \logT & & \logF & \logF & & \logT & \logT & & \logT & & \logT & & \logT & \\ \logF & \logT & \logF & & \logF & \logF & & \logF & \logT & & \logF & & \logT & & \logT & \\ \logF & \logF & \logT & & \logF & \logT & & \logT & \logT & & \logT & & \logT & & \logT & \\ \logF & \logF & \logF & & \logF & \logT & & \logF & \logT & & \logF & & \logT & & \logF & \\\hline & & & & $2$ & $1$ & & $5$ & $3$ & & $4$ & & $7$ & & $6$ & \\ \end{tabular} \end{center} The argument *{3}{c}|*{13}{c} to the tabular environment in the example above means that the table has three centered columns (*{3}{c}), followed by a vertical bar, followed by 13 centered columns. This format repetition style with asterisks is not part of standard LATEX but is provided in the array package, which the .tex file already includes. To avoid confusion with LATEX symbols, the .tex file defines commands \logand, \logor, and so forth for the logical operators, and also rewrites the formulas above for you, so you can see how to write similar formulas in LATEX. The file also defines \logT for ‘T’ and \logF for ‘F’. These and other LATEX commands useful for this assignment are summarized in a table in the Appendix to this assignment. WHAT TO DO. It is easy to get lost in the sea of ampersands needed to write a table like this in LATEX. I can think of four ways of getting the table right: • First draw the table by hand cleanly and in every detail on a sheet of paper, then translate that to LATEX. This procedure works if you are patient, have a good hand at drawing, and are detail oriented. • Use cut-and-paste very judiciously and directly in LATEX. For instance, if you understand the standard row ordering, then you can write the first three columns of the table in the example above by only writing its first line, then cutting, pasting, and making simple edits three times (as opposed to writing eight rows) for the table above. After that, you could put placeholders (perhaps a question mark) in the operator columns of the first row, and run LATEX to make sure the placeholders are where they belong. You can then copy that row eight times to get placeholders in the full table (including the bottom row with numbers). The next logical step is to replace the placeholders in the bottom row with the appropriate numbers. Once this is done, you can fill each column that has placeholders in the given order. At the end, insert \hline commands where needed (there are exactly two in every table). This procedure works if you are good at cut-and-paste, you work systematically, and you keep compiling the LATEX source and check all your intermediate steps are correct. • 10 extra-credit points for this solution approach. Write Racket code to generate the tables automatically. This is by far the most satisfactory way in terms of the reward you get from doing it, but is also difficult to get right, and may not be worth the investment COMPSCI 230 — Duke — March 16, 2015 given the small number of problems over which you would amortize your effort. If you follow this path, please submit your code (see instructions at the bottom of the assignment) and make a note before your first truth table, so we know to look for your code. Warning. The extra-credit solution approach is not for the faint of heart. Only do it if you enjoy programming in Racket. You will get full extra credit only for a clean, functional implementation. You can use a different language if you like, but you will get no extra credit in that case.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages8 Page
-
File Size-