Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] how to write this function?

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] how to write this function?


Chronological Thread 
  • From: Ömer Sinan Ağacan <omeragacan AT gmail.com>
  • To: Daniel Schepler <dschepler AT gmail.com>
  • Cc: coq club <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] how to write this function?
  • Date: Sat, 5 Apr 2014 23:33:56 +0300

2014-04-05 23:13 GMT+03:00 Daniel Schepler
<dschepler AT gmail.com>:
> Fixpoint nth_triangle_aux {T : Type} (idx stop : nat) (tr :
> triangle_t T idx) : Vector.t T stop :=
> match eq_nat_dec idx stop with
> | left e => match e in (_ = stop') return Vector.t T stop' with
> | eq_refl => match tr in (triangle_t _ idx')
> return (Vector.t T idx') with
> triangle _ v _ => v
> end
> end
> | right ne =>
> match tr in (triangle_t _ n) return (S idx = S n -> Vector.t T stop)
> with
> triangle n _ tr' => fun eq : S idx = S n =>
> match eq in (_ = Sn) return (triangle_t T Sn -> Vector.t T
> stop)
> with
> | eq_refl => fun tr' => nth_triangle_aux (S idx) stop tr'
> end tr'
> end eq_refl
> end.

This code has some constructs that I never saw before(match ... in ...
and match ... return ...), I had started proving useful theorems in
proof mode(I implemented a non-trivial language and proved type
soundness of it) but apparently there are a lot to learn on
programming side. I'll start reading CPDT from chapter 6.

Thanks again!

---
Ömer Sinan Ağacan
http://osa1.net



Archive powered by MHonArc 2.6.18.

Top of Page