| 1 |
Require Import ssreflect. |
| 2 |
|
| 3 |
Generalizable Variables A B. |
| 4 |
|
| 5 |
Class Inhab (A:Type) : Type := |
| 6 |
{ arbitrary : A }. |
| 7 |
|
| 8 |
Lemma test_intro_typeclass_1 : forall A `{Inhab A} (x:A), x = arbitrary -> x = arbitrary. |
| 9 |
Proof. |
| 10 |
move =>> H. (* introduces [H:x=arbitrary] because first non dependent hypothesis *) |
| 11 |
Abort. |
| 12 |
|
| 13 |
Lemma test_intro_typeclass_2 : forall A `{Inhab A} (l1 l2:list A), l2 = nil -> app l1 l2 = l1. |
| 14 |
Proof. |
| 15 |
move =>> H. (* introduces [Inhab A] automatically because it is a typeclass instance *) |
| 16 |
Abort. |
| 17 |
|
| 18 |
Lemma test_intro_typeclass_3 : forall `{Inhab A, Inhab B} (x:A) (y:B), True -> x = x. |
| 19 |
Proof. (* Above types [A] and [B] are implicitly quantified *) |
| 20 |
move =>> y H. (* introduces the two typeclass instances automatically *) |
| 21 |
Abort. |
| 22 |
|
| 23 |
Class Foo `{Inhab A} : Type := |
| 24 |
{ foo : A }. |
| 25 |
|
| 26 |
Lemma test_intro_typeclass_4 : forall `{Foo A}, True -> True. |
| 27 |
Proof. (* Above, [A] and [{Inhab A}] are implicitly quantified *) |
| 28 |
move =>> H. (* introduces [A] and [Inhab A] because they are dependently used, |
| 29 |
and introduce [Foo A] automatically because it is an instance. *) |
| 30 |
Abort. |