Last active
September 20, 2022 16:54
-
-
Save roboguy13/f8c07fbad0e019f4f9896020e73d00a5 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
(* https://twitter.com/codydroux/status/1570158204243288066 *) | |
Section Iter_to_ind. | |
Variable B : Prop. | |
Variable F : Prop -> Prop. | |
(* F is a monad *) | |
Variable fmap : forall (a b : Prop), (a -> b) -> F a -> F b. | |
Variable pure : forall (a : Prop), a -> F a. | |
Variable join : forall a, F (F a) -> F a. | |
Fixpoint iter_prop (n : nat) : Prop := | |
match n with | |
| 0 => B | |
| S m => F (iter_prop m) | |
end. | |
Definition ind_prop : nat -> Prop := | |
fun n => | |
forall P : nat -> Prop, | |
(B -> P 0) -> | |
(forall m, F (P m) -> P (S m)) -> | |
P n. | |
Lemma ind_to_iter : forall n, ind_prop n -> iter_prop n. | |
Proof. | |
induction n; unfold ind_prop; simpl; intros; apply (H (fun n => iter_prop n)); auto. | |
Qed. | |
Lemma iter_to_ind : forall n, iter_prop n -> ind_prop n. | |
Proof. | |
intros. | |
induction n. | |
- intro. intros. apply H0. simpl in H. assumption. | |
- intro. intros. simpl in H. apply H1. | |
destruct n. | |
+ simpl in H. simpl in IHn. apply (fmap B); assumption. | |
+ pose (H1 n). | |
apply IHn. | |
apply join. apply H. | |
intro. | |
apply pure. | |
apply H0. assumption. | |
intros. | |
apply pure. | |
apply H1. | |
apply join. apply H2. | |
Qed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment