Propositional Equivalences Rosen 5th and 6th Editions section 1.2

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

Introduction to Computer Science Robert Sedgewick and Kevin Wayne Recursive Factorial Demo pubic class Factorial {
PROOF BY CONTRADICTION
Craps. /* * file : Craps.java * file : Craps.java * author: george j. grevera, ph.d. * author: george j. grevera, ph.d. * desc. : program to simulate.
Lecture # 21 Chapter 6 Uptill 6.4. Type System A type system is a collection of rules for assigning type expressions to the various parts of the program.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved.1 Chapter 3 Selections.
Section 4.2: Functions that Test Conditions (continued)
1 Introduction to Recursion  Introduction to Recursion  Example 1: Factorial  Example 2: Reversing Strings  Example 3: Fibonacci  Infinite Recursion.
SELECTION CSC 171 FALL 2004 LECTURE 8. Sequences start end.
Josephus Problem: Build the Circular Linked List
16-Aug-15 Java Puzzlers From the book Java Puzzlers by Joshua Bloch and Neal Gafter.
ESP int f(int x) {.... } int g(int y) { …. f(2); …. } int main() { …. g(1); …. } EIP 100: 200: 250: 300: 350:
XOR and XNOR Logic Gates. XOR Function Output Y is TRUE if input A OR input B are TRUE Exclusively, else it is FALSE. Logic Symbol  Description  Truth.
Boolean expressions, part 2: Logical operators. Previously discussed Recall that there are 2 types of operators that return a boolean result (true or.
An Introduction to Java – Part 1 Dylan Boltz. What is Java?  An object-oriented programming language  Developed and released by Sun in 1995  Designed.
The if-else statement. The if-else statement in Java The if-else statement is the second conditional statement in Java The if-else statement selects one.
Repetition Statements while and do while loops
Object-Oriented Programming Simple Stack Implementation.
Overriding toString()
3: Controlling Program Flow Using Java operators Mathematical operators Relational operators Logical operators –Primitive type: ALL (the same with C) –String:
CS 100Lecture 191 CS100J Lecture 19 n Previous Lecture –Two dimensional arrays. –Reasonable size problem (a past assignment). –Stepwise refinement. –Use.
Review TEST 2 Chapters 4,5,7. QUESTION For which type of operands does the == operator always work correctly: (a) int, (b) double, or (c) String?
CONDITIONALS. Boolean values Boolean value is either true or false It is name after the British mathemetician, George Boole who first formulated Boolean.
FOR LOOP WALK THROUGH public class NestedFor { public static void main(String [] args) { for (int i = 1; i
Inverse, Contrapositive & indirect proofs Sections 6.2/6.3.
Chapter One Lesson Three DATA TYPES ©
A: A: double “4” A: “34” 4.
Application development with Java Lecture 6 Rina Zviel-Girshin.
Programming With Java ICS201 University Of Ha’il1 Chapter 11 Recursion.
Boolean expressions, part 1: Compare operators. Compare operators Compare operators compare 2 numerical values and return a Boolean (logical) value A.
Department of Computer Engineering Methods Computer Programming for International Engineers.
Computer Science 320 A First Program in Parallel Java.
1 Advanced Programming Examples Output. Show the exact output produced by the following code segment. char[,] pic = new char[6,6]; for (int i = 0; i
Chapter 5 : Methods Part 2. Returning a Value from a Method  Data can be passed into a method by way of the parameter variables. Data may also be returned.
Catie Welsh February 14,  Program 2 Due Tonight by 11:59pm  Program 3 Assigned 2.
CS1101X: Programming Methodology Recitation 10 Inheritance and Polymorphism.
Output Programs These slides will present a variety of small programs. Each program has a compound condition which uses the Boolean Logic that was introduced.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
WAP to find out the number is prime or not Import java.util.*; Class Prime { public static void main(string args[]) { int n,I,res; boolean flag=true;
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
Section 2.2 The StringLog ADT Specification. 2.2 The StringLog ADT Specification The primary responsibility of the StringLog ADT is to remember all the.
IF Statements flowcharts and pseudocode Please open the speaker notes - they contain additional information!
CSC111 Quick Revision.
using System; namespace Demo01 { class Program
Introduction to programming in java
Factoring if/else code
CPSC 121: Models of Computation
SELECTION STATEMENTS (1)
Building Java Programs
Decision statements. - They can use logic to arrive at desired results
Review Operation Bingo
Computing Adjusted Quiz Total Score
null, true, and false are also reserved.
TO COMPLETE THE FOLLOWING:
Stack Memory 2 (also called Call Stack)
An Introduction to Java – Part I, language basics
The Boolean (logical) data type boolean
Interfaces and Constructors
Java so far Week 7.
Programming in Java Assertion.
Unit 3 - The while Loop - Extending the Vic class - Examples
Recursive GCD Demo public class Euclid {
References and Objects
class PrintOnetoTen { public static void main(String args[]) {
Lecture Notes – Week 4 Chapter 5 (Loops).
Lecture Notes – Week 2 Lecture-2
Building Java Programs
Names of variables, functions, classes
Factoring if/else code
Instructor: Mainak Chaudhuri
Presentation transcript:

Propositional Equivalences Rosen 5th and 6th Editions section 1.2

I assume you know what follows

Okay? If not then please read appropriate section from Rosen

// // are functions f and g logically equivalent? public class Obfuscate { public static boolean f(int x,int y){ boolean z; if (!(x>5 || (x<=5 && y<3))) z = true; else z = false; return z; } public static boolean g(int x,int y){return x<=5 && y>=3;} public static void main(String[] args) { int n = Integer.parseInt(args[0]); int m = Integer.parseInt(args[1]); System.out.println(f(n,m) + " " + g(n,m));

What’s the difference between & and && | and ||

Can you think of a reason why we might use | in place of || & in place of &&

Propositional Equivalences