the-lambda-church / coquille

Interactive theorem proving with Coq in vim.
ISC License
186 stars 68 forks source link

Add 'as' and 'return' keywords in 'match ... with' constructions #34

Closed lgeorget closed 9 years ago

lgeorget commented 9 years ago

Hello!

In this small patch, I add the keywords 'as' and 'return' to various 'match ... with' constructions. It is used in this kind of constructions:

Definition pred_partial : forall n:nat, n <> 0 -> nat.
  refine
  (fun n =>
    match n as x return x <> 0 -> nat with
    | O => fun h:0 <> 0 => _
    | S p => fun h:S p <> 0 => p
  end).
  elim h.
  reflexivity.
Defined.

(Taken from the Coq'Art, by Yves Bertot and Pierre Castéran, https://www.labri.fr/perso/casteran/CoqArt/coqartF.pdf).

lgeorget commented 9 years ago

For those who are interested, the previous definition is equivalent to:

Definition pred_partial' : forall n:nat, n <> 0 -> nat :=
  fun n =>
    match n as x return x <> 0 -> nat with
    | O => fun h:0 <> 0 => False_rec nat (h eq_refl)
    | S p => fun h:S p <> 0 => p
  end.
trefis commented 9 years ago

Thank you!