| 1 |
Require Import Corelib.Classes.Morphisms. |
| 2 |
Require Import Corelib.Setoids.Setoid. |
| 3 |
|
| 4 |
Definition T := nat. |
| 5 |
Axiom MT : Type. |
| 6 |
Axiom ret : T -> MT. |
| 7 |
Axiom bind : MT -> (T -> MT) -> MT. |
| 8 |
Axiom bind_bind : forall x f1 f2, bind (bind x f1) f2 = bind x (fun x => bind (f1 x) f2). |
| 9 |
Axiom bind_ret : forall x f, bind (ret x) f = f x. |
| 10 |
Reserved Notation "A <- X ; B" (at level 70, X at next level, right associativity, format "'[v' A <- X ; '/' B ']'"). |
| 11 |
Notation "v <- x ; f" := (bind x (fun v => f)). |
| 12 |
Axiom bind_Proper : Proper (eq ==> (eq ==> eq) ==> eq) bind. |
| 13 |
Axiom bind_Proper' : Proper (eq ==> pointwise_relation _ eq ==> eq) bind. |
| 14 |
#[export] Existing Instances bind_Proper bind_Proper'. |
| 15 |
|
| 16 |
Module Thunked. |
| 17 |
Definition nat_rect P (O_case : unit -> P) (S_case : nat -> P -> P) (n : nat) : P |
| 18 |
:= Datatypes.nat_rect (fun _ => P) (O_case tt) S_case n. |
| 19 |
End Thunked. |
| 20 |
|
| 21 |
Definition make_binds_assoc_def (n : nat) (v : MT) := |
| 22 |
@Thunked.nat_rect |
| 23 |
MT |
| 24 |
(fun _ => v) |
| 25 |
(fun _ rec => bind rec (fun x => ret x)) |
| 26 |
n. |
| 27 |
|
| 28 |
Lemma foo : |
| 29 |
let n := 2%nat in |
| 30 |
forall v, make_binds_assoc_def n v = make_binds_assoc_def n v. |
| 31 |
Proof. |
| 32 |
cbv [make_binds_assoc_def]. |
| 33 |
intros. |
| 34 |
rewrite_strat ((eval cbv [Thunked.nat_rect nat_rect]); (topdown bind_bind)). |
| 35 |
reflexivity. |
| 36 |
Qed. |