Skip to content

Commit ec90047

Browse files
author
Alex Gryzlov
committed
Tactics: finish with examples for now
1 parent 2dcd269 commit ec90047

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/Tactics.lidr

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,12 @@ Here, we could prove this with rewrites:
4949
or the dependent pattern matching:
5050

5151
```idris
52-
silly1 m m p p Refl Refl = Refl
52+
silly1 n n o o Refl Refl = Refl
5353
```
5454

55+
\todo[inline]{Write more about dependent pattern matching techinque. Maybe move
56+
to an earlier chapter?}
57+
5558
as we have done several times before. We can achieve the same effect by a series
5659
of tactic applications, using \idr{exact} instead of the
5760
\idr{rewrite}+\idr{Refl} combination:
@@ -380,46 +383,43 @@ equations that \idr{injective} generates.
380383

381384
$\square$
382385

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}
384392

385393
When used on a hypothesis involving an equality between _different_ constructors
386394
(e.g., \idr{S n = Z}), \idr{injective} solves the goal immediately. Consider the
387395
following proof:
388396

389-
> -- beq_nat_0_l : beq_nat 0 n = True -> n = 0
397+
> beq_nat_0_l : beq_nat 0 n = True -> n = 0
390398

391399
We can proceed by case analysis on n. The first case is trivial.
392400

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
395402

396403
However, the second one doesn't look so simple: assuming \idr{beq_nat 0 (S n') =
397404
True}, we must show \idr{S n' = 0}, but the latter clearly contradictory! The
398405
way forward lies in the assumption. After simplifying the goal state, we see
399406
that \idr{beq_nat 0 (S n') = True} has become \idr{False = True}:
400407

401-
> -- compute
408+
\todo[inline]{How to show impossible cases from Elab?}
402409

403-
\todo[inline]{Finish the script. Use \idr{disjoint}?}
410+
> beq_nat_0_l {n=(S _)} prf = absurd prf
404411

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}.
407414

408415
This is an instance of a logical principle known as the principle of explosion,
409416
which asserts that a contradictory hypothesis entails anything, even false
410417
things!
411418

412-
\todo[inline]{How to show impossible cases from Elab?}
413-
414419
> inversion_ex4 : (n : Nat) -> S n = Z -> 2 + 2 = 5
415420
> -- we need "sym" because Prelude.Nat only disproves "Z = S n" for us
416421
> inversion_ex4 n prf = absurd $ sym prf
417422

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-
423423
> inversion_ex5 : (n, m : Nat) -> False = True -> [n] = [m]
424424
> inversion_ex5 n m prf = absurd prf
425425

0 commit comments

Comments
 (0)