convoy-pattern

extracting evidence of equality from match

老子叫甜甜 提交于 2019-12-23 17:20:20
问题 I am trying to make the following work: Definition gen `{A:Type} {i o: nat} (f: nat -> (option nat)) {ibound: forall (n n':nat), f n = Some n' -> n' < i} (x: svector A i) (t:nat) (ti: t < o): option A := match (f t) with | None => None | Some t' => Vnth x (ibound t t' _) end. In place of last "_" I need an evidence that "f t" is equals to "Some t'". I could not figure out how to get it from the match. Vnth is defined as: Vnth : ∀ (A : Type) (n : nat), vector A n → ∀ i : nat, i < n → A 回答1:

Implementing vector addition in Coq

最后都变了- 提交于 2019-12-07 07:56:44
问题 Implementing vector addition in some of the dependently typed languages (such as Idris) is fairly straightforward. As per the example on Wikipedia: import Data.Vect %default total pairAdd : Num a => Vect n a -> Vect n a -> Vect n a pairAdd Nil Nil = Nil pairAdd (x :: xs) (y :: ys) = x + y :: pairAdd xs ys (Note how Idris' totality checker automatically infers that addition of Nil and non- Nil vectors is a logical impossibility.) I am trying to implement the equivalent functionality in Coq,

Implementing vector addition in Coq

[亡魂溺海] 提交于 2019-12-05 15:03:27
Implementing vector addition in some of the dependently typed languages (such as Idris) is fairly straightforward. As per the example on Wikipedia : import Data.Vect %default total pairAdd : Num a => Vect n a -> Vect n a -> Vect n a pairAdd Nil Nil = Nil pairAdd (x :: xs) (y :: ys) = x + y :: pairAdd xs ys (Note how Idris' totality checker automatically infers that addition of Nil and non- Nil vectors is a logical impossibility.) I am trying to implement the equivalent functionality in Coq, using a custom vector implementation, albeit very similar to the one provided in the official Coq

Structural recursion on a dependent parameter

99封情书 提交于 2019-11-28 05:04:25
问题 I'm trying to write the sieve of Eratosthenes in Coq. I have a function crossout : forall {n:nat}, vector bool n -> nat -> vector bool n . When the sieve finds a number that is prime, it uses crossout to mark all the numbers that are not prime and then recurses on the resulting vector. The sieve obviously can't be structurally recursive on the vector itself, but it is structurally recursive on the length of the vector. What I want is to do something like this: Fixpoint sieve {n:nat} (v:vector