Skip to content

Instantly share code, notes, and snippets.

@einblicker
Created April 3, 2012 06:38
Show Gist options
  • Save einblicker/2289811 to your computer and use it in GitHub Desktop.
Save einblicker/2289811 to your computer and use it in GitHub Desktop.
hungry functionにいくら自然数を食わせてもhungryなままであることを証明
Section HungryIsImmutable.
CoInductive hungry := h : (nat -> hungry) -> hungry.
CoFixpoint f := h (fun _ => f).
Definition unH x :=
match x with
| h f => f
end.
Infix "$" := unH (at level 120).
Fixpoint mkHungry n :=
match n with
| O => f $ O
| S m => mkHungry m $ S m
end.
Theorem hungryIsImmutable : forall n, mkHungry n = f.
Proof.
induction n; [ | simpl; rewrite IHn ]; reflexivity.
Qed.
End HungryIsImmutable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment