| 1 |
Inductive Inner : Type := |
| 2 |
| innerI_nat : forall (x:nat), Inner |
| 3 |
| innerI_fun : forall (f:nat->Type), Inner |
| 4 |
| innerI_inner : forall (i:Inner), Inner |
| 5 |
| innerI_Type : forall (T:Type), Inner |
| 6 |
| innerI_extra : Inner. |
| 7 |
|
| 8 |
Inductive ExtractTest (A:Type) (F:nat->Type) (I:Inner): Inner -> Inner -> unit -> Type := |
| 9 |
| extract_f_x_from_index : forall (x:nat) (f:nat->Type) (t:f x), |
| 10 |
ExtractTest A F I (innerI_inner (innerI_nat x)) (innerI_fun f) tt |
| 11 |
| extract_F_from_param_x_from_index : forall (x:nat) (f:nat->Type) (t:F x), |
| 12 |
ExtractTest A F I (innerI_inner (innerI_nat x)) innerI_extra tt |
| 13 |
| extract_fail : forall (x y: nat) (f : nat -> Type) (t : f x), |
| 14 |
ExtractTest A F I (innerI_nat y) (innerI_fun f) tt |
| 15 |
| extract_fx_from_index : forall (x:nat) (f:nat->Type) (t:f x), |
| 16 |
ExtractTest A F I (innerI_Type (f x)) innerI_extra tt |
| 17 |
| extract_t_match : forall (b:bool) (t:if b then unit else nat), |
| 18 |
ExtractTest A F I (innerI_Type (if b then unit else nat)) innerI_extra tt |
| 19 |
. |
| 20 |
|
| 21 |
(* This still dosn't work, because the fields type isn't composeable from extracteable parts of its inductive type.*) |
| 22 |
Lemma test_extract_fail A F x y f t1 t2 : extract_fail A F innerI_extra x y f t1 = extract_fail A F innerI_extra x y f t2 -> t1 = t2. |
| 23 |
Proof. |
| 24 |
Fail congruence. |
| 25 |
Abort. |
| 26 |
|
| 27 |
(* I think this should also work when the whole match statement is part of the inductive type, but something with universes is wrong because A is Type but if b then unit else nat is Set below is the projection that is getting created but it doesn't work *) |
| 28 |
Lemma test_extract_t_match_success (A:Set) (F:nat->Type) (b:bool) (t1 t2: if b then unit else nat) : |
| 29 |
extract_t_match A F innerI_extra b t1 = extract_t_match A F innerI_extra b t2 -> t1 = t2. |
| 30 |
Proof. |
| 31 |
intros H. |
| 32 |
Fail congruence. |
| 33 |
Abort. |
| 34 |
|
| 35 |
|
| 36 |
Fail Definition proj (A:Type) (F:nat->Type) (b:bool) (t1:if b then unit else nat):= |
| 37 |
(fun |
| 38 |
e : ExtractTest A F innerI_extra |
| 39 |
(innerI_Type (if b then unit else nat)) innerI_extra tt => |
| 40 |
match |
| 41 |
e in (ExtractTest _ _ _ i i0 u) |
| 42 |
return |
| 43 |
(match i with |
| 44 |
| innerI_Type T => T |
| 45 |
| _ => if b then unit else nat |
| 46 |
end -> |
| 47 |
match i with |
| 48 |
| innerI_Type T => T |
| 49 |
| _ => if b then unit else nat |
| 50 |
end) |
| 51 |
with |
| 52 |
| extract_f_x_from_index _ _ _ x f _ => |
| 53 |
fun |
| 54 |
t : match innerI_inner (innerI_nat x) with |
| 55 |
| innerI_Type T => T |
| 56 |
| _ => if b then unit else nat |
| 57 |
end => |
| 58 |
t |
| 59 |
| extract_F_from_param_x_from_index _ _ _ x _ _ => |
| 60 |
fun |
| 61 |
t : match innerI_inner (innerI_nat x) with |
| 62 |
| innerI_Type T => T |
| 63 |
| _ => if b then unit else nat |
| 64 |
end => |
| 65 |
t |
| 66 |
| extract_fail _ _ _ x y f _ => |
| 67 |
fun |
| 68 |
t : match innerI_nat y with |
| 69 |
| innerI_Type T => T |
| 70 |
| _ => if b then unit else nat |
| 71 |
end => |
| 72 |
t |
| 73 |
| extract_fx_from_index _ _ _ x f _ => |
| 74 |
fun |
| 75 |
t : match innerI_Type (f x) with |
| 76 |
| innerI_Type T => T |
| 77 |
| _ => if b then unit else nat |
| 78 |
end => |
| 79 |
t |
| 80 |
| extract_t_match _ _ _ b0 t => |
| 81 |
fun |
| 82 |
_ : match innerI_Type (if b0 then unit else nat) with |
| 83 |
| innerI_Type T => T |
| 84 |
| _ => if b then unit else nat |
| 85 |
end => |
| 86 |
t |
| 87 |
end t1). |