]> matita.cs.unibo.it Git - helm.git/blob - helm/software/components/ng_disambiguation/nCicDisambiguate.ml
4e3f8cac3e265aa362253b2dd47e440bfa97705e
[helm.git] / helm / software / components / ng_disambiguation / nCicDisambiguate.ml
1 (*
2     ||M||  This file is part of HELM, an Hypertextual, Electronic        
3     ||A||  Library of Mathematics, developed at the Computer Science     
4     ||T||  Department, University of Bologna, Italy.                     
5     ||I||                                                                
6     ||T||  HELM is free software; you can redistribute it and/or         
7     ||A||  modify it under the terms of the GNU General Public License   
8     \   /  version 2 or (at your option) any later version.      
9      \ /   This software is distributed as is, NO WARRANTY.     
10       V_______________________________________________________________ *)
11
12 (* $Id: nCic.ml 9058 2008-10-13 17:42:30Z tassi $ *)
13
14 open Printf
15
16 open DisambiguateTypes
17 open UriManager
18
19 module Ast = CicNotationPt
20 module NRef = NReference 
21
22 let debug_print _ = ();;
23 (* let debug_print s = prerr_endline (Lazy.force s);; *)
24
25 let cic_name_of_name = function
26   | Ast.Ident (n, None) ->  n
27   | _ -> assert false
28 ;;
29
30 let refine_term 
31  metasenv subst context uri ~coercion_db ~use_coercions term _ ~localization_tbl=
32   assert (uri=None);
33   debug_print (lazy (sprintf "TEST_INTERPRETATION: %s" 
34     (NCicPp.ppterm ~metasenv ~subst ~context term)));
35   try
36     let localise t = 
37       try NCicUntrusted.NCicHash.find localization_tbl t
38       with Not_found -> 
39         prerr_endline (NCicPp.ppterm ~metasenv ~subst ~context t);
40         assert false
41     in
42     let metasenv, subst, term, _ = 
43       NCicRefiner.typeof
44         (NCicUnifHint.db ())
45         ~look_for_coercion:(
46           if use_coercions then 
47            NCicCoercion.look_for_coercion coercion_db
48           else (fun _ _ _ _ _ -> []))
49         metasenv subst context term None ~localise 
50     in
51      Disambiguate.Ok (term, metasenv, subst, ())
52   with
53   | NCicRefiner.Uncertain loc_msg ->
54       debug_print (lazy ("UNCERTAIN: [" ^ snd (Lazy.force loc_msg) ^ "] " ^ 
55         NCicPp.ppterm ~metasenv ~subst ~context term)) ;
56       Disambiguate.Uncertain loc_msg
57   | NCicRefiner.RefineFailure loc_msg ->
58       debug_print (lazy (sprintf "PRUNED:\nterm%s\nmessage:%s"
59         (NCicPp.ppterm ~metasenv ~subst ~context term) (snd(Lazy.force loc_msg))));
60       Disambiguate.Ko loc_msg
61 ;;
62
63   (* TODO move it to Cic *)
64 let find_in_context name context =
65   let rec aux acc = function
66     | [] -> raise Not_found
67     | hd :: _ when hd = name -> acc
68     | _ :: tl ->  aux (acc + 1) tl
69   in
70   aux 1 context
71
72 let interpretate_term_and_interpretate_term_option 
73   ?(create_dummy_ids=false) 
74     ~obj_context ~mk_choice ~env ~uri ~is_path ~localization_tbl 
75 =
76   (* create_dummy_ids shouldbe used only for interpretating patterns *)
77   assert (uri = None);
78
79   let rec aux ~localize loc context = function
80     | CicNotationPt.AttributedTerm (`Loc loc, term) ->
81         let res = aux ~localize loc context term in
82         if localize then 
83          NCicUntrusted.NCicHash.add localization_tbl res loc;
84        res
85     | CicNotationPt.AttributedTerm (_, term) -> aux ~localize loc context term
86     | CicNotationPt.Appl (CicNotationPt.Symbol (symb, i) :: args) ->
87         let cic_args = List.map (aux ~localize loc context) args in
88         Disambiguate.resolve ~mk_choice ~env (Symbol (symb, i)) (`Args cic_args)
89     | CicNotationPt.Appl terms ->
90        NCic.Appl (List.map (aux ~localize loc context) terms)
91     | CicNotationPt.Binder (binder_kind, (var, typ), body) ->
92         let cic_type = aux_option ~localize loc context `Type typ in
93         let cic_name = cic_name_of_name var  in
94         let cic_body = aux ~localize loc (cic_name :: context) body in
95         (match binder_kind with
96         | `Lambda -> NCic.Lambda (cic_name, cic_type, cic_body)
97         | `Pi
98         | `Forall -> NCic.Prod (cic_name, cic_type, cic_body)
99         | `Exists ->
100             Disambiguate.resolve ~env ~mk_choice (Symbol ("exists", 0))
101               (`Args [ cic_type; NCic.Lambda (cic_name, cic_type, cic_body) ]))
102     | CicNotationPt.Case (term, indty_ident, outtype, branches) ->
103         let cic_term = aux ~localize loc context term in
104         let cic_outtype = aux_option ~localize loc context `Term outtype in
105         let do_branch ((_, _, args), term) =
106          let rec do_branch' context = function
107            | [] -> aux ~localize loc context term
108            | (name, typ) :: tl ->
109                let cic_name = cic_name_of_name name in
110                let cic_body = do_branch' (cic_name :: context) tl in
111                let typ =
112                  match typ with
113                  | None -> NCic.Implicit `Type
114                  | Some typ -> aux ~localize loc context typ
115                in
116                NCic.Lambda (cic_name, typ, cic_body)
117          in
118           do_branch' context args
119         in
120         if create_dummy_ids then
121          let branches =
122           List.map
123            (function
124                Ast.Wildcard,term -> ("wildcard",None,[]), term
125              | Ast.Pattern _,_ ->
126                 raise (DisambiguateTypes.Invalid_choice 
127                  (lazy (loc, "Syntax error: the left hand side of a "^
128                    "branch pattern must be \"_\"")))
129            ) branches
130          in
131          (*
132           NCic.MutCase (ref, cic_outtype, cic_term,
133             (List.map do_branch branches))
134           *) ignore branches; assert false (* patterns not implemented yet *)
135         else
136          let indtype_ref =
137           match indty_ident with
138           | Some (indty_ident, _) ->
139              (match Disambiguate.resolve ~env ~mk_choice 
140                 (Id indty_ident) (`Args []) with
141               | NCic.Const (NReference.Ref (_,NReference.Ind _) as r) -> r
142               | NCic.Implicit _ ->
143                  raise (Disambiguate.Try_again 
144                   (lazy "The type of the term to be matched is still unknown"))
145               | t ->
146                 raise (DisambiguateTypes.Invalid_choice 
147                   (lazy (loc,"The type of the term to be matched "^
148                           "is not (co)inductive: " ^ NCicPp.ppterm 
149                           ~metasenv:[] ~subst:[] ~context:[] t))))
150           | None ->
151               let rec fst_constructor =
152                 function
153                    (Ast.Pattern (head, _, _), _) :: _ -> head
154                  | (Ast.Wildcard, _) :: tl -> fst_constructor tl
155                  | [] -> raise (Invalid_choice (lazy (loc,"The type "^
156                      "of the term to be matched cannot be determined "^
157                      "because it is an inductive type without constructors "^
158                      "or because all patterns use wildcards")))
159               in
160 (*
161               DisambiguateTypes.Environment.iter
162                   (fun k v ->
163                       prerr_endline
164                         (DisambiguateTypes.string_of_domain_item k ^ " => " ^
165                         description_of_alias v)) env; 
166 *)
167               (match Disambiguate.resolve ~env ~mk_choice
168                 (Id (fst_constructor branches)) (`Args []) with
169               | NCic.Const (NReference.Ref (_,NReference.Con _) as r) -> 
170                    let b,_,_,_,_ = NCicEnvironment.get_checked_indtys r in
171                    NReference.mk_indty b r
172               | NCic.Implicit _ ->
173                  raise (Disambiguate.Try_again 
174                   (lazy "The type of the term to be matched is still unknown"))
175               | t ->
176                 raise (DisambiguateTypes.Invalid_choice 
177                   (lazy (loc, 
178                   "The type of the term to be matched is not (co)inductive: " 
179                   ^ NCicPp.ppterm ~metasenv:[] ~subst:[] ~context:[] t))))
180          in
181          let _,leftsno,itl,_,indtyp_no =
182           NCicEnvironment.get_checked_indtys indtype_ref in
183          let _,_,_,cl =
184           try
185            List.nth itl indtyp_no
186           with _ -> assert false in
187          let rec count_prod t =
188                  match NCicReduction.whd ~subst:[] [] t with
189                NCic.Prod (_, _, t) -> 1 + (count_prod t)
190              | _ -> 0 
191          in 
192          let rec sort branches cl =
193           match cl with
194              [] ->
195               let rec analyze unused unrecognized useless =
196                function
197                   [] ->
198                    if unrecognized != [] then
199                     raise (DisambiguateTypes.Invalid_choice
200                      (lazy
201                        (loc,"Unrecognized constructors: " ^
202                         String.concat " " unrecognized)))
203                    else if useless > 0 then
204                     raise (DisambiguateTypes.Invalid_choice
205                      (lazy
206                        (loc,"The last " ^ string_of_int useless ^
207                         "case" ^ if useless > 1 then "s are" else " is" ^
208                         " unused")))
209                    else
210                     []
211                 | (Ast.Wildcard,_)::tl when not unused ->
212                     analyze true unrecognized useless tl
213                 | (Ast.Pattern (head,_,_),_)::tl when not unused ->
214                     analyze unused (head::unrecognized) useless tl
215                 | _::tl -> analyze unused unrecognized (useless + 1) tl
216               in
217                analyze false [] 0 branches
218            | (_,name,ty)::cltl ->
219               let rec find_and_remove =
220                function
221                   [] ->
222                    raise
223                     (DisambiguateTypes.Invalid_choice
224                      (lazy (loc, "Missing case: " ^ name)))
225                 | ((Ast.Wildcard, _) as branch :: _) as branches ->
226                     branch, branches
227                 | (Ast.Pattern (name',_,_),_) as branch :: tl
228                    when name = name' ->
229                     branch,tl
230                 | branch::tl ->
231                    let found,rest = find_and_remove tl in
232                     found, branch::rest
233               in
234                let branch,tl = find_and_remove branches in
235                match branch with
236                   Ast.Pattern (name,y,args),term ->
237                    if List.length args = count_prod ty - leftsno then
238                     ((name,y,args),term)::sort tl cltl
239                    else
240                     raise
241                      (DisambiguateTypes.Invalid_choice
242                       (lazy (loc,"Wrong number of arguments for " ^ name)))
243                 | Ast.Wildcard,term ->
244                    let rec mk_lambdas =
245                     function
246                        0 -> term
247                      | n ->
248                         CicNotationPt.Binder
249                          (`Lambda, (CicNotationPt.Ident ("_", None), None),
250                            mk_lambdas (n - 1))
251                    in
252                     (("wildcard",None,[]),
253                      mk_lambdas (count_prod ty - leftsno)) :: sort tl cltl
254          in
255           let branches = sort branches cl in
256            NCic.Match (indtype_ref, cic_outtype, cic_term,
257             (List.map do_branch branches))
258     | CicNotationPt.Cast (t1, t2) ->
259         let cic_t1 = aux ~localize loc context t1 in
260         let cic_t2 = aux ~localize loc context t2 in
261         NCic.LetIn ("_",cic_t2,cic_t1, NCic.Rel 1)
262     | CicNotationPt.LetIn ((name, typ), def, body) ->
263         let cic_def = aux ~localize loc context def in
264         let cic_name = cic_name_of_name name in
265         let cic_typ =
266           match typ with
267           | None -> NCic.Implicit `Type
268           | Some t -> aux ~localize loc context t
269         in
270         let cic_body = aux ~localize loc (cic_name :: context) body in
271         NCic.LetIn (cic_name, cic_typ, cic_def, cic_body)
272     | CicNotationPt.LetRec (_kind, _defs, _body) -> assert false 
273     | CicNotationPt.Ident _
274     | CicNotationPt.Uri _ when is_path -> raise Disambiguate.PathNotWellFormed
275     | CicNotationPt.Ident (name, subst) ->
276        assert (subst = None);
277        (try
278          NCic.Rel (find_in_context name context)
279        with Not_found -> 
280          try NCic.Const (List.assoc name obj_context)
281          with Not_found ->
282            Disambiguate.resolve ~env ~mk_choice (Id name) (`Args []))
283     | CicNotationPt.Uri (name, subst) ->
284        assert (subst = None);
285        (try
286          NCic.Const (NRef.reference_of_string name)
287         with NRef.IllFormedReference _ ->
288          CicNotationPt.fail loc "Ill formed reference")
289     | CicNotationPt.Implicit -> NCic.Implicit `Term
290     | CicNotationPt.UserInput -> assert false (*NCic.Implicit (Some `Hole)
291 patterns not implemented *)
292     | CicNotationPt.Num (num, i) -> 
293         Disambiguate.resolve ~env ~mk_choice (Num i) (`Num_arg num)
294     | CicNotationPt.Meta (index, subst) ->
295         let cic_subst =
296          List.map
297           (function None -> assert false| Some t -> aux ~localize loc context t)
298           subst
299         in
300          NCic.Meta (index, (0, NCic.Ctx cic_subst))
301     | CicNotationPt.Sort `Prop -> NCic.Sort NCic.Prop
302     | CicNotationPt.Sort `Set -> NCic.Sort (NCic.Type
303        [false,NUri.uri_of_string "cic:/matita/pts/Type.univ"])
304     | CicNotationPt.Sort (`Type _u) -> NCic.Sort (NCic.Type
305        [false,NUri.uri_of_string "cic:/matita/pts/Type.univ"])
306     | CicNotationPt.Sort (`NType s) -> NCic.Sort (NCic.Type
307        [false,NUri.uri_of_string ("cic:/matita/pts/Type" ^ s ^ ".univ")])
308     | CicNotationPt.Sort (`CProp _u) -> NCic.Sort (NCic.Type
309        [false,NUri.uri_of_string "cic:/matita/pts/CProp.univ"])
310     | CicNotationPt.Symbol (symbol, instance) ->
311         Disambiguate.resolve ~env ~mk_choice 
312          (Symbol (symbol, instance)) (`Args [])
313     | CicNotationPt.Variable _
314     | CicNotationPt.Magic _
315     | CicNotationPt.Layout _
316     | CicNotationPt.Literal _ -> assert false (* god bless Bologna *)
317   and aux_option ~localize loc context annotation = function
318     | None -> NCic.Implicit annotation
319     | Some (CicNotationPt.AttributedTerm (`Loc loc, term)) ->
320         let res = aux_option ~localize loc context annotation (Some term) in
321         if localize then 
322           NCicUntrusted.NCicHash.add localization_tbl res loc;
323         res
324     | Some (CicNotationPt.AttributedTerm (_, term)) ->
325         aux_option ~localize loc context annotation (Some term)
326     | Some CicNotationPt.Implicit -> NCic.Implicit annotation
327     | Some term -> aux ~localize loc context term
328   in
329    (fun ~context -> aux ~localize:true HExtlib.dummy_floc context),
330    (fun ~context -> aux_option ~localize:true HExtlib.dummy_floc context)
331 ;;
332
333 let interpretate_term ?(create_dummy_ids=false) ~context ~env ~uri ~is_path ast
334      ~obj_context ~localization_tbl ~mk_choice
335 =
336   let context = List.map fst context in
337   fst 
338     (interpretate_term_and_interpretate_term_option 
339       ~obj_context ~mk_choice ~create_dummy_ids ~env ~uri ~is_path ~localization_tbl)
340     ~context ast
341 ;;
342
343 let interpretate_term_option 
344   ?(create_dummy_ids=false) ~context ~env ~uri ~is_path 
345   ~localization_tbl ~mk_choice ~obj_context
346 =
347   let context = List.map fst context in
348   snd 
349     (interpretate_term_and_interpretate_term_option 
350       ~obj_context ~mk_choice ~create_dummy_ids ~env ~uri ~is_path ~localization_tbl)
351     ~context 
352 ;;
353
354 let new_flavour_of_flavour = function 
355   | `Definition -> `Definition
356   | `MutualDefinition -> `Definition 
357   | `Fact -> `Fact
358   | `Lemma -> `Lemma
359   | `Remark -> `Corollary
360   | `Theorem -> `Theorem
361   | `Variant -> `Corollary 
362   | `Axiom -> `Fact
363 ;;
364
365 (*
366 let interpretate_obj ?(create_dummy_ids=false) ~context ~env ~uri ~is_path ast
367      ~localization_tbl
368 =
369  assert (context = []);
370  assert (is_path = false);
371  let interpretate_term ?(obj_context=[]) =
372   interpretate_term ~mk_choice ~localization_tbl ~obj_context in
373  let interpretate_term_option ?(obj_context=[]) =
374    interpretate_term_option ~mk_choice ~localization_tbl ~obj_context in
375  match obj with
376  | CicNotationPt.Theorem (flavour, name, ty, bo) ->
377      let attrs = `Provided, new_flavour_of_flavour flavour in
378      let ty' = interpretate_term [] env None false ty in
379      let height = (* XXX calculate *) 0 in
380      uri, height, [], [], 
381      (match bo,flavour with
382         None,`Axiom ->
383          NCic.Constant (name,None,ty',attrs)
384       | Some bo,`Axiom -> assert false
385       | None,_ ->
386          NCic.Constant (name,NCic.Implicit None,ty',attrs)
387       | Some bo,_ ->
388          match bo with
389          | CicNotationPt.LetRec (kind, defs, _) ->
390              let inductive = kind = `Inductive in
391              let obj_context =
392                List.split 
393                  (List.fold_left
394                    (fun (i,acc) (_,(name,_),_,k) -> 
395                     ((name, NReference.reference_of_spec uri 
396                        (if inductive then NReference.Fix (i,k,0)
397                         else NReference.CoFix i)) :: acc)
398                    (0,[]) defs))
399              in
400              let inductiveFuns =
401                List.map
402                  (fun (params, (name, typ), body, decr_idx) ->
403                    let add_binders kind t =
404                     List.fold_right
405                      (fun var t -> 
406                         CicNotationPt.Binder (kind, var, t)) params t
407                    in
408                    let cic_body =
409                      interpretate_term ~context ~env ~uri:None ~is_path:false
410                        (add_binders `Lambda body) 
411                    in
412                    let cic_type =
413                      interpretate_term_option ~context ~env ~uri:None
414                        ~is_path:false `Type
415                        (HExtlib.map_option (add_binders `Pi) typ)
416                    in
417                    (name, decr_idx, cic_type, cic_body))
418                  defs
419              in
420              NCic.Fixpoint (inductive,inductiveFuns,attrs)
421          | bo -> 
422              let bo = 
423                interpretate_term ~context:[] ~env ~uri:None ~is_path:false bo
424              in
425              NCic.Constant (name,Some bo,ty',attrs))
426   | _ -> assert false
427 (*
428   | CicNotationPt.Inductive (params,tyl) ->
429      let uri = match uri with Some uri -> uri | None -> assert false in
430      let context,params =
431       let context,res =
432        List.fold_left
433         (fun (context,res) (name,t) ->
434           let t =
435            match t with
436               None -> CicNotationPt.Implicit
437             | Some t -> t in
438           let name = CicNotationUtil.cic_name_of_name name in
439            name::context,(name, interpretate_term context env None false t)::res
440         ) ([],[]) params
441       in
442        context,List.rev res in
443      let add_params =
444       List.fold_right (fun (name,ty) t -> Cic.Prod (name,ty,t)) params in
445      let obj_context =
446       snd (
447        List.fold_left
448         (*here the explicit_named_substituion is assumed to be of length 0 *)
449         (fun (i,res) (name,_,_,_) -> i + 1,(name,Cic.MutInd (uri,i,[]))::res)
450         (0,[]) tyl) in
451      let tyl =
452       List.map
453        (fun (name,b,ty,cl) ->
454          let ty' = add_params (interpretate_term context env None false ty) in
455          let cl' =
456           List.map
457            (fun (name,ty) ->
458              let ty' =
459               add_params
460                (interpretate_term ~obj_context ~context ~env ~uri:None
461                  ~is_path:false ty)
462              in
463               name,ty'
464            ) cl
465          in
466           name,b,ty',cl'
467        ) tyl
468      in
469       Cic.InductiveDefinition (tyl,[],List.length params,[])
470   | CicNotationPt.Record (params,name,ty,fields) ->
471      let uri = match uri with Some uri -> uri | None -> assert false in
472      let context,params =
473       let context,res =
474        List.fold_left
475         (fun (context,res) (name,t) ->
476           let t =
477            match t with
478               None -> CicNotationPt.Implicit
479             | Some t -> t in
480           let name = CicNotationUtil.cic_name_of_name name in
481            name::context,(name, interpretate_term context env None false t)::res
482         ) ([],[]) params
483       in
484        context,List.rev res in
485      let add_params =
486       List.fold_right
487        (fun (name,ty) t -> Cic.Prod (name,ty,t)) params in
488      let ty' = add_params (interpretate_term context env None false ty) in
489      let fields' =
490       snd (
491        List.fold_left
492         (fun (context,res) (name,ty,_coercion,arity) ->
493           let context' = Cic.Name name :: context in
494            context',(name,interpretate_term context env None false ty)::res
495         ) (context,[]) fields) in
496      let concl =
497       (*here the explicit_named_substituion is assumed to be of length 0 *)
498       let mutind = Cic.MutInd (uri,0,[]) in
499       if params = [] then mutind
500       else
501        Cic.Appl
502         (mutind::CicUtil.mk_rels (List.length params) (List.length fields)) in
503      let con =
504       List.fold_left
505        (fun t (name,ty) -> Cic.Prod (Cic.Name name,ty,t))
506        concl fields' in
507      let con' = add_params con in
508      let tyl = [name,true,ty',["mk_" ^ name,con']] in
509      let field_names = List.map (fun (x,_,y,z) -> x,y,z) fields in
510       Cic.InductiveDefinition
511        (tyl,[],List.length params,[`Class (`Record field_names)])
512 *)
513 ;;
514 *)
515
516 let disambiguate_term ~context ~metasenv ~subst ?goal
517    ~mk_implicit ~description_of_alias ~mk_choice
518    ~aliases ~universe ~coercion_db ~lookup_in_library 
519    (text,prefix_len,term) 
520  =
521   let mk_localization_tbl x = NCicUntrusted.NCicHash.create x in
522   let hint =
523    match goal with
524       None -> (fun _ y -> y),(fun x -> x)
525     | Some n ->
526        (fun metasenv y ->
527          let _,_,ty = NCicUtils.lookup_meta n metasenv in
528           NCic.LetIn ("_",ty,y,NCic.Rel 1)),
529        (function  
530         | Disambiguate.Ok (t,m,s,ug) ->
531             (match t with
532             | NCic.LetIn ("_",_,y,NCic.Rel 1) -> Disambiguate.Ok (y,m,s,ug)
533             | _ -> assert false)
534         | k -> k)
535   in
536    let res,b =
537     MultiPassDisambiguator.disambiguate_thing
538      ~freshen_thing:CicNotationUtil.freshen_term
539      ~context ~metasenv ~initial_ugraph:() ~aliases
540      ~mk_implicit ~description_of_alias
541      ~string_context_of_context:(List.map (fun (x,_) -> Some x))
542      ~universe ~uri:None ~pp_thing:CicNotationPp.pp_term
543      ~passes:(MultiPassDisambiguator.passes ())
544      ~lookup_in_library ~domain_of_thing:Disambiguate.domain_of_term
545      ~interpretate_thing:(interpretate_term ~obj_context:[] ~mk_choice (?create_dummy_ids:None))
546      ~refine_thing:(refine_term ~coercion_db) (text,prefix_len,term)
547      ~mk_localization_tbl ~hint ~subst
548    in
549     List.map (function (a,b,c,d,_) -> a,b,c,d) res, b
550 ;;
551
552 let _ = 
553 let mk_type n = 
554   if n = 0 then
555      [false, NUri.uri_of_string ("cic:/matita/pts/Type.univ")]
556   else
557      [false, NUri.uri_of_string ("cic:/matita/pts/Type"^string_of_int n^".univ")]
558 in
559 let mk_cprop n = 
560   if n = 0 then 
561     [false, NUri.uri_of_string ("cic:/matita/pts/CProp.univ")]
562   else
563     [false, NUri.uri_of_string ("cic:/matita/pts/CProp"^string_of_int n^".univ")]
564 in
565          NCicEnvironment.add_constraint true (mk_type 0) (mk_type 1);
566          NCicEnvironment.add_constraint true (mk_cprop 0) (mk_cprop 1);
567          NCicEnvironment.add_constraint true (mk_cprop 0) (mk_type 1);
568          NCicEnvironment.add_constraint true (mk_type 0) (mk_cprop 1);
569          NCicEnvironment.add_constraint false (mk_cprop 0) (mk_type 0);
570          NCicEnvironment.add_constraint false (mk_type 0) (mk_cprop 0);
571
572          NCicEnvironment.add_constraint true (mk_type 1) (mk_type 2);
573          NCicEnvironment.add_constraint true (mk_cprop 1) (mk_cprop 2);
574          NCicEnvironment.add_constraint true (mk_cprop 1) (mk_type 2);
575          NCicEnvironment.add_constraint true (mk_type 1) (mk_cprop 2);
576          NCicEnvironment.add_constraint false (mk_cprop 1) (mk_type 1);
577          NCicEnvironment.add_constraint false (mk_type 1) (mk_cprop 1);
578
579          NCicEnvironment.add_constraint true (mk_type 2) (mk_type 3);
580          NCicEnvironment.add_constraint true (mk_cprop 2) (mk_cprop 3);
581          NCicEnvironment.add_constraint true (mk_cprop 2) (mk_type 3);
582          NCicEnvironment.add_constraint true (mk_type 2) (mk_cprop 3);
583          NCicEnvironment.add_constraint false (mk_cprop 2) (mk_type 2);
584          NCicEnvironment.add_constraint false (mk_type 2) (mk_cprop 2);
585
586          NCicEnvironment.add_constraint false (mk_cprop 3) (mk_type 3);
587          NCicEnvironment.add_constraint false (mk_type 3) (mk_cprop 3);
588
589 ;;
590