Skip to content

Instantly share code, notes, and snippets.

@gebner
Created February 15, 2017 12:50
Show Gist options
  • Save gebner/63b74d6fffaec1ae4766de758a76bd77 to your computer and use it in GitHub Desktop.
Save gebner/63b74d6fffaec1ae4766de758a76bd77 to your computer and use it in GitHub Desktop.
-- standard setup
lemma they_are_isomorphic (x : false) : ℕ = (ℕ × ℕ) :=
by contradiction
def repack (x : unit → false) (y : ℕ) : ℕ × ℕ :=
cast (they_are_isomorphic (x ())) y
def proj_nat (x : unit → false) : ℕ → ℕ :=
prod.fst ∘ repack x
-- now the new fun begins
def long_computation : ℕ → list ℕ
| 0 := [1,2,3]
| (n+1) := (long_computation n)^.reverse
vm_eval try_for 1 (long_computation 1000) -- none
-- but the kernel says something else:
meta example : try_for 1 (long_computation 1000) = some [1,2,3] := rfl
meta def crash (n : ℕ) : ℕ :=
let x := try_for 1 (long_computation 1000) in
if h : x = none then
proj_nat (by contradiction) 4
else
42
vm_eval crash 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment