diff options
author | Amin Timany <amintimany@gmail.com> | 2017-05-24 13:45:08 +0200 |
---|---|---|
committer | Emilio Jesus Gallego Arias <e+git@x80.org> | 2017-06-16 04:51:18 +0200 |
commit | c01d225f9e112bb08f9df26f70805bde0c0d127a (patch) | |
tree | 793f803d3fa99bb480e3312960266d038381513f /checker/univ.ml | |
parent | e28d3a488c81c6dc59aa8f53d98a95ee93a84d37 (diff) |
Enable the checking of ind subtyping in checker
Diffstat (limited to 'checker/univ.ml')
-rw-r--r-- | checker/univ.ml | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/checker/univ.ml b/checker/univ.ml index 525f535e9..92b6a9e86 100644 --- a/checker/univ.ml +++ b/checker/univ.ml @@ -968,7 +968,23 @@ struct else Level.compare v v' end -module Constraint = Set.Make(UConstraintOrd) +let pr_constraint_type op = + let op_str = match op with + | Lt -> " < " + | Le -> " <= " + | Eq -> " = " + in str op_str + +module Constraint = +struct + module S = Set.Make(UConstraintOrd) + include S + + let pr prl c = + fold (fun (u1,op,u2) pp_std -> + pp_std ++ prl u1 ++ pr_constraint_type op ++ + prl u2 ++ fnl () ) c (str "") +end let empty_constraint = Constraint.empty let merge_constraints c g = @@ -1159,6 +1175,11 @@ struct let make x = x let instance (univs, cst) = univs let constraints (univs, cst) = cst + + let is_empty (univs, cst) = Instance.is_empty univs && Constraint.is_empty cst + let pr prl (univs, cst as ctx) = + if is_empty ctx then mt() else + h 0 (Instance.pr univs ++ str " |= ") ++ h 0 (v 0 (Constraint.pr prl cst)) end type universe_context = UContext.t @@ -1193,8 +1214,12 @@ struct (univcst, UContext.make (Array.append inst freshunivs, create_trivial_subtyping inst freshunivs)) + let subtyping_other_instance (univcst, subtypcst) = + let (_, ctx') = (halve_context (UContext.instance subtypcst)) in ctx' + let subtyping_susbst (univcst, subtypcst) = - let (_, ctx') = (halve_context (UContext.instance subtypcst)) in ctx' + let (ctx, ctx') = (halve_context (UContext.instance subtypcst)) in + Array.fold_left2 (fun subst l1 l2 -> LMap.add l1 l2 subst) LMap.empty ctx ctx' end @@ -1308,6 +1333,10 @@ let merge_context_set strict ctx g = (** Pretty-printing *) +let pr_constraints prl = Constraint.pr prl + +let pr_universe_context = UContext.pr + let pr_arc = function | _, Canonical {univ=u; lt=[]; le=[]} -> mt () |