Skip to content

Instantly share code, notes, and snippets.

@mukeshtiwari
Created February 24, 2023 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mukeshtiwari/0ae6cf1278c5066657a0452b112ff21e to your computer and use it in GitHub Desktop.
Save mukeshtiwari/0ae6cf1278c5066657a0452b112ff21e to your computer and use it in GitHub Desktop.
Definition bind_vector :
forall {m n : nat}, Vector.t (A * prob) (1 + m) ->
list (Vector.t A n * prob) -> list (Vector.t A (S n) * prob).
Proof.
refine(
fix bind_vector m :=
match m with
| 0 => fun n ca cb => _
| S m' => fun n ca cb => _
end).
+
destruct (vector_inv_S ca) as ((h, p) & t & Hc).
(* I am going to stick h infront of ever cb and multiply p *)
exact (List.map
(fun '(hs, ps) => (Vector.cons _ h _ hs, mul_prob p ps)) cb).
+
destruct (vector_inv_S ca) as ((h, p) & t & Hc).
remember (List.map
(fun '(hs, ps) => (Vector.cons _ h _ hs, mul_prob p ps)) cb) as chead.
pose proof (bind_vector m' n t cb) as ctail.
exact (chead ++ ctail).
Defined.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment