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