The Logic of the er nary Sentential Connecti IfThenElse illiam Rapaport Department of Computer Science Engineering and Center or Cogniti Science State Uni ersity of New ork at Buffalo Buffalo NY  rap
300K - views

The Logic of the er nary Sentential Connecti IfThenElse illiam Rapaport Department of Computer Science Engineering and Center or Cogniti Science State Uni ersity of New ork at Buffalo Buffalo NY rap

buffaloedu httpwwwcsebuffaloedu rapapo rt July 1997 Abstract This document as originally intended to be section of Schagrin Morton L Rapaport illiam J Dipert Randall R 1985 Lo gic Computer Appr oac Ne ork McGra wHill This document discusses the terna

Download Pdf

The Logic of the er nary Sentential Connecti IfThenElse illiam Rapaport Department of Computer Science Engineering and Center or Cogniti Science State Uni ersity of New ork at Buffalo Buffalo NY rap




Download Pdf - The PPT/PDF document "The Logic of the er nary Sentential Conn..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.



Presentation on theme: "The Logic of the er nary Sentential Connecti IfThenElse illiam Rapaport Department of Computer Science Engineering and Center or Cogniti Science State Uni ersity of New ork at Buffalo Buffalo NY rap"— Presentation transcript:


Page 1
The Logic of the er nary Sentential Connecti “If-Then-Else illiam Rapaport Department of Computer Science Engineering and Center or Cogniti Science State Uni ersity of New ork at Buffalo, Buffalo, NY 14260 rapaport@cse.buffalo.edu http://www.cse.buffalo.edu/ rapapo rt/ July 1997 Abstract This document as originally intended to be section of Schagrin, Morton L.; Rapaport, illiam J.; Dipert, Randall R. (1985), Lo gic: Computer Appr oac (Ne ork: McGra w-Hill). This document discusses the ternary (i.e., 3-place) if-then-else sentential connective which is based on the if-then-else

instruction of computer programming languages. Before we be gin, ho we er we should look closely at an important dif ference between the use of if-then (and of if-then-else) in programming languages and its use in sentential (i.e., propositional) logic. In most logic te xts (e.g., Shagrin et al. 1985) that are about the logic of declarati sentences—i.e., sentences, xpressing propositions, that can be either true or alse—the antecedent and consequent of conditional sentence are themselv es declarati sentences. But in an “imperati e programming language such as Basic or ascal, an if-then

statement is really conditional instruction or command whose antecedent is delcarati sentence ut whose consequent is an instruction or command, i.e., an imper ative sentence. Thus, whereas in sentential logic we are interested in conditional sentences such as: If Ann goes to the party then Bob will go to the party in man programming languages, we ould be interested in conditional instructions such as: IF THEN print "yes" Instructions, or commands, are neither true nor alse. (It is possible to de vise analogies to truth and alsity for commands, ut we on do that here. If you are interested, see

Rescher 1966, Casta neda 1975.) The if-then-else command is similar to the if-then command. In general, it has the form: IF P, THEN ELSE where the antecedent, is some sentence that is either true or alse (in the xclusi sense of “or”!) and where the “then-consequent and the “else-consequent are instructions. The meaning of the if-then-else command is this: If is true, then do ut if is alse, then do What we shall do here is study the logic of the if-then-else conditional sentence where both consequents (as well as the antecedent) are sentences that are either true or alse, e.g.: If Ann goes to

the party then Bob will, else Cal will. (Actually such sentence ould more lik ely be xpressed in ordinary English using the ord ‘otherwise rather than ‘else’.) Ho ould we decide whether such sentence is true? can compute its truth alues by realizing that
Page 2
if then else is really conjunction of tw conditionals:   So we can construct the follo wing truth table: V( V( V( V( V( V( V(if then else see if this is reasonable interpretation, we can try to find sentence that xpresses the result of performing conditional command. The command: IF THEN seems to correspond to the

sentence if then will be done. Similarly the command: IF THEN ELSE seems to correspond to the sentence: if then will be done, else will be done. The action is indicated by ’, ut will be done is sentence. So we let: will be done will be done where and are sentences. No if you study our truth table carefully you will see that it can be understood as saying the follo wing: if is true, then at least (i.e., and possibly else at least (i.e., and possibly ou may or may not find this plausible interpretation of the corresponding command: IF THEN ELSE which suggests to some people that if is

true, then will definitely not be done (as result of this command), and, further if is alse, then will not be done (as result of this command). Of course, there is nothing wrong with the follo wing program: IF THEN BEGIN X;Y END ELSE BEGIN Y;X END The notation ‘V( ) means: “the truth alue of ”; ‘0 represents the truth alue false ‘1 represents the truth alue true
Page 3
But this appears to be redundant set of instructions: If both and are going to be done an yw ay why bother testing if is true? ell, one reason is that the programming-language “control structure kno wn as

sequencing is not commutati e: The sequence X;Y does not necessarily compute the same function as the sequence Y;X since the first instruction might change the en vironment in such ay that the second instruction ould not be using the same input as it ould in the other case. Thus, in both cases, it seems more reasonable to use the if-then-else command when you ant to perform or ut not both (i.e., in the xclusi sense of “or”). This suggests the follo wing, “stronger interpretation of the sentential connective if-then-else: if then else (in the “strong sense) means: if then ut not and if

not then ut not Note. After this document as written, learned of the follo wing reference that deals with the logic of if-then-else: Manna aldinger 1985: 12–13.
Page 4
Exer cises. 1. Symbolize “if then else in the strong sense using and 2. Construct truth table (using and 1) for the strong sense of if-then-else. (If you do this correctly you will see that V(if then else in only tw situations: when either V( V( and V( 1, or when V( V( and V( 0.) 3. (a) Construct an arithmetical truth-function for the weak sense of if-then-else (i.e., function that arithmetically computes the truth

alue of an if-then-else sentence; see Schagrin et al. 1985 for more discussion of arithmetical truth functions). (b) Construct an arithmetical truth-function for the str ong sense of if-then-else. 4. (a) Construct flo wchart for computing the truth alue of if-then-else in the weak sense. (b) Construct flo wchart for computing the truth alue of if-then-else in the str ong sense. 5. In programming languages, the sequence of instructions: IF THEN X; means: if is true, then do and then do else do ut not What ould “weak interpretation of ‘if-then be? What ould “strong interpretation of

‘if-then be? 6. (a) Using the weak sense of if-then-else, determine the truth alues of the follo wing sentences with the indicated atomic truth-v alues. (b) Using the strong sense of if-then-else, determine the truth alues of the follo wing sentences with the indicated atomic truth-v alues. V(A) TR UE V(C) TR UE V(B) ALSE V(D) ALSE i. (if (A D) then (A D) else D) ii. (if (A D) then (A D) else D) iii. (if (A D) then else D) (if (A D) then else A) (if (A D) then else D) vi. (if then else A) vii. ((if then else B) B) viii. ((if then else B) A) ix. ((if then else C) (if then else B)) Refer ences

1. Casta neda, Hector -Neri (1975), Thinking and Doing: The Philosophical oundations of Institutions (Dordrecht: D. Reidel). 2. Manna, Zohar aldinger Richard (1985), The Lo gical Basis for Computer Pr gr amming ol. I: Deducti Reasoning (Reading, MA: Addison-W esle y). 3. Rescher Nicholas (1966), The Lo gic of Commands (London: Routledge gan aul; Ne ork: Do er). 4. Schagrin, Morton L.; Rapaport, illiam J.; Dipert, Randall R. (1985), Lo gic: Computer Appr oac (Ne ork: McGra w-Hill). E.g., the arithmetical truth function FNEG(V( )) V( ).