Skip to content

Instantly share code, notes, and snippets.

@bond15
Last active March 15, 2022 18:51
Show Gist options
  • Save bond15/e8e56c9367a47cf3cf59a1a195db7c7e to your computer and use it in GitHub Desktop.
Save bond15/e8e56c9367a47cf3cf59a1a195db7c7e to your computer and use it in GitHub Desktop.
Coq Extended Pattern Match - Program Definition
Require Import Program.Tactics.
Lemma prf (n : nat)(p : n = 0) : bool.
Admitted.
Program Definition huh(n : nat) : bool :=
match n with
| O => prf n _. (* Program adds the equation `n = 0` to the context of this match branch which is pickec up by the implicit *)
| S n => true
end.
(*
Agda does not have this?
prf : ∀{n : ℕ} → (p : n ≡ 0) → Bool
prf = {! !}
huh : ℕ → Bool
huh n@zero = prf {n} _
huh _ = true
*)
@bond15
Copy link
Author

bond15 commented Mar 15, 2022

@bond15
Copy link
Author

bond15 commented Mar 15, 2022

See "Generation of Equalities"

match x with
| 0 => t
| S n => u
end.

rewritten to

(match x as y return (x = y -> _) with
| 0 => fun H : x = 0 -> t
| S n => fun H : x = S n -> u
end) (eq_refl x).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment