Debian Codegraph @

test-suite/success/Discriminate_HoTT.v

raw
1 (* -*- mode: coq; coq-prog-args: ("-noinit" "-indices-matter") -*- *)
2
3 (* This file tests the discriminate tactic compatibility with HoTT.
4 The first part of the file will setup a mini HoTT environment.
5 Afterwards a number of tests are performed. The tests are basically
6 copied from the Discriminate.v test file. *)
7
8 Unset Elimination Schemes.
9
10 Set Universe Polymorphism.
11
12 Require Import Equality.
13
14 Declare ML Module "rocq-runtime.plugins.ltac".
15
16 Global Set Default Proof Mode "Classic".
17
18 Notation "x -> y" := (forall (_:x), y) (at level 99, right associativity, y at level 200).
19
20 Cumulative Variant paths {A} (a:A) : A -> Type
21 := idpath : paths a a.
22
23 Arguments idpath {A a} , [A] a.
24
25 Scheme paths_ind := Induction for paths Sort Type.
26 Arguments paths_ind [A] a P f y p : rename.
27
28 Notation "x = y :> A" := (@paths A x y) (at level 70, y at next level, no associativity).
29 Notation "x = y" := (x = y :>_) (at level 70, no associativity).
30
31 Register paths as core.identity.type.
32 Register idpath as core.identity.refl.
33 Register paths_ind as core.identity.ind.
34
35 Scheme paths_ind_nodep := Minimality for paths Sort Type.
36
37 Definition inverse {A : Type} {x y : A} (p : x = y) : y = x
38 := match p with idpath => idpath end.
39 Arguments inverse {A x y} p : simpl nomatch.
40 Register inverse as core.identity.sym.
41
42 Definition concat {A : Type} {x y z : A} (p : x = y) (q : y = z) : x = z :=
43 match p, q with idpath, idpath => idpath end.
44 Arguments concat {A x y z} p q : simpl nomatch.
45 Register concat as core.identity.trans.
46
47 Definition ap {A B:Type} (f:A -> B) {x y:A} (p:x = y) : f x = f y
48 := match p with idpath => idpath end.
49 Arguments ap {A B} f {x y} p.
50 Register ap as core.identity.congr.
51
52 Definition paths_Has_Leibniz_elim@{l l' l''} : Has_Leibniz@{Type Type Type;l l' l''} (@paths) :=
53 fun A x P t y e => match e with idpath => t end.
54
55 Hint Resolve paths_Has_Leibniz_elim : rewrite_instances.
56
57 Variant Empty : Type :=.
58
59 Register Empty as core.False.type.
60
61 Variant Unit : Type := tt.
62
63 Register Unit as core.True.type.
64 Register tt as core.True.I.
65
66 Variant Bool : Type := true | false.
67
68 Inductive nat : Type := O | S (n:nat).
69
70 (*********** Test discriminate tactic below. ***************)
71
72 Goal O = S O -> Empty.
73 discriminate 1.
74 Qed.
75
76 Goal forall H : O = S O, H = H.
77 discriminate H.
78 Qed.
79
80 Goal O = S O -> Unit.
81 intros. discriminate H. Qed.
82 Goal O = S O -> Unit.
83 intros. Ltac g x := discriminate x. g H. Qed.
84
85 Goal (forall x y : nat, x = y -> x = S y) -> Unit.
86 intros.
87 try discriminate (H O) || exact tt.
88 Qed.
89
90 Goal (forall x y : nat, x = y -> x = S y) -> Unit.
91 intros. ediscriminate (H O). instantiate (1:=O). Abort.
92
93 (* Check discriminate on types with local definitions *)
94
95 Inductive A := B (T := Unit) (x y : Bool) (z := x).
96 Goal forall x y, B x true = B y false -> Empty.
97 discriminate.
98 Qed.