]> matita.cs.unibo.it Git - helm.git/blob - weblib/hints_declaration.ma
grafite parser updated
[helm.git] / weblib / hints_declaration.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 (* 
16
17 Notation for hint declaration
18 ==============================
19
20 The idea is to write a context, with abstraction first, then
21 recursive calls (let-in) and finally the two equivalent terms.
22 The context can be empty. Note the ; to begin the second part of
23 the context (necessary even if the first part is empty). 
24
25  unification hint PREC \coloneq
26    ID : TY, ..., ID : TY
27    ; ID \equest T, ..., ID \equest T
28    \vdash T1 \equiv T2       
29
30 With unidoce and some ASCII art it looks like the following:
31
32  unification hint PREC ≔ ID : TY, ..., ID : TY;
33     ID ≟ T, ..., ID ≟ T
34  (*---------------------*) ⊢
35          T1 ≡ T2       
36
37 The order of premises is relevant, since they are processed in order
38 (left to right).
39
40 *)
41    
42 (* it seems unbelivable, but it works! *)
43 notation > "≔ (list0 ( (list1 (ident x) sep , ) opt (: T) ) sep ,) opt (; (list1 (ident U ≟ term 19 V ) sep ,)) ⊢ term 19 Px ≡ term 19 Py"
44   with precedence 90
45   for @{ ${ fold right 
46                @{ ${ default 
47                     @{ ${ fold right 
48                         @{ 'hint_decl $Px $Py } 
49                         rec acc1 @{ let ( ${ident U} : ?) ≝ $V in $acc1} } }
50                     @{ 'hint_decl $Px $Py } 
51                  }
52                } 
53                rec acc @{ 
54                  ${ fold right @{ $acc } rec acc2 
55                       @{ ∀${ident x}:${ default @{ $T } @{ ? } }.$acc2 } } 
56                }
57        }}.
58
59 include "basics/pts.ma".
60
61 \ 5img class="anchor" src="icons/tick.png" id="hint_declaration_Type0"\ 6definition hint_declaration_Type0  ≝  λA:Type[0] .λa,b:A.Prop.
62 \ 5img class="anchor" src="icons/tick.png" id="hint_declaration_Type1"\ 6definition hint_declaration_Type1  ≝  λA:Type[1].λa,b:A.Prop.
63 \ 5img class="anchor" src="icons/tick.png" id="hint_declaration_Type2"\ 6definition hint_declaration_Type2  ≝  λa,b:Type[2].Prop.
64 \ 5img class="anchor" src="icons/tick.png" id="hint_declaration_CProp0"\ 6definition hint_declaration_CProp0 ≝  λA:CProp[0].λa,b:A.Prop.
65 \ 5img class="anchor" src="icons/tick.png" id="hint_declaration_CProp1"\ 6definition hint_declaration_CProp1 ≝  λA:CProp[1].λa,b:A.Prop.
66 \ 5img class="anchor" src="icons/tick.png" id="hint_declaration_CProp2"\ 6definition hint_declaration_CProp2 ≝  λa,b:CProp[2].Prop.
67   
68 interpretation "hint_decl_Type2"  'hint_decl a b = (hint_declaration_Type2 a b).
69 interpretation "hint_decl_CProp2" 'hint_decl a b = (hint_declaration_CProp2 a b).
70 interpretation "hint_decl_Type1"  'hint_decl a b = (hint_declaration_Type1 ? a b).
71 interpretation "hint_decl_CProp1" 'hint_decl a b = (hint_declaration_CProp1 ? a b).
72 interpretation "hint_decl_CProp0" 'hint_decl a b = (hint_declaration_CProp0 ? a b).
73 interpretation "hint_decl_Type0"  'hint_decl a b = (hint_declaration_Type0 ? a b).
74
75 (* Non uniform coercions support
76 record solution2 (S : Type[2]) (s : S) : Type[3] ≝ {
77   target2 : Type[2];
78   result2  : target2
79 }.
80
81 record solution1 (S : Type[1]) (s : S) : Type[2] ≝ {
82   target1 : Type[1];
83   result1  : target1
84 }.
85
86 coercion nonunifcoerc1 : ∀S:Type[1].∀s:S.∀l:solution1 S s. target1 S s l ≝ result1 
87  on s : ? to target1 ???.
88
89 coercion nonunifcoerc2 : ∀S:Type[2].∀s:S.∀l:solution2 S s. target2 S s l ≝ result2
90  on s : ? to target2 ???.
91 *)
92
93 (* Example of a non uniform coercion declaration 
94    
95      Type[0]              setoid
96                 >--->     
97      MR                   R  
98
99    provided MR = carr R
100
101 unification hint 0 ≔ R : setoid;
102    MR ≟ carr R, 
103    sol ≟ mk_solution1 Type[0] MR setoid R 
104 (* ---------------------------------------- *) ⊢ 
105    setoid ≡ target1 ? MR sol.
106
107 *)