Debian Codegraph @

test-suite/success/Case22.v

raw
1 (* Check typing in the presence of let-in in inductive arity *)
2
3 Inductive I : let a := 1 in a=a -> let b := 2 in Type := C : I (eq_refl).
4 Lemma a : forall x:I eq_refl, match x in I a b c return b = b with C => eq_refl end = eq_refl.
5 intro.
6 match goal with |- ?c => let x := eval cbv in c in change x end.
7 Abort.
8
9 Check forall x:I eq_refl, match x in I x return x = x with C => eq_refl end = eq_refl.
10
11 (* This is bug #3210 *)
12
13 Inductive I' : let X := Set in X :=
14 | C' : I'.
15
16 Definition foo (x : I') : bool :=
17 match x with
18 C' => true
19 end.
20
21 (* Bug found in november 2015: was wrongly failing in 8.5beta2 and 8.5beta3 *)
22
23 Inductive I2 (A:Type) : let B:=A in forall C, let D:=(C*B)%type in Type :=
24 E2 : I2 A nat.
25
26 Check fun x:I2 nat nat => match x in I2 _ X Y Z return X*Y*Z with
27 E2 _ => (0,0,(0,0))
28 end.
29
30 (* This used to succeed in 8.3, 8.4 and 8.5beta1 *)
31
32 Inductive IND : forall X:Type, let Y:=X in Type :=
33 CONSTR : IND True.
34
35 Definition F (x:IND True) (A:Type) :=
36 (* This failed in 8.5beta2 though it should have been accepted *)
37 match x in IND X Y return Y with
38 CONSTR => Logic.I
39 end.
40
41 Theorem paradox : False.
42 (* This succeeded in 8.3, 8.4 and 8.5beta1 because F had wrong type *)
43 Fail Proof (F C False).
44 Abort.
45
46 (* Another bug found in November 2015 (a substitution was wrongly
47 reversed at pretyping level) *)
48
49 Inductive Ind (A:Type) :
50 let X:=A in forall Y:Type, let Z:=(X*Y)%type in Type :=
51 Constr : Ind A nat.
52
53 Check fun x:Ind bool nat =>
54 match x in Ind _ X Y Z return Z with
55 | Constr _ => (true,0)
56 end.
57
58 (* A vm_compute bug (the type of constructors was not supposed to
59 contain local definitions before proper parameters) *)
60
61 Inductive Ind2 (b:=1) (c:nat) : Type :=
62 Constr2 : Ind2 c.
63
64 Eval vm_compute in Constr2 2.
65
66 (* A bug introduced in ade2363 (similar to #5322 and #5324). This
67 commit started to see that some List.rev was wrong in the "var"
68 case of a pattern-matching problem but it failed to see that a
69 transformation from a list of arguments into a substitution was
70 still needed. *)
71
72 (* The order of real arguments was made wrong by ade2363 in the "var"
73 case of the compilation of "match" *)
74
75 Inductive IND2 : forall X Y:Type, Type :=
76 CONSTR2 : IND2 unit Empty_set.
77
78 Check fun x:IND2 bool nat =>
79 match x in IND2 a b return a with
80 | y => _
81 end = true.
82
83 (* From January 2017, using the proper function to turn arguments into
84 a substitution up to a context possibly containing let-ins, so that
85 the following, which was wrong also before ade2363, now works
86 correctly *)
87
88 Check fun x:Ind bool nat =>
89 match x in Ind _ X Y Z return Z with
90 | y => (true,0)
91 end.
92
93 (* A check that multi-implicit arguments work *)
94
95 Check fun x : {True}+{False} => match x with left _ _ => 0 | right _ _ => 1 end.
96 Check fun x : {True}+{False} => match x with left _ => 0 | right _ => 1 end.
97
98 (* Check that Asymmetric Patterns does not apply to the in clause *)
99
100 Inductive expr {A} : A -> Type := intro : forall {n:nat} (a:A), n=n -> expr a.
101 Check fun (x:expr true) => match x in expr n return n=n with intro _ _ => eq_refl end.
102 Set Asymmetric Patterns.
103 Check fun (x:expr true) => match x in expr n return n=n with intro _ a _ => eq_refl a end.
104 Unset Asymmetric Patterns.