Skip to content

Commit 1a4fa0e

Browse files
committed
updated explanations in the solutions.
1 parent d04f946 commit 1a4fa0e

File tree

2 files changed

+31
-13
lines changed

2 files changed

+31
-13
lines changed

Agda/Exercises/03-Exercises.lagda.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ is-lower-bound P n = {!!}
253253
We define the type of minimal elements of a type family over the naturals.
254254
```agda
255255
minimal-element : (P : ℕ → Type) → Type
256-
minimal-element P = {!!}
256+
minimal-element P = Σ n ꞉ ℕ , (P n) × (is-lower-bound P n)
257257
```
258258

259259
### Exercise 8 (⋆)

Agda/Exercises/03-Solutions.lagda.md

+30-12
Original file line numberDiff line numberDiff line change
@@ -277,18 +277,25 @@ is-minimal-element-suc :
277277
(m : ℕ) (pm : P (suc m))
278278
(is-lower-bound-m : is-lower-bound (λ x → P (suc x)) m) →
279279
¬ (P 0) → is-lower-bound P (suc m)
280-
is-minimal-element-suc P d m pm is-lower-bound-m neg-p0 0 p0 =
281-
𝟘-nondep-elim (neg-p0 p0)
282-
is-minimal-element-suc
283-
P d 0 pm is-lower-bound-m neg-p0 (suc n) psuccn = leq-zero n
284-
is-minimal-element-suc
285-
P d (suc m) pm is-lower-bound-m neg-p0 (suc n) psuccn =
286-
is-minimal-element-suc (λ x → P (suc x)) (λ x → d (suc x)) m pm
287-
(λ m → is-lower-bound-m (suc m))
288-
(is-lower-bound-m 0)
289-
(n)
290-
(psuccn)
280+
is-minimal-element-suc P d m pm is-lower-bound-m neg-p0 0 p0 = 𝟘-nondep-elim (neg-p0 p0)
281+
-- In the previous clause, 𝟘-nondep-elim is superfluous, because neg-p0 p0 : ∅ already.
282+
is-minimal-element-suc P d 0 pm is-lower-bound-m neg-p0 (suc n) psuccn = ⋆
283+
is-minimal-element-suc P d (suc m) pm is-lower-bound-m neg-p0 (suc n) psuccn = h
284+
where
285+
h : suc m ≤₁ n
286+
h = is-minimal-element-suc (λ x → P (suc x))
287+
(λ x → d (suc x)) m pm
288+
(λ m → is-lower-bound-m (suc m))
289+
(is-lower-bound-m 0)
290+
(n)
291+
(psuccn)
292+
-- alternative solution
293+
h' : suc m ≤₁ n
294+
h' = is-lower-bound-m n psuccn
291295
```
296+
The lemma states that for a decidable type family `P`, if `m` is a lower bound
297+
for `P ∘ suc`, and `P 0` is false, then `m + 1` is a lower bound for `P`.
298+
Note that the assumptions `d` and `pm` are not used.
292299

293300
### Exercise 10 (🌶)
294301

@@ -304,7 +311,18 @@ well-ordering-principle-suc :
304311
minimal-element (λ m → P (suc m)) → minimal-element P
305312
well-ordering-principle-suc P d n p (inl p0) _ = 0 , (p0 , (λ m q → leq-zero m))
306313
well-ordering-principle-suc P d n p (inr neg-p0) (m , (pm , is-min-m)) = (suc m) , (pm , is-minimal-element-suc P d m pm is-min-m neg-p0)
314+
where
315+
h : is-lower-bound P (suc m)
316+
h = is-minimal-element-suc P d m pm is-min-m neg-p0
317+
318+
-- alternative solution
319+
h' : is-lower-bound P (suc m)
320+
h' zero q = 𝟘-nondep-elim (neg-p0 q)
321+
h' (suc k) q = is-min-m k q
307322
```
323+
This lemma states that for a decidable type family `P`, if `P ∘ suc` is true for some `n`,
324+
and `P 0` is decidable, then minimal elements of `P ∘ suc` yield minimal elements of `P`.
325+
Note that `d` and `p` are not used.
308326

309327
### Exercise 11 (🌶)
310328

@@ -315,7 +333,7 @@ well-ordering-principle P d 0 p = 0 , (p , (λ m q → leq-zero m))
315333
well-ordering-principle P d (suc n) p = well-ordering-principle-suc P d n p (d 0) (well-ordering-principle (λ m → P (suc m)) (λ m → d (suc m)) n p)
316334
```
317335

318-
### Exercise 12 (🌶)
336+
### Exercise 12 (⋆⋆⋆)
319337

320338
Prove that the well-ordering principle returns 0 if `P 0` holds.
321339

0 commit comments

Comments
 (0)