Last active
March 28, 2019 18:59
-
-
Save ckoparkar/1ca33f1b74a67c42402865b00dc2122b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Require Import List. | |
Require Import Omega. | |
Import ListNotations. | |
Definition strong_head {A : Type} : forall ls : list A, ls <> [] -> A. | |
refine (fun (ls : list A) => | |
match ls with | |
| [] => fun _ => _ | |
| a :: _ => fun _ => a | |
end). | |
(* [] *) | |
congruence. | |
Defined. | |
Definition this_works : forall (ns : list nat) (idx : nat), (ns <> []) -> nat. | |
refine (fun ns idx ns_not_empty => | |
(strong_head ns _) - (strong_head ns _)). | |
+ apply ns_not_empty. | |
+ apply ns_not_empty. | |
Qed. | |
Definition bug : forall (ns : list nat) (idx : nat), (ns <> []) -> nat. | |
refine (fun ns idx ns_not_empty => | |
let x := strong_head ns _ in | |
let y := x - (strong_head ns _) in | |
y). | |
+ apply ns_not_empty. Abort. | |
(* Unshelve *) | |
Definition bug_fix : forall (ns : list nat) (idx : nat), (ns <> []) -> nat. | |
refine (fun ns idx ns_not_empty => | |
let x := strong_head ns _ in | |
let y := x - (strong_head ns _) in | |
y). | |
+ Unshelve. apply ns_not_empty. apply ns_not_empty. | |
Qed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment