Velocer › Flashcard › University of Wisconsin–Madison › comp sci 240 midterm 1
comp sci 240 midterm 1
Intro to discrete math, propositions + predicate logic, sets, proof techniques. · oleh sunset_point_notes · 153 kartu
- DiscreteOpposite of continuous; values are distinct and separated, not smoothly varying.
- Discrete structuresStructures you can count off with integers: element 1, element 2, element 3, and so on. Like the integers 1, 2, 3 or the letters of a word.
- RigorousEvery statement is precise; concepts fixed by definitions, claims stated as propositions.
- ProofA sound justification that a statement is true, leaving no doubt.
- Two steps of inductionBase case plus induction step.
- Base case in inductionThe property holds for the first element.
- Induction stepFor every positive integer k, property at k implies property at k+1.
- Loop invariantA statement that is true each time a loop iteration starts.
- Loop invariant baseThe property holds on the first arrival at the loop start.
- Loop invariant stepThe property is preserved from the start to the end of an iteration.
- What are loop invariants used for?Proving the correctness of iterative programs.
- Foundation ruleThe part of a recursive definition giving the simplest instances.
- Constructor ruleThe part of a recursive definition that builds complex instances from simpler ones.
- Structural inductionInduction where the base covers the foundation rule and the step covers the constructor rule.
- Recursive programSplits an instance into simpler instances of the same problem, calls itself, and composes the solutions.
- How do you prove a recursive program correct?Induction on recursion depth plus a termination argument showing recursion bottoms out.
- What do program analyses lead to?Recurrence relations; you focus on asymptotic behavior for large inputs.
- GraphNodes plus edges, where each edge is a pair of nodes.
- What do graphs model?Relations, like friendships: nodes are people, edges are friend pairs.
- What do trees model?Hierarchical relations.
- Equivalence relations correspond to what?Partitions of the universe.
- Graph topicsConnectivity, isomorphism, and planarity.
- Finite state automataSpecial graphs modeling simple computation; they exactly match the power of regular expressions.
- CombinatoricsCounting structures that have a given property.
- Classical combinatoricsPermutations, combinations, and selections from finite sets under restrictions.
- Uniform-distribution probabilities and countingThey are equivalent: computing a probability is just counting outcomes.
- Stable matching setupn students and n professors; each professor hires one student, each student gets one advisor.
- Preference ranking in stable matchingEach side submits a strict ranking with no ties.
- Matching (definition)A pairing where each student has exactly one advisor, and each professor advises exactly one student. So it's a one-to-one link between the two groups.
- Disruptive pair (s, p)Not paired together, and both prefer each other over their current partners.
- Stable matchingA matching with no disruptive pair.
- Is a matching where everyone gets their top choice always stable?It is stable, but it may not be a valid matching, like when two share a first choice.
- Does a stable matching always exist?Yes, and it is shown by giving an algorithm.
- Gale–Shapley: what happens in the morning step?Every student sends an application to the highest-ranked school they haven't been rejected by yet. Example: if your top pick already said no, you try your next favorite.
- Gale–Shapley afternoon stepEach professor says maybe to the top applicant and no to the others.
- Gale–Shapley evening stepRejected students cross that professor off their list.
- In Gale–Shapley, who is a student paired with?The professor who most recently said maybe to them.
- How many stable matchings can exist?There may be many; the algorithm returns one of them.
- p optimal for sThe highest-ranked professor that some stable matching pairs with s.
- p pessimal for sThe lowest-ranked professor that some stable matching pairs with s.
- Student optimal matchingEvery student gets their optimal professor.
- Professor pessimal matchingEvery professor gets their pessimal student.
- Optimality theorem for Gale–ShapleyIts output is both student optimal and professor pessimal.
- Real-world uses of stable matchingMedical residents to hospitals, students to schools, and organ transplant allocation.
- PropositionA claim that's true or false, nothing in between. Like "7 is odd" (true) or "3 > 5" (false). Questions and commands don't count.
- Are questions and commands propositions?No, they have no truth value.
- What does ¬P mean?Not P; flips the truth value.
- When is P ∧ Q true?Only when both P and Q are true.
- When is P ∨ Q false?Only when both P and Q are false (inclusive or).
- In P ⇒ Q, what are P and Q called?P is the premise, Q is the consequence.
- Why is an implication with a false premise true?It's vacuously true; the condition never holds.
- What makes an implication false?True premise and false consequence.
- Does a true implication alone prove the consequence?No, you must also show the premise holds.
- Logically equivalentSame truth value for every variable assignment.
- How do you test logical equivalence?Compare truth-table columns row by row.
- Contrapositive of P ⇒ Q¬Q ⇒ ¬P; logically equivalent to the original.
- Converse of P ⇒ QQ ⇒ P; not equivalent to the original.
- P ⇐⇒ Q (iff)(P ⇒ Q) ∧ (Q ⇒ P); true when both sides share truth value.
- AxiomA proposition assumed true without proof.
- PredicateA mapping from a domain to propositions; a parametrized proposition.
- (∀x)P(x)True if P holds for every x in the domain; false if one counterexample exists.
- What is (∀x)P(x) on an empty domain?True, because no counterexample is possible.
- ¬(∀x)S(x) is equivalent to what?(∃x)¬S(x)
- How does ∀ behave like a big AND?It requires P to hold for every element, like conjoining all cases.
- How does ∃ behave like a big OR?It requires P to hold for at least one element, like disjoining all cases.
- DeMorgan: ¬(P ∧ Q) ≡ ?¬P ∨ ¬Q
- How do you prove ∃ is false?Show it's false for every element (harder than a counterexample).
- "All A are B" in predicate logic(∀x)(A(x) ⇒ B(x))
- "Some A is B" in predicate logic(∃x)(A(x) ∧ B(x))
- Why use ⇒ with ∀?So irrelevant elements don't falsify the statement.
- Does quantifier order matter?Yes: (∀x)(∃y)P(x,y) is not the same as (∃y)(∀x)P(x,y).
- If (∃y)(∀x)P(x,y) is true, what follows?(∀x)(∃y)P(x,y) is true (weaker, loses info).
- Does (∀x)(∃y)P(x,y) imply (∃y)(∀x)P(x,y)?No, the reverse does not hold.
- Shrinking domain to condition: (∀x ∈ D1)P(x) ≡ ?(∀x ∈ D)(x ∈ D1 ⇒ P(x))
- Shrinking domain to condition: (∃y ∈ D2)Q(y) ≡ ?(∃y ∈ D)(y ∈ D2 ∧ Q(y))
- Goldbach's conjectureEvery even integer > 2 is a sum of two primes; truth unknown.
- Prime numberAn integer > 1 divisible only by 1 and itself.
- Does math "or" allow both?Yes, it's inclusive; everyday "or" often excludes both.
- P ∨ (¬P ∧ Q) ≡ ?P ∨ Q
- How do you prove an implication via its contrapositive?Prove ¬Q ⇒ ¬P, which is logically equivalent to P ⇒ Q.
- Why is "any" ambiguous in logic?It can mean "for all" or "there exists"; use explicit quantifiers.
- SetA collection of elements drawn from a domain.
- Well-defined setFor every element in the domain, you can decide whether it belongs.
- What does x ∈ A mean?x is an element of set A.
- Subset A ⊆ BEvery element of A is also an element of B.
- Strict subset A ⊂ BA ⊆ B and B has at least one element not in A.
- Does the order of elements matter in a set?No; {true, false} is the same set as {false, true}.
- Set-builder notation{x ∈ N | 100 ≤ x ≤ 1000}: before the | names the element, after gives properties.
- What does the symbol | mean in set-builder notation?'Such that' — it separates the element from its properties.
- Finite setA set with a finite number of elements, all listable given enough time.
- Boolean domain BB = {true, false}.
- On B′ = {0, 1}, what operation matches ∧?Multiplication.
- When is XOR true?When exactly one of the two values is true.
- Cardinality |S|The number of distinct elements in a finite set S.
- What is |∅|?0.
- Countable setFinite, or infinite with an enumeration that lists exactly all its elements.
- Enumeration of a setEach position gives a different element, and every element appears somewhere.
- Is N countable?Yes: 0, 1, 2, 3, … lists every natural number.
- Is Z countable?Yes: 0, 1, −1, 2, −2, … lists every integer.
- When is an ellipsis (...) allowed in a set?Only when the continuation is unambiguous — one logical next step.
- Dense setBetween any two elements lies another element; Q is dense since (x+y)/2 works.
- Is Q countable?Yes; arrange a/b in a table and traverse it diagonally, skipping duplicates.
- Is R countable?No; the reals are uncountable.
- Russell's paradox set S = {A | A ∉ A}Whether S ∈ S is undefined, so S is not well-defined.
- Union E1 ∪ E2{x | x ∈ E1 ∨ x ∈ E2}; ∪ parallels OR.
- Intersection E1 ∩ E2{x | x ∈ E1 ∧ x ∈ E2}; ∩ parallels AND.
- What is a Venn diagram the set analog of?A truth table; it gets messy beyond 3 sets.
- Distributive law for setsA ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C).
- Complement of E2{x | x ∉ E2}; the precise form also requires x ∈ U, the domain.
- Set difference E1 − E2{x | x ∈ E1 ∧ x ∉ E2}.
- How do you write a complement using set difference?S3 = U − E2, where U is the domain.
- Power set P(A)The set of all subsets of A: P(A) = {S | S ⊆ A}.
- List P({0, 1}){∅, {0}, {1}, {0, 1}}.
- If |A| = k, what is |P(A)|?2^k, since each element is independently in or out.
- What is |P({0, 1, 2})|?2³ = 8.
- Alternate notation for P(A)2^A.
- Is P(N) countable?No; the power set of the naturals is uncountable.
- Proof by contradictionAssume the negation of what you want, then derive a false statement.
- Why does diagonalization show P(N) is uncountable?The built A differs from every A_k at element k−1, so A is not in the enumeration.
- How is R shown to be uncountable?Use binary representation together with diagonalization.
- Inference ruleA rule with antecedents (premises) and a conclusion (consequence).
- Modus ponensFrom P and P ⇒ Q, you conclude Q.
- How is an inference rule written?Antecedents above a horizontal line, conclusion below it.
- Direct proof of P ⇒ Q: what's step 1?Assume P is true.
- Direct proof of P ⇒ Q: what's step 2?Derive Q logically from P.
- Direct proof of P ⇒ Q: what's step 3?State Q, and mark the end with □ or Q.E.D.
- What does Q.E.D. mean?"Which was to be shown" — an end-of-proof marker.
- How do you prove a universal statement?Prove it for an arbitrary element, not just one example.
- If x is odd, how do you write it?x = 2y + 1 for some integer y.
- Indirect proof (contrapositive): what do you prove?Prove ¬Q ⇒ ¬P instead, which is logically equivalent to P ⇒ Q.
- Contrapositive rule(¬Q ⇒ ¬P) → (P ⇒ Q).
- When is contrapositive proof useful?When the statement has negations; the contrapositive strips them away.
- Contrapositive vs. converseThe contrapositive is equivalent to the original; the converse is not.
- Method A for proving P ⇐⇒ QProve P ⇒ Q and Q ⇒ P separately.
- Biconditional rule(P ⇒ Q) ∧ (Q ⇒ P) → (P ⇐⇒ Q).
- Method B for proving P ⇐⇒ QBuild a chain P1 ⇐⇒ P2 ⇐⇒ … ⇐⇒ Pk with P1 = P and Pk = Q.
- What does a chain of equivalences prove?Both directions at once.
- Proof by contradiction: what do you assume?Assume ¬P, derive a falsehood, then conclude P.
- Contradiction rule(¬P ⇒ false) → P.
- When should you avoid proof by contradiction?When possible — it's less intuitive; prefer direct or indirect proof.
- √2 is irrational: what's the first assumption?Assume √2 = a′/b′ with gcd(a′, b′) = 1.
- √2 proof: what does squaring give?2(b′)² = (a′)², which forces a′ to be even.
- √2 proof: how does the contradiction arise?Both a′ and b′ turn out even, contradicting gcd(a′, b′) = 1.
- Why number your equations in a proof?So you can reference them later.
- Proof by cases: what must the conditions satisfy?At least one Ci is always true, and each Ci ⇒ P.
- Proof by cases rule(C1 ∨ … ∨ Ck) ∧ (C1 ⇒ P) ∧ … ∧ (Ck ⇒ P) → P.
- How is a truth table a case proof?Each row is one case.
- 6 people: what's always guaranteed?Either 3 mutual acquaintances or 3 mutual strangers.
- 6-people proof: how do you split on Alice?Case ≥3 acquaintances vs. ≤2 acquaintances, each splitting into subcases.
- Graph model for the 6-people problemPeople are vertices, acquaintance is an edge; the stranger case mirrors the acquaintance case.
- Are Venn-diagram set proofs valid proofs?No — they're only an intuition aid.
- Proving one instance vs. proving universallyOne example never proves a universally quantified claim.
- Contradiction vs. indirect proof: what's assumed?Contradiction assumes ¬P; indirect proof assumes ¬Q, the negation of the conclusion.
Velocer gratis: pengulangan berjarak dan kartu Anda sendiri dari dokumen apa pun.
PDF to flashcards · Lecture to flashcards · Practice exam · Syllabus study plan · Anki import
Dek lain dari University of Wisconsin–Madison
- comp sci 240 midterm 2
- COMP SCI 240 Midterm 3
- COMP SCI 240 Final
- comp sci 300 full course review
- CS 639: Introduction to Reinforcement Learning · UW-Madison
- CS 839: Reinforcement Learning · UW-Madison
- CS 544: Intro to Big Data Systems · UW-Madison
- CS 580: Intelligent Robotics · UW-Madison
- CS 784: Foundations of Data Management · UW-Madison
- CS 880: Quantum Algorithms · UW-Madison
- CS 765: Data Visualization · UW-Madison
- CS 639: AI Coding · UW-Madison