Logic and proofs
مُقدَّم
5:38
الرياضيات المتقطعة
Discrete mathematics is the mathematics of objects you can list: statements, sets, graphs and arrangements. The first three units build the proof engine…
سرد باللغة الإنجليزية · ترجمة نصية بالإنجليزية و中文 يمكنك التبديل بينهما
في هذا الدرس
| English | المعنى |
|---|---|
| sorted lists | |
| proposition/ˌprɒpəˈzɪʃn/ | الحكم |
| truth table/truːθ ˈteɪbl/ | جدول الحقيقة |
| contrapositive/ˌkɒntrəˈpɒzɪtɪv/ | المقابلة العكسية |
| converse/ˈkɒnvɜːs/ | العكس |
| De Morgan's laws/də ˈmɔːɡənz lɔːz/ | قوانين دي مورغان |
| predicate logic/ˈpredɪkeɪt ˈlɒdʒɪk/ | المنطق التقريري |
| quantifier/ˈkwɒntɪfaɪə/ | المُقدِّر (المُقيِّم) |
| direct proof/daɪˈrekt pruːf/ | الإثبات المباشر |
| contraposition/ˌkɒntrəpəˈzɪʃn/ | الاستدلال بالعكس المعاكس |
| proof by contradiction/pruːf baɪ ˌkɒntrəˈdɪkʃn/ | الإثبات بالتناقض |
Did the tester break the claim?
- A spec says: "If the list is sorted, the search returns the right index." A tester feeds in an unsorted list, gets a wrong index and files a bug: "the claim is false."
- This test does not show the claim is false. The claim only promises something about sorted lists 有序列表. This lesson makes that kind of reading exact, then turns it into proofs.
Propositions and the truth table
- A proposition 命题 is a statement that is true or false. Join them with ¬ (not), ∧ (and), ∨ (or), → (if…then) and ↔ (if and only if).
- A truth table 真值表 lists every combination of T and F for the variables, so it settles any formula. With $n$ variables there are $2^n$ rows.
| $p$ | $q$ | ${p{\land}q}$ | ${p{\lor}q}$ | ${p{\to}q}$ | ${p{\leftrightarrow}q}$ |
|---|---|---|---|---|---|
| T | T | T | T | T | T |
| T | F | F | T | F | F |
| F | T | F | T | T | F |
| F | F | F | F | T | T |
- $p \to q$ is false in one row only: $p$ true and $q$ false. When $p$ is false, the implication is true whatever $q$ is.
A formula uses the variables p, q, r and s. How many rows does its truth table have?
الصعوبة 2/5 · 140 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Each variable is T or F, so there are $2^4 = 16$ combinations.
Reading "if p then q"
- $p \to q$ is false in one row only: $p$ true and $q$ false. When $p$ is false the claim makes no promise, so it counts as true. That is why the unsorted list broke nothing.
- $p \to q \equiv \neg p \lor q$. The contrapositive 逆否命题 $\neg q \to \neg p$ has the same truth table; the converse 逆命题 $q \to p$ does not.

The claim "if the list is sorted, the search returns the right index" is shown false by an unsorted list that gets a wrong index.
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
With p false, p → q is true whatever happens. Only a sorted list with a wrong index would break the claim.
Match each form to the statement it describes, for the claim p → q.
الصعوبة 2/5 · 140 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
The contrapositive and ¬p ∨ q share the truth table of p → q; the converse does not; p ∧ ¬q is its negation.
Negation flips everything it passes
- De Morgan's laws 德摩根律: $\neg(p \land q) \equiv \neg p \lor \neg q$ and $\neg(p \lor q) \equiv \neg p \land \neg q$. The negation goes inside and the connective flips.
- Predicate logic 谓词逻辑 adds the quantifiers 量词 $\forall$ (for all) and $\exists$ (there exists). Negation swaps them and negates the predicate: $\neg\forall x\,P(x) \equiv \exists x\,\neg P(x)$.
Claim: "every email has exactly one address." Its negation: "some email has no address, or some email has two or more addresses." One email that breaks the rule is enough.
Push the negation inside
Set a and b and compare ¬(a ∧ b) with ¬a ∨ ¬b, then the OR form. The two sides agree on every row, and the naive rewrite without flipping the connective fails on a counterexample.
The negation of ∀x P(x) is —
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
One counterexample is enough: negation swaps the quantifier and negates the predicate.
Which formulas are equivalent to ¬(p ∧ q)? Select all that apply.
الصعوبة 2/5 · 140 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
De Morgan gives ¬p ∨ ¬q. Rewriting p → ¬q as ¬p ∨ ¬q gives the same, and so does q → ¬p. ¬p ∧ ¬q forgets to flip the connective.
Three proof shapes
- Direct proof 直接证明: assume $p$ and derive $q$. Contraposition 逆否证明: prove $\neg q \to \neg p$ instead, which helps when the negatives are easier to work with.
- Proof by contradiction 反证法: assume $p \land \neg q$ and derive something impossible. Choosing the shape decides which assumptions you get to compute with.
Assuming p ∧ ¬q and deriving something impossible is —
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Contradiction assumes the claim fails; the impossibility shows it cannot fail.
Name the shape, then prove
Claim: if $n^2$ is even, then $n$ is even. "$n^2$ even" is hard to use, so prove the contrapositive 逆否命题.
Suppose $n$ is odd: $n = 2k + 1$. Then $n^2 = 4k^2 + 4k + 1 = 2(2k^2 + 2k) + 1$, which is odd. So "$n$ odd" gives "$n^2$ odd", and the claim follows.
- State the strategy in the first line ("by contraposition"), so the reader knows what you are assuming.
Put the contraposition proof of "if n² is even then n is even" in order.
الصعوبة 3/5 · 200 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Name the shape first, then work from the assumption ¬q to the conclusion ¬p.
Marks that slip away
- Proving the converse 逆命题. Showing $q \to p$ when $p \to q$ was asked proves the wrong thing.
- Negating without flipping. $\neg(p \land q)$ is $\neg p \lor \neg q$, not $\neg p \land \neg q$.
- Examples as proof. Ten examples do not prove a "for all" claim. One counterexample does disprove it.
You've got it
- $p \to q$ is false only when $p$ is true and $q$ is false; $p \to q \equiv \neg p \lor q \equiv \neg q \to \neg p$.
- Negation flips ∧/∨ (De Morgan) and swaps $\forall$/$\exists$.
- Translate the claim, choose a shape (direct, contraposition 逆否证明, contradiction), name it, then write justified steps.
ما المشكلة؟ لا يرى ذلك سوى فريق الموقع.