]> matita.cs.unibo.it Git - helm.git/commitdiff
CProp hierarchy fixed:
authorEnrico Tassi <enrico.tassi@inria.fr>
Wed, 9 Jul 2008 11:19:02 +0000 (11:19 +0000)
committerEnrico Tassi <enrico.tassi@inria.fr>
Wed, 9 Jul 2008 11:19:02 +0000 (11:19 +0000)
- CProp universes are not swept away
- CProp i : Type j (where i < j, used to be a fresh j)
- new kernel universe inconsistency error message improved
- pp function for universes constraints for new kernel

Formal topology example fixed to eploit left parameters to reduce the universe
height and solve universe inconsistency

helm/software/components/cic/cicUniv.ml
helm/software/components/cic_proof_checking/cicTypeChecker.ml
helm/software/components/cic_proof_checking/cicUnivUtils.ml
helm/software/components/cic_unification/cicRefine.ml
helm/software/components/ng_kernel/check.ml
helm/software/components/ng_kernel/nCicEnvironment.ml
helm/software/components/ng_kernel/nCicEnvironment.mli
helm/software/matita/library/demo/formal_topology.ma
helm/software/matita/library/depends

index fa773a4db8450d1705070c6256b6216400fd919c..cf6b6eeffba96fb5796f7049c025a3635730829b 100644 (file)
@@ -474,8 +474,14 @@ let add_eq u v b =
 let rank = ref MAL.empty;;
 
 let do_rank (b,_,_) =
-(*         print_ugraph ugraph; *)
-   let keys = MAL.fold (fun k _ acc -> k::acc) b [] in
+   let keys = 
+     MAL.fold 
+       (fun k v acc -> 
+          SOF.union acc (SOF.union (SOF.singleton k) 
+            (SOF.union v.eq_closure (SOF.union v.gt_closure v.ge_closure))))
+       b SOF.empty 
+   in
+   let keys = SOF.elements keys in
    let fall =
      List.fold_left 
        (fun acc u ->
@@ -483,7 +489,6 @@ let do_rank (b,_,_) =
            | [] -> 0, seen
            | x::tl when SOF.mem x seen -> aux k seen tl
            | x::tl ->
-(*                prerr_endline (String.make k '.' ^ string_of_universe x); *)
                let seen = SOF.add x seen in
                let t1, seen = aux (k+1) seen (SOF.elements (repr x b).eq_closure) in
                let t3, seen = aux (k+1) seen (SOF.elements (repr x b).gt_closure) in
index e3d9add620f0755fb19b7725eb66fe12c77eac88..cf3a3c49caec3c2d427ac35dfd3d6c845257f6ba 100644 (file)
@@ -1367,6 +1367,13 @@ and type_of_aux' ~logger ?(subst = []) metasenv context t ugraph =
           in
             ((CicSubstitution.subst_meta l ty),ugraph1))
       (* TASSI: CONSTRAINTS *)
+    | C.Sort (C.CProp t) -> 
+       let t' = CicUniv.fresh() in
+       (try
+         let ugraph1 = CicUniv.add_gt t' t ugraph in
+           (C.Sort (C.Type t')),ugraph1
+        with
+         CicUniv.UniverseInconsistency msg -> raise (TypeCheckerFailure msg))
     | C.Sort (C.Type t) -> 
        let t' = CicUniv.fresh() in
        (try
@@ -1374,7 +1381,7 @@ and type_of_aux' ~logger ?(subst = []) metasenv context t ugraph =
            (C.Sort (C.Type t')),ugraph1
         with
          CicUniv.UniverseInconsistency msg -> raise (TypeCheckerFailure msg))
-    | C.Sort s -> (C.Sort (C.Type (CicUniv.fresh ()))),ugraph
+    | C.Sort (C.Prop|C.Set) -> (C.Sort (C.Type (CicUniv.fresh ()))),ugraph
     | C.Implicit _ -> raise (AssertFailure (lazy "Implicit found"))
     | C.Cast (te,ty) as t ->
        let _,ugraph1 = type_of_aux ~logger context ty ugraph in
index 948b26ff0bf62e372648f8ab175112cd0b455d9a..2c35ebe1a05badb17fd5269edfa4411662bb5c2e 100644 (file)
@@ -79,6 +79,8 @@ let universes_of_obj uri t =
     | C.Meta (n,l1) -> C.Meta (n, List.map (HExtlib.map_option aux) l1)
     | C.Sort (C.Type i) -> add_result [i]; 
       C.Sort (C.Type (CicUniv.name_universe i uri))
+    | C.Sort (C.CProp i) -> add_result [i]; 
+      C.Sort (C.CProp (CicUniv.name_universe i uri))
     | C.Rel _ 
     | C.Sort _
     | C.Implicit _ as x -> x
index 8fa6963aab637b62bcb145dc72eec52d1597b247..fc9dc840d1bb5323ff9526ce57d561664b5999ac 100644 (file)
@@ -386,7 +386,14 @@ and type_of_aux' ?(clean_dummy_dependent_types=true) ?(localization_tbl = Cic.Ci
                  t,(C.Sort (C.Type tno')),subst,metasenv,ugraph1
               with
                CicUniv.UniverseInconsistency msg -> raise (RefineFailure msg))
-        | C.Sort _ -> 
+        | C.Sort (C.CProp tno) -> 
+            let tno' = CicUniv.fresh() in 
+             (try
+               let ugraph1 = CicUniv.add_gt tno' tno ugraph in
+                 t,(C.Sort (C.Type tno')),subst,metasenv,ugraph1
+              with
+               CicUniv.UniverseInconsistency msg -> raise (RefineFailure msg))
+        | C.Sort (C.Prop|C.Set) -> 
             t,C.Sort (C.Type (CicUniv.fresh())),subst,metasenv,ugraph
         | C.Implicit infos ->
            let metasenv',t' = exp_impl metasenv subst context infos in
index 71ba8ddc284720f3ec8bed7fa0ed08c34b41d6d6..d6165d9dbc39cc0a318b8c8821585c95a33b3f2b 100644 (file)
@@ -143,32 +143,38 @@ let _ =
     roots_alluris;
   prerr_endline "finished....";
   let lll = List.sort compare (CicUniv.do_rank (get_graph ())) in
-  prerr_endline "caching objects";
   let _ = 
+    try
     let rec aux = function
       | a::(b::_ as tl) ->
          NCicEnvironment.add_constraint true (mk_type a) (mk_type b);
          NCicEnvironment.add_constraint true (mk_cprop a) (mk_cprop b);
          NCicEnvironment.add_constraint true (mk_type a) (mk_cprop a);
          NCicEnvironment.add_constraint true (mk_cprop a) (mk_type b);
-         NCicEnvironment.add_constraint true (mk_type b) (mk_cprop b);
          aux tl
+      | [a] -> 
+         NCicEnvironment.add_constraint true (mk_type a) (mk_cprop a);
       | _ -> ()
     in
        aux lll
+    with NCicEnvironment.BadConstraint s as e ->
+      prerr_endline (Lazy.force s); raise e
   in
   prerr_endline "ranked....";
+  prerr_endline (NCicEnvironment.pp_constraints ());
   HExtlib.profiling_enabled := false;
   List.iter (fun uu ->
     let uu= OCic2NCic.nuri_of_ouri uu in
     indent := 0;
     let o = NCicLibrary.get_obj uu in
+(*       prerr_endline (NCicPp.ppobj o); *)
     try 
       NCicTypeChecker.typecheck_obj o
     with 
     | NCicTypeChecker.AssertFailure s 
     | NCicTypeChecker.TypeCheckerFailure s
     | NCicEnvironment.ObjectNotFound s
+    | NCicEnvironment.BadConstraint s
     | NCicEnvironment.BadDependency s as e -> 
        prerr_endline ("######### " ^ Lazy.force s);
        if not ignore_exc then raise e
index 57f130546d9ed4c5a663e88119fba719d6df2e7f..496ae54468471382ede458fc51fdd4c1bc0f96c4 100644 (file)
@@ -43,12 +43,21 @@ let universe_leq a b =
 
 let universe_eq a b = universe_leq b a && universe_leq a b
 
+let pp_constraint b x y =  
+  NUri.name_of_uri x ^ (if b then " < " else " <= ") ^ NUri.name_of_uri y
+;;
+
+let pp_constraints () =
+  String.concat "\n" (List.map (fun (b,x,y) -> pp_constraint b x y) !le_constraints)
+;;
+
 let add_constraint strict a b = 
   match a,b with
   | [false,a2],[false,b2] -> 
       if not (le_path_uri [] strict a2 b2) then (
         if le_path_uri [] (not strict) b2 a2 then
-         (raise (BadConstraint (lazy "universe inconsistency")));
+         (raise(BadConstraint(lazy("universe inconsistency adding "^pp_constraint strict a2 b2
+           ^ " to:\n" ^ pp_constraints ()))));
         le_constraints := (strict,a2,b2) :: !le_constraints)
   | _ -> raise (BadConstraint
           (lazy "trying to add a constraint on an inferred universe"))
index 67b3857d1703f71ea1cb0abe191247fc3c974090..029cd94d18818a0c3520f0ce0f2360f6829b56ae 100644 (file)
@@ -29,6 +29,7 @@ val universe_leq: NCic.universe -> NCic.universe -> bool
    true -> strict check (<); false -> loose check (<=)
 *)
 val add_constraint: bool -> NCic.universe -> NCic.universe -> unit
+val pp_constraints: unit -> string
 
 val get_checked_def:
   NReference.reference -> 
index 50671aa41afa50e12f3c3ebfdc6e18e5424e21e5..05711b7b6ca840cb95ceff01f941b52709e815d9 100644 (file)
@@ -44,16 +44,17 @@ record axiom_set : Type ≝
    C: ∀a:A. i a → 2 \sup A
  }.
 
+inductive iter (A: axiom_set) (U,V: 2 \sup A) (covers: A → CProp) : CProp ≝
+   cycle: (∀a:A.a ∈ V → covers a) → iter A U V covers.
+
 inductive covers (A: axiom_set) (U: 2 \sup A) : A → CProp ≝
    refl: ∀a:A. a ∈ U → covers A U a
- | infinity: ∀a:A. ∀j: i ? a. coversl A U (C ? a j) → covers A U a
-with coversl : (2 \sup A) → CProp ≝
-   iter: ∀V:2 \sup A.(∀a:A.a ∈ V → covers A U a) → coversl A U V.
+ | infinity: ∀a:A. ∀j: i ? a. iter A U (C ? a j) (covers A U) → covers A U a.
 
 notation "hvbox(a break ◃ b)" non associative with precedence 45
 for @{ 'covers $a $b }.
 
-interpretation "coversl" 'covers A U = (coversl _ U A).
+interpretation "coversl" 'covers A U = (iter _ U A (covers _ U)).
 interpretation "covers" 'covers a U = (covers _ U a).
 
 definition covers_elim ≝
@@ -63,11 +64,10 @@ definition covers_elim ≝
     let rec aux (a:A) (p:a ◃ U) on p : a ∈ P ≝
      match p return λaa.λ_:aa ◃ U.aa ∈ P with
       [ refl a q ⇒ H1 a q
-      | infinity a j q ⇒ H2 a j q (auxl (C ? a j) q)
-      ]
-    and auxl (V: 2 \sup A) (q: V ◃ U) on q : ∀b. b ∈ V → b ∈ P ≝
-     match q return λVV.λ_:VV ◃ U.∀b. b ∈ VV → b ∈ P with
-      [ iter VV f ⇒ λb.λr. aux b (f b r) ]
+      | infinity a j q ⇒
+         H2 a j q
+          match q return λ_:(C ? a j) ◃ U.∀b. b ∈ (C ? a j) → b ∈ P with
+          [ cycle f ⇒ λb.λr. aux b (f b r) ]]
     in
      aux.
 
@@ -136,8 +136,8 @@ qed.
 
 theorem compatibility: ∀A:axiom_set.∀a:A.∀U,V. a ⋉ V → a ◃ U → U ⋉ V.
  intros;
- generalize in match H; clear H; generalize in match V; clear V;
- apply (covers_elim ?? (mk_powerset A (λa.∀p:2 \sup A.a ⋉ p → U ⋉ p)) ??? H1);
+ generalize in match H; clear H; 
+ apply (covers_elim ?? (mk_powerset A (λa.a ⋉ V → U ⋉ V)) ??? H1);
  clear H1; simplify; intros;
   [ exists [apply a1]
     split;
index 3b068389dc36b2c3604c2f2e56c9425074944bd4..bd27126af01a5f57e4e39421cac04a5d638e72d0 100644 (file)
@@ -14,84 +14,85 @@ algebra/groups.ma algebra/monoids.ma datatypes/bool.ma logic/connectives.ma nat/
 algebra/finite_groups.ma algebra/groups.ma nat/relevant_equations.ma
 algebra/semigroups.ma higher_order_defs/functions.ma
 algebra/monoids.ma algebra/semigroups.ma
+demo/power_derivative.ma nat/compare.ma nat/nat.ma nat/orders.ma nat/plus.ma
 demo/propositional_sequent_calculus.ma datatypes/constructors.ma list/sort.ma nat/compare.ma nat/plus.ma
 demo/realisability.ma datatypes/constructors.ma logic/connectives.ma
-demo/power_derivative.ma nat/compare.ma nat/nat.ma nat/orders.ma nat/plus.ma
-list/in.ma datatypes/bool.ma datatypes/constructors.ma list/list.ma
+demo/formal_topology.ma logic/equality.ma
 list/sort.ma datatypes/bool.ma datatypes/constructors.ma list/in.ma
 list/list.ma datatypes/bool.ma higher_order_defs/functions.ma logic/equality.ma nat/nat.ma nat/orders.ma nat/plus.ma
+list/in.ma datatypes/bool.ma datatypes/constructors.ma list/list.ma
 logic/equality.ma higher_order_defs/relations.ma logic/connectives.ma
 logic/connectives.ma 
 logic/coimplication.ma logic/connectives.ma
 logic/connectives2.ma higher_order_defs/relations.ma
-nat/sieve.ma list/sort.ma nat/primes.ma
 nat/div_and_mod.ma datatypes/constructors.ma nat/minus.ma
 nat/count.ma nat/permutation.ma nat/relevant_equations.ma nat/sigma_and_pi.ma
-nat/factorial2.ma nat/exp.ma nat/factorial.ma
 nat/totient1.ma nat/compare.ma nat/gcd_properties1.ma nat/iteration2.ma nat/totient.ma
 nat/congruence.ma nat/primes.ma nat/relevant_equations.ma
 nat/minus.ma nat/compare.ma nat/le_arith.ma
-nat/chebyshev.ma nat/factorial2.ma nat/factorization.ma nat/log.ma nat/o.ma nat/pi_p.ma
 nat/chinese_reminder.ma nat/congruence.ma nat/exp.ma nat/gcd.ma nat/permutation.ma
 nat/permutation.ma nat/compare.ma nat/sigma_and_pi.ma
 nat/factorial.ma nat/le_arith.ma
 nat/nth_prime.ma nat/lt_arith.ma nat/primes.ma
-nat/binomial.ma nat/factorial2.ma nat/iteration2.ma
-nat/chebyshev_teta.ma nat/binomial.ma nat/pi_p.ma
 nat/fermat_little_theorem.ma nat/congruence.ma nat/exp.ma nat/gcd.ma nat/permutation.ma
 nat/exp.ma nat/div_and_mod.ma nat/lt_arith.ma
 nat/minimization.ma nat/minus.ma
 nat/gcd.ma nat/lt_arith.ma nat/primes.ma
-nat/chebyshev_thm.ma nat/neper.ma
-nat/neper.ma nat/binomial.ma nat/chebyshev.ma nat/div_and_mod_diseq.ma nat/iteration2.ma nat/log.ma
 nat/sigma_and_pi.ma nat/exp.ma nat/factorial.ma nat/lt_arith.ma
 nat/le_arith.ma nat/orders.ma nat/times.ma
-nat/sqrt.ma nat/compare.ma nat/log.ma nat/times.ma
 nat/times.ma nat/plus.ma
-nat/div_and_mod_diseq.ma nat/lt_arith.ma
-nat/generic_iter_p.ma nat/div_and_mod_diseq.ma nat/ord.ma nat/primes.ma
 nat/gcd_properties1.ma nat/gcd.ma
 nat/totient.ma nat/chinese_reminder.ma nat/iteration2.ma
 nat/lt_arith.ma nat/div_and_mod.ma
-nat/bertrand.ma list/in.ma list/sort.ma nat/chebyshev.ma nat/chebyshev_teta.ma nat/o.ma nat/sieve.ma nat/sqrt.ma
 nat/factorization.ma nat/ord.ma
-nat/log.ma datatypes/constructors.ma nat/div_and_mod_diseq.ma nat/iteration2.ma nat/minimization.ma nat/primes.ma nat/relevant_equations.ma
+nat/generic_iter_p.ma nat/div_and_mod_diseq.ma nat/ord.ma nat/primes.ma
 nat/iteration2.ma nat/count.ma nat/generic_iter_p.ma nat/ord.ma nat/primes.ma
+nat/factorial2.ma nat/exp.ma nat/factorial.ma
+nat/pi_p.ma nat/generic_iter_p.ma nat/iteration2.ma nat/primes.ma
 nat/nat.ma higher_order_defs/functions.ma
 nat/relevant_equations.ma nat/gcd.ma nat/minus.ma nat/times.ma
 nat/map_iter_p.ma nat/count.ma nat/permutation.ma
 nat/orders.ma higher_order_defs/ordering.ma logic/connectives.ma nat/nat.ma
-nat/pi_p.ma nat/generic_iter_p.ma nat/iteration2.ma nat/primes.ma
 nat/plus.ma nat/nat.ma
-nat/factorization2.ma nat/factorization.ma
 nat/euler_theorem.ma nat/nat.ma nat/map_iter_p.ma nat/totient.ma
 nat/compare.ma datatypes/bool.ma datatypes/compare.ma nat/orders.ma
 nat/primes.ma logic/connectives.ma nat/div_and_mod.ma nat/factorial.ma nat/minimization.ma nat/sigma_and_pi.ma
 nat/ord.ma datatypes/constructors.ma nat/exp.ma nat/gcd.ma nat/nth_prime.ma nat/relevant_equations.ma
+nat/chebyshev.ma nat/factorial2.ma nat/factorization.ma nat/log.ma nat/o.ma nat/pi_p.ma
+nat/log.ma datatypes/constructors.ma nat/div_and_mod_diseq.ma nat/iteration2.ma nat/minimization.ma nat/primes.ma nat/relevant_equations.ma
+nat/chebyshev_thm.ma nat/neper.ma
+nat/div_and_mod_diseq.ma nat/lt_arith.ma
+nat/binomial.ma nat/factorial2.ma nat/iteration2.ma
+nat/neper.ma nat/binomial.ma nat/chebyshev.ma nat/div_and_mod_diseq.ma nat/iteration2.ma nat/log.ma
+nat/sqrt.ma nat/compare.ma nat/log.ma nat/times.ma
+nat/chebyshev_teta.ma nat/binomial.ma nat/pi_p.ma
 nat/o.ma nat/binomial.ma nat/sqrt.ma
-Q/inv.ma Q/q.ma
-Q/frac.ma 
+nat/bertrand.ma list/in.ma list/sort.ma nat/chebyshev.ma nat/chebyshev_teta.ma nat/o.ma nat/sieve.ma nat/sqrt.ma
+nat/sieve.ma list/sort.ma nat/primes.ma
+nat/factorization2.ma list/list.ma nat/factorization.ma nat/sieve.ma
+Q/q.ma Q/fraction/fraction.ma Z/compare.ma Z/plus.ma nat/factorization.ma
 Q/Qaxioms.ma Z/compare.ma Z/times.ma nat/iteration2.ma
-Q/q.ma Z/compare.ma Z/plus.ma nat/factorization.ma
-Q/nat_fact/times.ma nat/factorization.ma
+Q/frac.ma nat/nat.ma Q/q/q.ma Q/q/qinv.ma nat/factorization.ma
+Q/inv.ma Q/fraction/finv.ma Q/q.ma Q/q/q.ma
 Q/ratio/rtimes.ma Q/fraction/ftimes.ma Q/ratio/rinv.ma
 Q/ratio/ratio.ma Q/fraction/fraction.ma
 Q/ratio/rinv.ma Q/fraction/finv.ma Q/ratio/ratio.ma
-Q/q/qtimes.ma Q/q/qinv.ma Q/ratio/rtimes.ma
-Q/q/qplus.ma nat/factorization.ma
-Q/q/qinv.ma Q/q/q.ma Q/ratio/rinv.ma
-Q/q/q.ma Q/fraction/numerator_denominator.ma Q/ratio/ratio.ma
+Q/fraction/fraction.ma Z/compare.ma nat/factorization.ma
 Q/fraction/ftimes.ma Q/fraction/finv.ma Q/nat_fact/times.ma Q/ratio/ratio.ma Z/times.ma
 Q/fraction/numerator_denominator.ma Q/fraction/finv.ma
 Q/fraction/finv.ma Q/fraction/fraction.ma Z/plus.ma
-Q/fraction/fraction.ma Z/compare.ma nat/factorization.ma
+Q/q/qplus.ma nat/factorization.ma
+Q/q/qinv.ma Q/q/q.ma Q/ratio/rinv.ma
+Q/q/q.ma Q/fraction/numerator_denominator.ma Q/ratio/ratio.ma
+Q/q/qtimes.ma Q/q/qinv.ma Q/ratio/rtimes.ma
+Q/nat_fact/times.ma nat/factorization.ma
 technicalities/setoids.ma datatypes/constructors.ma logic/coimplication.ma logic/connectives2.ma
 decidable_kit/streicher.ma logic/connectives.ma logic/equality.ma
 decidable_kit/decidable.ma datatypes/bool.ma decidable_kit/streicher.ma logic/connectives.ma nat/compare.ma
-decidable_kit/fgraph.ma decidable_kit/fintype.ma
 decidable_kit/eqtype.ma datatypes/constructors.ma decidable_kit/decidable.ma
 decidable_kit/list_aux.ma decidable_kit/eqtype.ma list/list.ma nat/plus.ma
 decidable_kit/fintype.ma decidable_kit/eqtype.ma decidable_kit/list_aux.ma
+decidable_kit/fgraph.ma decidable_kit/fintype.ma
 higher_order_defs/relations.ma logic/connectives.ma
 higher_order_defs/functions.ma logic/equality.ma
 higher_order_defs/ordering.ma logic/equality.ma