@@ -49,9 +49,12 @@ Here, we could prove this with rewrites:
49
49
or the dependent pattern matching:
50
50
51
51
```idris
52
- silly1 m m p p Refl Refl = Refl
52
+ silly1 n n o o Refl Refl = Refl
53
53
```
54
54
55
+ \todo[inline]{Write more about dependent pattern matching techinque. Maybe move
56
+ to an earlier chapter ?}
57
+
55
58
as we have done several times before. We can achieve the same effect by a series
56
59
of tactic applications, using \idr{exact} instead of the
57
60
\idr{rewrite}+\idr{Refl} combination:
@@ -380,46 +383,43 @@ equations that \idr{injective} generates.
380
383
381
384
$\ square$
382
385
383
- \ todo[inline]{Edit or remove}
386
+ \ todo[inline]{Remove if https : //github.com/idris-lang/Idris-dev/pull/3925 is merged}
387
+
388
+ > Uninhabited (False = True ) where
389
+ > uninhabited Refl impossible
390
+
391
+ \ todo[inline]{Edit }
384
392
385
393
When used on a hypothesis involving an equality between _different_ constructors
386
394
(e. g. , \ idr{S n = Z }), \ idr{injective} solves the goal immediately. Consider the
387
395
following proof :
388
396
389
- > -- beq_nat_0_l : beq_nat 0 n = True -> n = 0
397
+ > beq_nat_0_l : beq_nat 0 n = True -> n = 0
390
398
391
399
We can proceed by case analysis on n. The first case is trivial.
392
400
393
- > -- beq_nat_0_l {n=Z} prf = %runElab reflexivity
394
- > -- beq_nat_0_l {n=(S _)} prf = %runElab (do
401
+ > beq_nat_0_l {n= Z } _ = Refl
395
402
396
403
However , the second one doesn't look so simple : assuming \idr{beq_nat 0 (S n') =
397
404
True }, we must show \ idr{S n' = 0 }, but the latter clearly contradictory! The
398
405
way forward lies in the assumption. After simplifying the goal state, we see
399
406
that \ idr{beq_nat 0 (S n') = True } has become \ idr{False = True }:
400
407
401
- > -- compute
408
+ \ todo[inline]{ How to show impossible cases from Elab ? }
402
409
403
- \ todo[inline]{ Finish the script . Use \ idr{disjoint} ? }
410
+ > beq_nat_0_l {n = ( S _ )} prf = absurd prf
404
411
405
- If we use inversion on this hypothesis, Idris notices that the subgoal we are
406
- working on is impossible, and therefore removes it from further consideration .
412
+ If we use \ idr{absurd} on this hypothesis, Idris allows us to safely infer any
413
+ conclusion from it, in this case our goal of \ idr{n = 0 } .
407
414
408
415
This is an instance of a logical principle known as the principle of explosion,
409
416
which asserts that a contradictory hypothesis entails anything, even false
410
417
things!
411
418
412
- \ todo[inline]{How to show impossible cases from Elab ? }
413
-
414
419
> inversion_ex4 : (n : Nat ) -> S n = Z -> 2 + 2 = 5
415
420
> -- we need "sym" because Prelude.Nat only disproves "Z = S n" for us
416
421
> inversion_ex4 n prf = absurd $ sym prf
417
422
418
- \ todo[inline]{Remove if https : //github.com/idris-lang/Idris-dev/pull/3925 is merged}
419
-
420
- > Uninhabited (False = True ) where
421
- > uninhabited Refl impossible
422
-
423
423
> inversion_ex5 : (n, m : Nat ) -> False = True -> [n] = [m]
424
424
> inversion_ex5 n m prf = absurd prf
425
425
0 commit comments