| 1 |
Require Import TestSuite.admit. |
| 2 |
Section group_morphism. |
| 3 |
|
| 4 |
(* An example with default canonical structures *) |
| 5 |
|
| 6 |
Variable A B : Type. |
| 7 |
Variable plusA : A -> A -> A. |
| 8 |
Variable plusB : B -> B -> B. |
| 9 |
Variable zeroA : A. |
| 10 |
Variable zeroB : B. |
| 11 |
Variable eqA : A -> A -> Prop. |
| 12 |
Variable eqB : B -> B -> Prop. |
| 13 |
Variable phi : A -> B. |
| 14 |
|
| 15 |
Record img := { |
| 16 |
ia : A; |
| 17 |
ib :> B; |
| 18 |
prf : phi ia = ib |
| 19 |
}. |
| 20 |
|
| 21 |
Parameter eq_img : forall (i1:img) (i2:img), |
| 22 |
eqB (ib i1) (ib i2) -> eqA (ia i1) (ia i2). |
| 23 |
|
| 24 |
Lemma phi_img (a:A) : img. |
| 25 |
exists a (phi a). |
| 26 |
refine ( refl_equal _). |
| 27 |
Defined. |
| 28 |
Canonical Structure phi_img. |
| 29 |
|
| 30 |
Lemma zero_img : img. |
| 31 |
exists zeroA zeroB. |
| 32 |
admit. |
| 33 |
Defined. |
| 34 |
Canonical Structure zero_img. |
| 35 |
|
| 36 |
Lemma plus_img : img -> img -> img. |
| 37 |
intros i1 i2. |
| 38 |
exists (plusA (ia i1) (ia i2)) (plusB (ib i1) (ib i2)). |
| 39 |
admit. |
| 40 |
Defined. |
| 41 |
Canonical Structure plus_img. |
| 42 |
|
| 43 |
(* Print Canonical Projections. *) |
| 44 |
|
| 45 |
Goal forall a1 a2, eqA (plusA a1 zeroA) a2. |
| 46 |
intros a1 a2. |
| 47 |
refine (eq_img _ _ _). |
| 48 |
change (eqB (plusB (phi a1) zeroB) (phi a2)). |
| 49 |
Admitted. |
| 50 |
|
| 51 |
Variable foo : A -> Type. |
| 52 |
|
| 53 |
Definition local0 := fun (a1 : A) (a2 : A) (a3 : A) => |
| 54 |
(eq_refl : plusA a1 (plusA zeroA a2) = ia _). |
| 55 |
Definition local1 := |
| 56 |
fun (a1 : A) (a2 : A) (f : A -> A) => |
| 57 |
(eq_refl : plusA a1 (plusA zeroA (f a2)) = ia _). |
| 58 |
|
| 59 |
Definition local2 := |
| 60 |
fun (a1 : A) (f : A -> A) => |
| 61 |
(eq_refl : (f a1) = ia _). |
| 62 |
|
| 63 |
Goal forall a1 a2, eqA (plusA a1 zeroA) a2. |
| 64 |
intros a1 a2. |
| 65 |
refine (eq_img _ _ _). |
| 66 |
change (eqB (plusB (phi a1) zeroB) (phi a2)). |
| 67 |
Admitted. |
| 68 |
|
| 69 |
End group_morphism. |
| 70 |
|
| 71 |
Open Scope type_scope. |
| 72 |
|
| 73 |
Section type_reification. |
| 74 |
|
| 75 |
Inductive term :Type := |
| 76 |
Fun : term -> term -> term |
| 77 |
| Prod : term -> term -> term |
| 78 |
| Bool : term |
| 79 |
| SET :term |
| 80 |
| PROP :term |
| 81 |
| TYPE :term |
| 82 |
| Var : Type -> term. |
| 83 |
|
| 84 |
Fixpoint interp (t:term) := |
| 85 |
match t with |
| 86 |
Bool => bool |
| 87 |
| SET => Set |
| 88 |
| PROP => Prop |
| 89 |
| TYPE => Type |
| 90 |
| Fun a b => interp a -> interp b |
| 91 |
| Prod a b => interp a * interp b |
| 92 |
| Var x => x |
| 93 |
end. |
| 94 |
|
| 95 |
Record interp_pair :Type := |
| 96 |
{ repr:>term; |
| 97 |
abs:>Type; |
| 98 |
link: abs = interp repr }. |
| 99 |
|
| 100 |
Lemma prod_interp :forall (a b:interp_pair),a * b = interp (Prod a b) . |
| 101 |
Proof. |
| 102 |
intros a b. |
| 103 |
change (a * b = interp a * interp b). |
| 104 |
rewrite (link a), (link b); reflexivity. |
| 105 |
Qed. |
| 106 |
|
| 107 |
Lemma fun_interp :forall (a b:interp_pair), (a -> b) = interp (Fun a b). |
| 108 |
Proof. |
| 109 |
intros a b. |
| 110 |
change ((a -> b) = (interp a -> interp b)). |
| 111 |
rewrite (link a), (link b); reflexivity. |
| 112 |
Qed. |
| 113 |
|
| 114 |
Canonical Structure ProdCan (a b:interp_pair) := |
| 115 |
Build_interp_pair (Prod a b) (a * b) (prod_interp a b). |
| 116 |
|
| 117 |
Canonical Structure FunCan (a b:interp_pair) := |
| 118 |
Build_interp_pair (Fun a b) (a -> b) (fun_interp a b). |
| 119 |
|
| 120 |
Canonical Structure BoolCan := |
| 121 |
Build_interp_pair Bool bool (refl_equal _). |
| 122 |
|
| 123 |
Canonical Structure VarCan (x:Type) := |
| 124 |
Build_interp_pair (Var x) x (refl_equal _). |
| 125 |
|
| 126 |
Canonical Structure SetCan := |
| 127 |
Build_interp_pair SET Set (refl_equal _). |
| 128 |
|
| 129 |
Canonical Structure PropCan := |
| 130 |
Build_interp_pair PROP Prop (refl_equal _). |
| 131 |
|
| 132 |
Canonical Structure TypeCan := |
| 133 |
Build_interp_pair TYPE Type (refl_equal _). |
| 134 |
|
| 135 |
(* Print Canonical Projections. *) |
| 136 |
|
| 137 |
Variable A:Type. |
| 138 |
|
| 139 |
Variable Inhabited: term -> Prop. |
| 140 |
|
| 141 |
Variable Inhabited_correct: forall p, Inhabited (repr p) -> abs p. |
| 142 |
|
| 143 |
Lemma L : Prop * A -> bool * (Type -> Set) . |
| 144 |
refine (Inhabited_correct _ _). |
| 145 |
change (Inhabited (Fun (Prod PROP (Var A)) (Prod Bool (Fun TYPE SET)))). |
| 146 |
Admitted. |
| 147 |
|
| 148 |
Check L : abs _ . |
| 149 |
|
| 150 |
End type_reification. |