LF Teacher (solutions) source diff
LF/Automation.lean
11531153 case mStar0 ih => exists []; simp
11541154 case mStarApp s₁ s₂ re h₁ h₂ ih₁ ih₂ =>
11551155 injections heq; subst heq
1156- obtain ⟨ss, hfold, hall⟩ := ih₂ rfl
1156+ obtain ⟨ss, hfold, hall⟩ := ih₂ (by rfl)
11571157 exists (s₁ :: ss)
11581158 simp only [List.foldr_cons, List.mem_cons, forall_eq_or_imp]; rw [← hfold]
11591159 repeat
16811681 · exact heq.2.symm
16821682
16831683 theorem palindrome_converse {α : Type} {l : List α} (h : l = l.reverse) : Pal l := by
1684- exact reverse_pal rfl h
1684+ apply reverse_pal (by rfl) h
16851685
16861686 end PalConv
16871687
1688--- Source revision: 2ca0e09, committed 2026-10-23 15:44 UTC
1688+-- Source revision: a06e066, committed 2026-10-27 16:51 UTC
LF/Basics.lean
13351335 -- Similarly, for each of the three branches of the definition of `even`,
13361336 -- we need one simplification rule:
13371337
1338-theorem even_zero : even zero = true := rfl
1339-theorem even_one : even (succ zero) = false := rfl
1340-theorem even_succ_succ (n : Nat) : even (succ (succ n)) = even n := rfl
1338+theorem even_zero : even zero = true := by rfl
1339+theorem even_one : even (succ zero) = false := by rfl
1340+theorem even_succ_succ (n : Nat) : even (succ (succ n)) = even n := by rfl
13411341
13421342 attribute [irreducible] even odd
13431343
22702270 end Airport
22712271 end NatPlayground
22722272
2273--- Source revision: 2ca0e09, committed 2026-10-23 15:44 UTC
2273+-- Source revision: a06e066, committed 2026-10-27 16:51 UTC
LF/IndProp.lean
20902090 | take l hsub =>
20912091 rw [List.length_cons]
20922092 apply succ_le_succ
2093- apply ih _ rfl _ hsub
2093+ apply ih _ (by rfl) _ hsub
20942094 rw [List.allb_cons, Bool.and_eq_true] at hall
20952095 obtain ⟨_, h⟩ := hall
20962096 exact h
20972097 | skip hsub =>
20982098 apply Le.step
2099- exact ih _ rfl _ hsub hall
2099+ apply ih _ (by rfl) _ hsub hall
21002100
21012101 end FilterChallenge
21022102
23962396 Repeats l₁ :=
23972397 pigeonhole_aux l₁ [] l₂ hin hlen
23982398
2399--- Source revision: 2ca0e09, committed 2026-10-23 15:44 UTC
2399+-- Source revision: a06e066, committed 2026-10-27 16:51 UTC
LF/Induction.lean
11261126 end NatToBin
11271127 end NatPlayground.Nat
11281128
1129--- Source revision: 2ca0e09, committed 2026-10-23 15:44 UTC
1129+-- Source revision: a06e066, committed 2026-10-27 16:51 UTC
LF/Lists.lean
522522 rw [count_cons_def, h, cond_false]
523523
524524 example : count 1 [1] = 1 := by
525- rw [count_cons_same _ _ _ rfl]
526- rw [count_nil]
525+ rw [count_cons_same] -- This generates a subgoal for `h`, which will be closed by `rfl`
526+ · rw [count_nil]
527+ · rfl
527528
528529 example : count 2 [2, 2] = 2 := (by rfl)
529530
562563 rw [member, h, cond_false]
563564
564565 example : member 1 [1] = true := by
565- rw [member_cons_same _ _ _ rfl]
566+ rw [member_cons_same _ _ _ (by rfl)]
566567
567568 example : member 2 [1] = false := (by rfl)
568569
597598 rw [removeOne, h, cond_false]
598599
599600 example : removeOne 5 [1, 5, 4] = [1, 4] := by
600- rw [removeOne_cons_diff _ _ _ rfl]
601- rw [removeOne_cons_same _ _ _ rfl]
601+ rw [removeOne_cons_diff _ _ _ (by rfl)]
602+ rw [removeOne_cons_same _ _ _ (by rfl)]
602603
603604 example : count 5 (removeOne 5 [1, 5, 4]) = 0 := (by rfl)
604605
626627 rw [removeAll, h, cond_false]
627628
628629 example : count 5 (removeAll 5 [5, 1]) = 0 := by
629- rw [removeAll_cons_same _ _ _ rfl]
630- rw [removeAll_cons_diff _ _ _ rfl]
630+ rw [removeAll_cons_same _ _ _ (by rfl)]
631+ rw [removeAll_cons_diff _ _ _ (by rfl)]
631632 rw [removeAll_nil]
632- rw [count_cons_diff _ _ _ rfl]
633+ rw [count_cons_diff _ _ _ (by rfl)]
633634 rw [count_nil]
634635
635636 example : count 5 (removeAll 5 [5, 5]) = 0 := (by rfl)
662663 example : included [1] [2, 1] = true := by
663664 rw [included_cons_member]
664665 · exact included_nil _
665- · rw [member_cons_diff _ _ _ rfl]
666- rw [member_cons_same _ _ _ rfl]
666+ · rw [member_cons_diff _ _ _ (by rfl)]
667+ rw [member_cons_same _ _ _ (by rfl)]
667668
668669 example : included [1, 1] [2, 1, 4, 1] = true := (by rfl)
669670
10461047 example : beq [] [] = true := (by rfl)
10471048 example : beq [1, 2, 3] [1, 2, 3] = true := (by rfl)
10481049 example : beq [1, 2, 3] [1, 2, 4] = false := by
1049- rw [beq_cons_same _ _ _ _ rfl]
1050- rw [beq_cons_same _ _ _ _ rfl]
1051- rw [beq_cons_diff _ _ _ _ rfl]
1050+ rw [beq_cons_same _ _ _ _ (by rfl)]
1051+ rw [beq_cons_same _ _ _ _ (by rfl)]
1052+ rw [beq_cons_diff _ _ _ _ (by rfl)]
10521053
10531054 theorem beq_refl (l : NatList) :
10541055 beq l l = true := by
10931094 | cons n s' ih =>
10941095 cases n with
10951096 | zero =>
1096- rw [removeOne_cons_same _ _ _ rfl, count_cons_same _ _ _ rfl, ble_self_succ]
1097+ rw [removeOne_cons_same _ _ _ (by rfl), count_cons_same _ _ _ (by rfl), ble_self_succ]
10971098 | succ n' =>
1098- rw [removeOne_cons_diff _ _ _ rfl, count_cons_diff _ _ _ rfl, count_cons_diff _ _ _ rfl]
1099+ rw [removeOne_cons_diff _ _ _ (by rfl), count_cons_diff _ _ _ (by rfl), count_cons_diff _ _ _ (by rfl)]
10991100 exact ih
11001101
11011102 -- ### Exercise (3 stars): count_append (Optional, Manually graded) ⭐⭐⭐
13471348
13481349 end Lists
13491350
1350--- Source revision: 2ca0e09, committed 2026-10-23 15:44 UTC
1351+-- Source revision: a06e066, committed 2026-10-27 16:51 UTC
LF/Logic.lean
298298 · rfl /- 2 * 2 = 4 -/
299299
300300 -- Rather than applying the constructor, we can explicitly provide the
301--- arguments to the constructor as an `exact` proof.
301+-- arguments to the constructor as an `exact` proof. In particular, we can
302+-- write each argument as a *subproof* using the `by` keyword (the same
303+-- keyword that begins a proof- not a coincidence!). For example, since
304+-- each subproof of `And.intro` in the example below is closed by `rfl`,
305+-- we can close these proofs by passing `(by rfl)` as an argument to
306+-- `And.intro`.
302307
303308 example : 3 + 4 = 7 ∧ 2 * 2 = 4 := by
304- exact And.intro rfl rfl
309+ exact And.intro (by rfl) (by rfl)
305310
306311 -- Lean can figure out which constructor to use just from the goal's type,
307312 -- so we don't have to name it ourselves. This is what the tactic
309314 -- builds a value of the goal's type, leaving one subgoal per argument of
310315 -- that constructor. Since `And` has just one constructor, `constructor`
311316 -- always picks it here.
317+--
318+-- The constructor tactic is *very* useful for proofs involving types with
319+-- many constructors, which we will see in the IndProp chapter.
312320
313321 example : 3 + 4 = 7 ∧ 2 * 2 = 4 := by
314322 constructor
319327 -- which works on constructors for proofs as well.
320328
321329 example : 3 + 4 = 7 ∧ 2 * 2 = 4 := by
322- exact ⟨rfl, rfl⟩
330+ exact ⟨(by rfl), (by rfl)⟩
323331
324332 -- ### Exercise (2 stars): add_is_zero ⭐⭐
325333
11691177 theorem List.All_nil {α : Type} {a : α → Prop} : List.All a [] := (by constructor)
11701178
11711179 theorem List.All_cons {α : Type} {p : α → Prop} {x : α} {l : List α} :
1172- List.All p (x :: l) = (p x ∧ All p l) := (rfl)
1180+ List.All p (x :: l) = (p x ∧ All p l) := (by rfl)
11731181
11741182 theorem List.All_In {α : Type} {p : α → Prop} {l : List α} :
11751183 (∀ x : α, In x l → p x) ↔ All p l := by
16591667 · intro h
16601668 cases b1 with
16611669 | false => rw [and] at h; contradiction
1662- | true => rw [and] at h; exact ⟨rfl, h⟩
1670+ | true =>
1671+ rw [and] at h
1672+ exact ⟨by rfl, h⟩
16631673 · intro h
16641674 cases b1 with
16651675 | false => exfalso; cases h.left
16951705 | _, _ => false)
16961706
16971707 theorem beqList_nil_nil {α : Type} {beq : α → α → Bool} :
1698- beqList beq [] [] = true := (rfl)
1708+ beqList beq [] [] = true := (by rfl)
16991709
17001710 theorem beqList_cons_cons {α : Type} {beq : α → α → Bool}
17011711 {x y : α} {xs ys : List α} :
17021712 beqList beq (x :: xs) (y :: ys) = (beq x y && beqList beq xs ys) :=
1703- (rfl)
1713+ (by rfl)
17041714
17051715 theorem beqList_nil_cons {α : Type} {beq : α → α → Bool}
1706- {x : α} {xs : List α} : beqList beq [] (x :: xs) = false := (rfl)
1716+ {x : α} {xs : List α} : beqList beq [] (x :: xs) = false := (by rfl)
17071717
17081718 theorem beqList_cons_nil {α : Type} {beq : α → α → Bool}
1709- {x : α} {xs : List α} : beqList beq (x :: xs) [] = false := (rfl)
1719+ {x : α} {xs : List α} : beqList beq (x :: xs) [] = false := (by rfl)
17101720
17111721 theorem beqList_true_iff α (beq : α → α → Bool)
17121722 (h : ∀ (x y : α), beq x y = true ↔ x = y) :
17631773 | [] => true
17641774 | x :: xs' => test x && allb test xs')
17651775
1766-theorem List.allb_nil {α : Type} {test : α → Bool} : allb test [] = true := (rfl)
1776+theorem List.allb_nil {α : Type} {test : α → Bool} : allb test [] = true := (by rfl)
17671777
17681778 theorem List.allb_cons {α : Type} {test : α → Bool} {x : α} {l : List α} :
1769- allb test (x :: l) = (test x && allb test l) := (rfl)
1779+ allb test (x :: l) = (test x && allb test l) := (by rfl)
17701780
17711781 theorem List.allb_true_iff α {test : α → Bool} {l : List α} :
17721782 allb test l = true ↔ All (fun x => test x = true) l := by
23902400 theorem peirce_cm : Peirce → ConsequentiaMirabilis := by
23912401 intro h a; exact h a False
23922402
2393--- Source revision: 2ca0e09, committed 2026-10-23 15:44 UTC
2403+-- Source revision: a06e066, committed 2026-10-27 16:51 UTC
LF/Poly.lean
124124 -- Some simple facts about `replicate`:
125125
126126 theorem replicate_zero (α : Type) (a : α) :
127- replicate α a 0 = MyList.nil := rfl
127+ replicate α a 0 = MyList.nil := by rfl
128128
129129 theorem replicate_succ (α : Type) (a : α) (count : Nat) :
130- replicate α a (count + 1) = MyList.cons a (replicate α a count) := rfl
130+ replicate α a (count + 1) = MyList.cons a (replicate α a count) := by rfl
131131
132132 -- We can use `replicate` by applying it first to a type and then to an
133133 -- element of this type (and a number):
13991399
14001400 end Church
14011401
1402--- Source revision: 2ca0e09, committed 2026-10-23 15:44 UTC
1402+-- Source revision: a06e066, committed 2026-10-27 16:51 UTC
LF/Postscript.lean
6363 -- Lean](https://leanprover-community.github.io/mathematics_in_lean/)
6464 -- develops formalized mathematics using Lean and Mathlib.
6565
66--- Source revision: 2ca0e09, committed 2026-10-23 15:44 UTC
66+-- Source revision: a06e066, committed 2026-10-27 16:51 UTC
LF/Preface.lean
419419 -- Note to developers (Benjamin Pierce @bcpierce00):
420420 -- Other funding should be acknowledged here...
421421
422--- Source revision: 2ca0e09, committed 2026-10-23 15:44 UTC
422+-- Source revision: a06e066, committed 2026-10-27 16:51 UTC
LF/Tactics.lean
13291329 | nil => assumption
13301330 | cons y ys ih =>
13311331 rw [List.cons_append, List.length_cons] at *
1332- /- A trick here: by using `rfl` to close `(ys ++ x :: l₂).length = n`
1332+ /- A trick here: by using `(by rfl)` to close `(ys ++ x :: l₂).length = n`
13331333 we effectively choose `n` to be `(ys ++ x :: l₂).length`
13341334 -/
1335- rw [ih rfl]
1335+ rw [ih (by rfl)]
13361336 assumption
13371337
13381338 -- ### Exercise (3 stars): length_append_self (Optional) ⭐⭐⭐
13491349 rw [← h]
13501350 | cons x xs ih =>
13511351 rw [List.cons_append, List.length_cons] at *
1352- rw [← length_append_cons rfl]
1353- rw [ih rfl, ← h]
1352+ rw [← length_append_cons (n := (xs ++ x::xs).length) (h := by rfl)]
1353+ rw [ih (by rfl), ← h]
13541354 rw [Nat.add_add_add_comm]
13551355
13561356 -- ### Exercise (3 stars): list_ext ⭐⭐⭐
15731573 rw [anyTrue, ih, anyTrue', anyTrue', allTrue]
15741574 rw [Bool.not_and, Bool.not_not]
15751575
1576--- Source revision: 2ca0e09, committed 2026-10-23 15:44 UTC
1576+-- Source revision: a06e066, committed 2026-10-27 16:51 UTC
LF/Typeclasses.lean
16131613
16141614 end Reflection
16151615
1616--- Source revision: 2ca0e09, committed 2026-10-23 15:44 UTC
1616+-- Source revision: a06e066, committed 2026-10-27 16:51 UTC
LF/UsingLean.lean
423423
424424 def Nat.odd (n : Nat) := !(even n)
425425
426-theorem Nat.odd_def (n : Nat) : n.odd = !(n.even) := rfl
426+theorem Nat.odd_def (n : Nat) : n.odd = !(n.even) := by rfl
427427
428428 def Nat.minusTwo (n : Nat) : Nat :=
429429 match n with
526526 -- With these tools in hand, we can begin to prove properties about more
527527 -- sophisticated forms of data, beginning with `Lists`.
528528
529--- Source revision: 2ca0e09, committed 2026-10-23 15:44 UTC
529+-- Source revision: a06e066, committed 2026-10-27 16:51 UTC
LF.lean
1111 import LF.Typeclasses
1212 import LF.Postscript
1313
14--- Source revision: 2ca0e09, committed 2026-10-23 15:44 UTC
14+-- Source revision: a06e066, committed 2026-10-27 16:51 UTC
SFLCompat/Experiment.lean
146146 Example:
147147 ```lean
148148 sf_expect_failure_in
149- example : 1 = 2 := rfl
149+ example : 1 = 2 := by rfl
150150 ```
151151 -/
152152 def expectFailureTk := leading_parser
SFLCompat/Recall/Check.lean
460460
461461 def twice (f : Nat → Nat) (n : Nat) : Nat := f (f n)
462462
463-theorem twice_id : twice id 3 = 3 := rfl
463+theorem twice_id : twice id 3 = 3 := by rfl
464464
465465 sf_recall
466466 inductive Palette where
490490
491491 -- The statement form counts universe parameters: a placeholder universe
492492 -- becomes a parameter and matches, and a fixed universe is rejected.
493-theorem poly_refl.{u} : ∀ {α : Sort u} (a : α), a = a := fun _ => rfl
493+theorem poly_refl.{u} : ∀ {α : Sort u} (a : α), a = a := fun _ => by rfl
494494
495495 sf_recall statement poly_refl : ∀ {α : Sort _} (a : α), a = a
496496
SFLCompat/Recall/Source.lean
6363
6464 def twice (f : Nat → Nat) (n : Nat) : Nat := f (f n)
6565
66-theorem twice_id : twice id 3 = 3 := rfl
66+theorem twice_id : twice id 3 = 3 := by rfl
6767
6868 sf_recall_source
6969 inductive Palette where