Question

In: Computer Science

1. The equality operation on naturals is correctly computed by the following pseudo-Java method: boolean equals...

1. The equality operation on naturals is correctly computed by the following pseudo-Java method:

boolean equals (natural x, natural y) {

if (zero(x)) return zero(y);

return equals(pred(x), pred(y));

}

2. Suppose we define a function f from naturals to naturals as follows. We define f(0) to be 0, and for any natural x we define f(Sx) to be 1. Then this function satisfies the equation f(x · y) = f(x) · f(y), for any naturals x and y.

3.

Suppose I want to prove "for all x: S0 + x = Sx". The following is valid:

Ordinary induction on all naturals x.

Base case: x = 0, the desired formula becomes "S0 + 0 = S0". This is true by the base case of the definition of addition.

Inductive hypothesis: S0 + x = Sx

Inductive goal: S0 + Sx = S(Sx)

Proof of inductive step: By the inductive case of the definition of addition, S(S0 + x) = S0 + Sx. By the inductive hypothesis, applied inside the parentheses, the left-hand side of this equation is equal to S(Sx)). So the inductive goal is true.

Please help with True or False Questions

Solutions

Expert Solution

The solutions for the above questions is given below and if you feel any problem then feel free to ask.

1. True, because the function is of type boolean and returning bool, also the function is taking two arguments as natural x and y. And in the first case zero function returns a boolean value if x is zero then the function will return the boolean value for y whether it is zero or not and after if the function is return the boolean for whether x and y are equal or not.

2. True, as the f(0) =0 and for any x f(Sx)=1. Then taking f(x.y) we can write it as f(x).f(y) as the value for f(x) =1 and f(y) =1 and x.y is also a natural number or zero if x or y is zero then the value of f(x.y) becomes equal to 0 or 1. And, similarly the value of f(x).f(y) is either 0 or 1 (0 if any number is zero).

3. False, as the base condition is S0 + 0 =S0 which is true according to condition. And now taking the inductive hypothesis we get S0+n =Sn for n=x

and for the inductive step, for n=x+1

S0+(n+1) = S0 +n+1 = Sn+1 = S(n+1)

Here in the above question the goal for inductive step is not correct as the inductive step is used to prove the truthiness of our inductive hypothesis by proving it true for the next step i.e., n+1. But in the given case it is just putting the value of hypothesis in the equation instead of the next step.


Related Solutions

(TCO 2) Which of the following operations is not an operation of Boolean algebra? $ |...
(TCO 2) Which of the following operations is not an operation of Boolean algebra? $ | & ~
Correctly follow the described algorithm to complete the method    * Add operation counts -   ...
Correctly follow the described algorithm to complete the method    * Add operation counts -    * f(N) formula (show your work) -    * O(N) reduction -    */    public static int[] algorithm1(int N)//f(N) = ; O(N) =    {        long opCount = 0;        int[] arr = new int[N];        /*        * Use the following method to fill the array        * For each position in the array, generate a...
Write a Java program to 1. read in the size of a square boolean matrix A...
Write a Java program to 1. read in the size of a square boolean matrix A 2. read in the 0-1 matrix elements 3. read in a positive integer n 4. display A^n
Write a Java program to 1. read in the size of a square boolean matrix A...
Write a Java program to 1. read in the size of a square boolean matrix A 2. read in the 0-1 matrix elements 3. read in a positive integer n 4. display A^n Multiplying that matrix to the nth power. Like A^2 = matrix A * matrix A. Elements ONLY can be 0 or 1.
Write a MIPS assembly language program that implements the following pseudo-code operation: result = x +...
Write a MIPS assembly language program that implements the following pseudo-code operation: result = x + y – z + A[j] x and y should be in reserved memory words using the .word directive and labeled as x and y. Initialize x=10 and y=200. Read in z from the console. Input the value -8. This is the value for z, not for –z. Store this value in memory with the label z. To begin, you could just initialize z to...
// the language is java, please implement the JOptionPane Use method overloading to code an operation...
// the language is java, please implement the JOptionPane Use method overloading to code an operation class called CircularComputing in which there are 3 overloaded methods and an output method as follows: • computeObject(double radius) – compute the area of a circle • computeObject(double radius, double height) – compute area of a cylinder • computeObject(double radiusOutside, double radiusInside, double height) – compute the volume of a cylindrical object • output() use of JOptionPane to display instance field(s) and the result...
(JAVA) I was wondering if anyone can check if I am implementing this method correctly based...
(JAVA) I was wondering if anyone can check if I am implementing this method correctly based on the instructions? Here are the instructions: buildShape(String input) In the buildShape() method, you will parse the provided input to determine whether to create a CircleShape or SquareShape. Before you create the shape, you need to determine it's size, location and color. Use TestableRandom to randomly generate an int size ranging from 100-200. Randomly generate an x and y index for its location. X...
language is java Use method overloading to code an operation class called CircularComputing in which there...
language is java Use method overloading to code an operation class called CircularComputing in which there are 3 overloaded methods as follows: computeObject(double radius)-compute area of a circle computeObject(double radius, double height)-compute area of a cylinder computeObject(double radiusOutside, double radiusInside, double height)-compute volume of a cylindrical object These overloaded methods must have a return of computing result in each Then override toString() method so it will return the object name, the field data, and computing result Code a driver class...
How do I write this method correctly? What Ihave is a Java project assignment where I'm...
How do I write this method correctly? What Ihave is a Java project assignment where I'm supposed to create a Roshambo game. One of the classes that the project is supposed to have is a class called "RoshamboApp that let the user play 1 of 2 AI opponents, a "Bart" class, and a "Lisa" class. The instructions say "Create a class names RoshamboApp that allows player1 to play Bart or Lisa as shown in the console output. Rock should beat...
1. Use Boolean algebra to simplify the following Boolean expressions to expressions containing a minimum number...
1. Use Boolean algebra to simplify the following Boolean expressions to expressions containing a minimum number of literals: (a) A’C’ + A’BC + B’C (b) (A + B + C)’(ABC)’ (c) ABC’ + AC (d) A’B’D + A’C’D + BD (e) (A’ + B)’(A’ + C’)’(AB’C)’ (f) (AE + A’B’)(C’D’ + CD) + (AC)’ 2. Obtain the truth table of the function F = (AB + C)(B + AC), express the function F in sum-of-minterms and product-of-maxterms forms, and express...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT