Skip to content

Instantly share code, notes, and snippets.

@mankyKitty
Last active August 29, 2015 14:01
Show Gist options
  • Save mankyKitty/27693c0961361e76509b to your computer and use it in GitHub Desktop.
Save mankyKitty/27693c0961361e76509b to your computer and use it in GitHub Desktop.
Theorem identity_fn_applied_twice :
forall (f : bool -> bool),
(forall (x : bool), f x = x) -> forall (b : bool), f (f b) = b.
Proof.
intros f x b. (* Introduce our parameters *)
destruct b as [| b']. (* destruct b for possible values of b' <-- I don't use this and it worries me *)
rewrite -> x. (* rewrite f (f true) = true to f true = true *)
rewrite -> x. (* rewrite f true = true to true = true *)
reflexivity. (* solve the first subgoal above *)
rewrite -> x. (* rewrite f (f false) = false to f false = false *)
rewrite -> x. (* rewrite f false = false to false = false *)
reflexivity. (* solve the second subgoal above *)
Qed. (* victory for zim *)
(* better version ! *)
Theorem identity_fn_applied_twice :
forall (f : bool -> bool),
(forall (x : bool), f x = x) -> forall (b : bool), f (f b) = b.
Proof.
intros f H b.
rewrite -> H.
rewrite -> H.
reflexivity. Qed.
@domdere
Copy link

domdere commented May 21, 2014

Theorem identity_fn_applied_twice : 
  forall (f : bool -> bool),
    (forall (x : bool), f x = x) -> forall (b : bool), f (f b) = b.
Proof.
  intros f H b. (* Introduce our parameters *)
  rewrite -> H.
  apply H.
Qed.

@mankyKitty
Copy link
Author

Thanks ! :D

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