summaryrefslogtreecommitdiff
path: root/test-suite/typeclasses/clrewrite.v
blob: 2978fda26659bdea9d992eb056f2b4ec19959dd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111

Set Implicit Arguments.
Unset Strict Implicit.

Require Import Coq.Classes.Equivalence.

Section Equiv.
  Context [ Equivalence A eqA ].

  Variables x y z w : A.

  Goal eqA x y -> eqA y x.
    intros H ; clrewrite H.
    refl.
  Qed.

  Tactic Notation "simpl" "*" := auto || relation_tac.
  
  Goal eqA x y -> eqA y x /\ True.
    intros H ; clrewrite H.
    split ; simpl*.
  Qed.

  Goal eqA x y -> eqA y x /\ eqA x x.
    intros H ; clrewrite H.
    split ; simpl*.
  Qed.

  Goal eqA x y -> eqA y z -> eqA x y.
    intros H. 
    clrewrite H.
    intro. refl.
  Qed.
        
  Goal eqA x y -> eqA z y -> eqA x y.
    intros H. 
    clrewrite <- H at 2.
    clrewrite <- H at 1.
    intro. refl.
  Qed.

  Opaque complement.

  Print iff_inverse_impl_binary_morphism.

  Goal eqA x y -> eqA x y -> eqA x y.
    intros H.
    clrewrite H.
    intro. refl.
  Qed.

  Goal eqA x y -> eqA x y -> eqA x y.
    intros H.
    clrewrite <- H.
    refl.
  Qed.
  
  Goal eqA x y -> True /\ True /\ False /\ eqA x x -> True /\ True /\ False /\ eqA x y.
  Proof.
    intros.
    clrewrite <- H.
    apply H0.
  Qed.

End Equiv.

Section Trans.
  Context [ Transitive A R ].

  Variables x y z w : A.

  Tactic Notation "simpl" "*" := auto || relation_tac.
  
(*   Typeclasses eauto := debug. *)

  Goal R x y -> R y x -> R y y -> R x x.
  Proof with auto.
    intros H H' H''. 

    clrewrite <- H' at 2.
    clrewrite H at 1...
  Qed.

  Goal R x y -> R y z -> R x z.
    intros H.
    clrewrite H.
    refl.
  Qed.
        
  Goal R x y -> R z y -> R x y.
    intros H. 
    clrewrite <- H at 2.
    intro. 
    clrewrite H at 1.
  Abort.

  Goal R x y -> True /\ R y z -> True /\ R x z.
  Proof.
    intros.
    clrewrite H.
    apply H0.
  Qed.

  Goal R x y -> True /\ True /\ False /\ R y z -> True /\ True /\ False /\ R x z.
  Proof.
    intros.
    clrewrite H.
    apply H0.
  Qed.

End Trans.