soen331a1

pdf

School

University of the Fraser Valley *

*We aren’t endorsed by this school

Course

13

Subject

Computer Science

Date

Oct 30, 2023

Type

pdf

Pages

9

Uploaded by kakger18

Report
SOEN 331: Assignment 1 Adrienne Digo(40058646) Flora Avakian(40158192) Rose Rutherford-Stone(27062516) Due: October 14, 2021 Problem 1. Question 4.1. Propositional Logic You are shown a set of four cards placed on a table, each of which has a letter on one side and a symbol on the other side. The visible faces of the cards show the letters L and A, and the symbols 2 , and 3 . Which card(s) must you turn over in order to test the truth of the proposition that “If a card has an consonant on one side, then it has the symbol 3 on the other side” Solution. Question 4.1. The proposition can be rewritten as consonant 3 . This statement will only ever be false if the card face shows a vowel, and the other side shows a 3 . First, we should check the card L. Using modus ponens we get: consonant 3 consonant 3 So, if we turn over a card which has a consonant (L), we should see a diamond, otherwise the proposition is false. Next, we would flip over the 2 . Using modus tollens (where ¬ consonant is vowel and ¬ 3 is 2 ): consonant 3 2 vowel So, if we flip over a square we would expect to see a vowel. We do not need to flip over the 3 card or the A card. Flipping over the 3 card would give us no information as this would be a converse error: consonant 3 3 consonant This is a fallacy and cannot be used as evidence to prove consonant 3 . Flipping over the A card would also not give any information as it would be an inverse error. consonant 3 vowel 2 This would be a fallacy and cannot be using to prove consonant 3 . So, in summary L and 2 must be turned over, A and 3 do not need to be. Problem 2. Question 4.2 In the domain of all people, consider the predicate disclosed(a, b) that is interpreted as “a has disclosed a secret to b.” 1. How are the following two expressions translated into plain English? Are the two expressions logically equivalent? a b disclosed(a,b). 1
b a disclosed(a,b). 2. Can we claim that a b disclosed(a,b) → ∃ b a disclosed(a,b)? 3. Can we claim that b a disclosed(a,b) → ∀ a b disclosed(a,b)? Solution. Question 4.2 1. In plain English, the first expression reads: “Every a has disclosed a secret to at least one b ”. The second expression reads: “There is some b who has had a secret disclosed to from every a ”. The two expressions are not logically equivalent. In the first expression, b can be different for each a but in the second expression, b must work for all a . Logical equivalence occurs when p ⇐⇒ q is a tautology. This is not the case and is thus not logically equivalent. 2. No. Suppose a b disclosed(a, b) is true. This means that for all a , disclosed(a,b) is true for some b . Let G ( a ) be the set of elements b , where b disclosed(a,b). Let m be a point where m disclosed(m,b). Let G ( m ) be the set of elements b in which we are satisfying disclosed(a,b) with point m . a b disclosed(a, b) tells us that for every point m , the sets G ( m ) can result in two cases: (i) intersection is an or, (ii) at least one shared element b. In the first case, a b disclosed(a, b) holds true. It is not true however for b a disclosed(a, b). The intersection of all G ( m ) s must contain at least one shared b since there is some b in which all a has disclosed a secret to it. 3. Yes. Using the same logic as the previous answer: Suppose b a disclosed(a, b) is true. This means that for some b , disclosed(a,b) is true for all a . Let G ( a ) be the set of elements b , where b disclosed(a,b). Let m be a point where m disclosed(m,b). Let G ( m ) be the set of elements b in which we are satisfying disclosed(a,b) with point m . b a disclosed(a, b) tells us that for every point m , G ( m ) is not empty. This is also true for a b disclosed(a, b) since there is some b G ( m ) for all m . Problem 3. Question 4.3 Consider the subject “x is a person” and the predicate “x is mortal”, together with the following list of categorical propositions: “No person is immortal.” “All people are immortal.” “Some people are mortal.” “Some people are not mortal.” 1. Identify each categorical statement with its name (i.e. letter description). 2. Identify universal statements. 3. Identify particular statements. 4. Identify affirmative statements. 5. Identify negative statements. 6. Identify statements with opposite truth values. 7. Identify statements that cannot both be true, but could both be false. 8. Identify statements that cannot both be false but could both be true. 9. Identify pairs of super-subaltern statements. Solution. Question 4.3 2
1. “No person is immortal.” is A form. “All people are immortal.” is E form. “Some people are mortal.” is I form. “Some people are not mortal.” is O form. 2. The universal statements are: ”No person is immortal.” and “All people are immortal.”. 3. The particular statements are: “Some people are mortal.” and “Some people are not mortal.” 4. The affirmative statements are: “No person is immortal.” and “Some people are mortal.” 5. The negative statements are: “All people are immortal.” and “Some people are not mortal.” 6. The statements with opposite truth values are: “No person is immortal.” and “Some people are not mortal.” 7. The statement that cannot both be true but could both be false are: “No person is immortal.” and “All people are immortal.” 8. The statement that cannot both be false but could both be true: “Some people are mortal.” and “Some people are not mortal.” 9. The statements that are pairs of super-subaltern statements: ”Some people are mortal.” is subaltern of “No person is immortal.” “Some people are not mortal.” is subaltern of “All people are immortal.” Problem 4. Question 4.4 Consider a list Λ deployed to implement a Stack Abstract Data Type. 1. Let the head of Λ correspond to the topmost position of the Stack. Implement the body of operations push(el, Λ ) and pop( Λ ) (let return element be held in variable topmost) using list construction opera- tions. In both cases a) we assume that appropriate preconditions exist, and b) we can refer to Λ 0 as the state of the list upon successful termination of one of its operations. 2. Let the last element of Λ correspond to the topmost position of the Stack. Implement the body of both operations as above. When applicable, use control flow statements in your answer. Solution. Question 4.4 1. Stack protocol is on a LIFO basis. push ( el , ): cons(el, ) (or: concat(list(el), ) pop ( ): topmost = head( ) 0 = tail( ) Comments: The output of push ( el , ) is a new list with the first element as head and the second as tail. pop ( ) includes retrieving and removing. Returns a new list 0 . 2. We now reverse the way we manipulate. push ( el , ): cons(el, ) (or: concat(list(el), ) pop ( ): topmost = head(tail(tail(tail( )))) 0 = list( head(tail(tail( ))), head(tail( )), head( ) ) Comments: Since we are only able to access the head and tail, we must use nested head and lists in order to retrieve elements within the list. 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Problem 5. Question 4.5 Consider the sets: Laptop = { Apple,IBM ,Sony,HP,Acer,Dell,LG } Favorite = { Apple,Sony,Dell } Answer the following questions: 1. How do we interpret the expression Favorite : P Laptop? 2. Is P Laptop a legitimate type? 3. What is the nature of the variable in Favorite : P Laptop? (i.e. Atomic or composite? If composite, what type?) 4. Is Apple P Laptop? Explain why or why not 5. Is { Apple } ∈ P Laptop? Explain why or why not 6. Is {{}} ∈ P Laptop? Explain why or why not 7. Is {} ∈ P Laptop? Explain why or why not 8. If we define variable Favorite : P Laptop, is {} a legitimate value for variable Favorite? Explain why or why not 9. Is Favorite P Laptop? Explain. 10. Is Favorite P Laptop? Explain. Solution. Question 4.5 1. It is interpreted as “The variable Favorite can assume any value supported by the powerset of Laptop .” 2. Yes, the power set of Laptop is a legitimate type because it is a set that contains all subsets of Laptop including the empty set. 3. The nature of the variable in Favorite is composite and it is of type set. 4. No, Apple isn’t an element of the power set Laptop because Apple is not a subset of Laptop since it is not defined inside braces. 5. Yes, { Apple } belongs to P Laptop because a power set contains all subsets of a given set and { Apple } is a subset of Laptop. 6. No, {{}} doesn’t belong to the power set Laptop because an empty set including an empty set cannot be an element of this set. 7. Yes, {} is an element of P Laptop because an empty set is an element of all sets. 8. Yes, because the empty set is a valid set and is a subset of all sets. 9. Yes, Favorite is an element of the power set Laptop because Favorite is a set that contains elements of Laptop . 10. No, because Favorite is not a subset P Laptop . Problem 6. Question 4.6 Consider a system that assigns id’s to locations. An id may represent a vehicle in a parking lot, a train in a station, a process in an operating system etc. A location may represent a parking spot, a train station platform, a core in a hardware system etc. The requirements of the system are as follows: 4
1. ID’s are unique. 2. An id is assigned to a single location (and maybe reassigned subsequently). 3. No multiple id’s may be assigned to the same location The model of the system is captured by a relation assignment, which is represented as a set as shown below: assignment = { 001 7→ A , 002 7→ B , 003 7→ C , } 1. Define the precondition to operation add, that assigns a new id to a location. 2. Provide two alternative definitions for the main functionality of the operation. 3. What would be the result of calling the operation with id? = 001, and location? = D? 4. Let us get rid of the precondition. What would be the result of calling add with id? = 004, and location? = C? Would you accept or reject the call? If accepted then the pair should be added to the relation. If rejected, it should not be added to the relation. 5. Assume that in the absence of a precondition, we attempted to call operation add with some input parameters id? and location?. Under what conditions, if any, would this be acceptable? 6. Consider operation reassign that modifies the location of an existing id. Define the precondition to operation reassign. 7. Define the body of operation reassign. Solution. Question 4.6 1. id? : id location? : location id ? / dom assignment location ? ran assignment 2. The two definitions for the main functionality of the operation are the following : assignment 0 = assignemnt ⊕ { id ? 7→ location ? } assignment 0 = assignemnt ∪ { id ? 7→ location ? } 3. The result would lead to a violation of requirements since no multiple id’s may be assigned to the same location. It is no longer a proper function since two unique ids are mapped to two elements in the co domain. We thus reject and will not be added. 4. For basic specification, it may ignore the incorrect input or may break down. But, we can define a schema that describes the errors, its condition for which the error occurs, and an appropriate error message. For example, in this case, we can create a schema IDExists which specifies that the id already exists in the domain and can display a message such as ” ID already exists! ”. 5
5. Add would always work if a location and id were input. However, this could lead to the system being invalid. There is no check to make sure it follows the system requirements, so a ID could be added that is a duplicate, breaking the system requirements. 6. The precondition for reassign would be that the new input location is not assigned to another ID and that the ID already exists, so: id? : id location? : location location ? / ran assignment id ? dom assignment 7. id ? : id location ? : location location ? / ran assignment id ? dom assignment assignment 0 = assignment ⊕ { inputID 7→ inputLocation } Problem 7. Question 4.7 Consider the following relation: cellphones : Model Brand where cellphones = { galaxyA 21 s 7→ samsung , mate 10 7→ huawei , mate 10 pro 7→ huawei , galaxyA 01 7→ samsung , iPhone 12 ProMax 7→ apple , iPhoneSE 7→ apple , galaxyJ 2 Core 7→ samsung , redmi 6 A 7→ xiaomi , redmi 8 7→ xiaomi } 1. Given the above relation, (a) Define the domain of cellphones (b) Define the range of cellphones 2. Given the following the expression: { galaxyA 01 , galaxyJ 2 Core , redmi 8 } cellphones (a) What is the meaning of operator ? (b) What is the value of the expression? (c) Where would you deploy such operator in the context of a database management system? 3. Given the following expression cellphones { samsung , xiaomi } (a) What is the meaning of the operator ? (b) What is the value of the expression? (c) Where would you deploy such operator in the context of a database management system? 6
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
4. Given the following expression { mate 10 pro , iPhoneSE , galaxyJ 2 Core } - C cellphones (a) What is the meaning of the operator - C ? (b) What is the value of the expression? (c) Where would deploy such operator in the context of a database management system? 5. Given the following expression cellphones - B { apple , xiaomi } (a) What is the meaning of the operator - B ? (b) What is the value of the expression? (c) Where would deploy such operator in the context of a database management system? 6. Consider the following expression: cellphones ⊕ { galaxyA 51 7→ samsung , mate 9 7→ huawei } (a) What is the meaning of the operator ? (b) What is the value of the expression? (c) Where would deploy such operator in the context of a database management system? (d) Does the result of the expression have a permanent effect on the database (relation)? If not, describe in detail how would you ensure that such operation would have a permanent effect. Solution. Question 4.7 1. (a) The domain is defined as : dom cellphones = { galaxyA 21 s , mate 10 , mate 10 pro , galaxyA 01 , iPhone 12 ProMax , iPhoneSE , galaxyJ 2 Core , redmi 6 A , redmi 8 } (b) The range is defined as: ran cellephones = { samsung , huawei , apple , xiaomi } . 2. (a) Domain restriction selects pairs based on their first element. (b) The value of this expression will be { galaxyA 01 , galaxyJ 2 Core , redmi 8 } cellphones = { galaxyA 01 7→ samsungl , galaxyJ 2 Core 7→ samung , redmi 8 7→ xiaomi , } (c) The operator is deployed to model database queries. 7
3. (a) Range restriction selects pairs based on their second element. (b) The value of this expression will be cellphones { samsung , xiaomi } = { galaxyA 21 s 7→ samsung , galaxyA 01 7→ samsung , galaxyJ 2 Core 7→ samsung , redmi 6 A 7→ xiaomi , redmi 8 7→ xiaomi , } (c) The operator is deployed to model database queries. 4. (a) Domain subtraction removes elements from the domain of the relation. (b) The value of this expression will be { mate 10 pro , iPhoneSE , galaxyJ 2 Core } - C cellphones = { galaxyA 21 s 7→ samsung , mate 10 7→ huawei , galaxyA 01 7→ samsung , IPhone 12 ProMax 7→ apple , redmi 6 A 7→ xiaomi redmi 8 7→ xiaomi } (c) The operator is deployed to model deletion of records. 5. (a) Range subtraction removes elements from the codomain of the relation. (b) The value of this expression will be cellphones - B { apple , xiaomi } = { galaxyA 21 s 7→ samsung , mate 10 7→ huawei , mate 10 pro 7→ huawei , galaxyA 01 7→ samsung , galaxyJ 2 Core 7→ samsung , } (c) The operator is deployed to model database updates (deletion of records). 6. (a) Relational overriding can model database updates (addition of records). (b) The result is 8
cellphones ⊕ { galaxyA 51 7→ samsung , mate 9 7→ huawei } = { galaxyA 51 7→ samsung , mate 9 7→ huawei , galaxyA 21 s 7→ samsung , mate 10 7→ huawei , mate 10 pro 7→ huawei , galaxyA 01 7→ samsung , iPhone 12 ProMax 7→ apple , iPhoneSE 7→ apple , galaxyJ 2 Core 7→ samsung , redmi 6 A 7→ xiaomi redmi 8 7→ xiaomi } (c) The operator is deployed to model database updates (addition of records). (d) The result of the expression does not have a permanent effect on the database . To ensure that such operation would have a permanent effect, an assignment statement needs to be defined. cellphones 0 = cellphones ⊕ { galaxyA 51 7→ samsung , mate 9 7→ huawei } which reads “The value of variable cellphones is assigned the result of the expression on the right- hand-side of the assignment statement.” 9
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help

Browse Popular Homework Q&A

Q: The difference between f'(3) and f'(x) is that f'(3) is a numerical value and f'(x) is a function of…
Q: For each ordered pair, determine whether it is a solution to the system of equations. −3x+2y=1…
Q: In mice black fur (B) is dominant over white fur (b), Green eyes (G) is dominant over blue eyes (g)…
Q: 4. Three point charges are located at the corners of a rectangle. The electric potential at the…
Q: Solve the given initial value problem dx/dt = 7x+y; x(0) =3 dy/dt = -8x+y; y(0) = 0 The solution is…
Q: Which of the moving charged particles will experience the least magnetic force? A B C the same
Q: 5. Find all possible single digits that can be placed in the square so that the number 1,427,4 2 is…
Q: Here ê, are orthonormal unit base vectors in R³. 2.12 Let the vectors (i, j, k) constitute an…
Q: f workers accurately predict the rate of inflation, is there a short-run trade-off between inflation…
Q: If the population standard deviation is 9, then what is the variance? a. 9 b. 81 c. 3 d. 18
Q: J2 all space (a) Positive charge Q is distributed uniformly over the surface of a thin spherical…
Q: Assume a monopolist faces the demand schedule given below and a constant marginal cost of $2 for…
Q: The price per share will be $ (Round to the nearest cent.)
Q: Consider a square in a regular hexagon, a six sided figure with sides of equal length one side of…
Q: 2. Let f(x) = x² + x³ - 10x² + 10. Find each of the following. You will need your graphing…
Q: Random sampling from four normally distributed populations produced the following data: (You may…
Q: Problem 3: Find unit vector of a force. Find the unit vector corresponding to a 100 N force at 60°…
Q: (Graduate students only) Consider the primal and dual problems in our standard form presented in…
Q: To interpret his finding, he needs to calculate the probability that a sample of 25 graduates would…
Q: Let X: N(3,4) so μ= 3,0=2 Find a) P(X ≤6) b) P(2.0≤X ≤5.4)
Q: 4.26 The components of a stress tensor at a point P, referred to the (11, 12, 13) system, are [57 0…
Q: Step by step guide. Thank you very much!   Find the derivative of the function. y = x2ex − 2xex +…