diff --git a/src/plfa/part2/DeBruijn.lagda.md b/src/plfa/part2/DeBruijn.lagda.md index db88b709..bd69d574 100644 --- a/src/plfa/part2/DeBruijn.lagda.md +++ b/src/plfa/part2/DeBruijn.lagda.md @@ -423,7 +423,7 @@ lookup ∅ _ = ⊥-elim impossible We intend to apply the function only when the natural is shorter than the length of the context, which we indicate by postulating an `impossible` term, just as we did -[here]({{ site.baseurl }}/Lambda/#impossible). +[here]({{ site.baseurl }}/Lambda/#primed). Given the above, we can convert a natural to a corresponding de Bruijn index, looking up its type in the context: diff --git a/src/plfa/part2/Lambda.lagda.md b/src/plfa/part2/Lambda.lagda.md index f4c2f6a1..650bed03 100644 --- a/src/plfa/part2/Lambda.lagda.md +++ b/src/plfa/part2/Lambda.lagda.md @@ -209,7 +209,7 @@ definition may use `plusᶜ` as defined earlier (or may not ``` -#### Exercise `primed` (stretch) +#### Exercise `primed` (stretch) {#primed} Some people find it annoying to write `` ` "x" `` instead of `x`. We can make examples with lambda terms slightly easier to write @@ -230,6 +230,20 @@ case′ _ [zero⇒ _ |suc _ ⇒ _ ] = ⊥-elim impossible μ′ _ ⇒ _ = ⊥-elim impossible where postulate impossible : ⊥ ``` +We intend to apply the function only when the first term is a variable, which we +indicate by postulating a term `impossible` of the empty type `⊥`. If we use +C-c C-n to normalise the term + + ƛ′ two ⇒ two + +Agda will return an answer warning us that the impossible has occurred: + + ⊥-elim (plfa.part2.Lambda.impossible (`suc (`suc `zero)) (`suc (`suc `zero))) + +While postulating the impossible is a useful technique, it must be +used with care, since such postulation could allow us to provide +evidence of _any_ proposition whatsoever, regardless of its truth. + The definition of `plus` can now be written as follows: ``` plus′ : Term