]> matita.cs.unibo.it Git - helm.git/blob - helm/matita/contribs/LAMBDA-TYPES/tlt_defs.ma
ocaml 3.09 transition
[helm.git] / helm / matita / contribs / LAMBDA-TYPES / tlt_defs.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 set "baseuri" "cic:/matita/LAMBDA-TYPES/tlt_defs".
16
17 include "terms_defs.ma".
18
19 definition wadd: (nat \to nat) \to nat \to (nat \to nat) \def 
20    \lambda map,w,n.
21    match n with [
22         O     \Rightarrow w
23       | (S m) \Rightarrow (map m)
24    ].
25
26 let rec weight_map (A:Set) (N:Set) (map:nat \to nat) (t:T A N) on t : nat \def 
27    match t with [
28         (TSort y k)     \Rightarrow O
29       | (TLRef y i)     \Rightarrow (map i)
30       | (TWag y z w u) \Rightarrow
31          match z with [
32               (Bind b) \Rightarrow
33                  match b with [
34                       Abbr \Rightarrow
35                         (S ((weight_map A N map w) + (weight_map A N (wadd map (S (weight_map A N map w))) u)))
36                     | Abst \Rightarrow 
37                         (S ((weight_map A N map w) + (weight_map A N (wadd map O) u)))
38                     | Void \Rightarrow 
39                         (S ((weight_map A N map w) + (weight_map A N (wadd map O) u)))
40                  ]
41             | (Flat a) \Rightarrow
42                  (S ((weight_map A N map w) + (weight_map A N map u)))
43          ]
44       | (TGRef y n)     \Rightarrow O
45   ].
46
47 definition weight: \forall A,N. T A N \to nat \def 
48    \lambda A,N. 
49    (weight_map A N (\lambda _.O)).
50
51 definition tlt: \forall A,N. T A N \to T A N \to Prop \def 
52    \lambda A,N,t1,t2. 
53    weight A N t1 < weight A N t2.