X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fcomponents%2Facic_procedural%2Fprocedural2.ml;h=46d4431bde2b19be822125f269c70df37fbf927f;hb=b4fd90e993045c2a71b6fd2479cd515f09d36d06;hp=e41dd101b896b8f64bea8fbae0a22d6331d15c84;hpb=1b70a1f66be53f76e475383e86d63c2b5c1fbcaa;p=helm.git diff --git a/helm/software/components/acic_procedural/procedural2.ml b/helm/software/components/acic_procedural/procedural2.ml index e41dd101b..46d4431bd 100644 --- a/helm/software/components/acic_procedural/procedural2.ml +++ b/helm/software/components/acic_procedural/procedural2.ml @@ -230,14 +230,14 @@ let mk_arg st = function | C.ARel (_, _, i, name) as what -> convert st ~name:(name, i) what | _ -> [] -let mk_fwd_rewrite st dtext name tl direction v t ity = +let mk_fwd_rewrite st dtext name tl direction v t ity ety = let compare premise = function | None -> true | Some s -> s = premise in assert (List.length tl = 6); let what, where, predicate = List.nth tl 5, List.nth tl 3, List.nth tl 2 in - let e = Cn.mk_pattern 1 predicate in + let e = Cn.mk_pattern 1 ety predicate in if (Cn.does_not_occur e) then st, [] else match where with | C.ARel (_, _, i, premise) as w -> @@ -258,10 +258,10 @@ let mk_fwd_rewrite st dtext name tl direction v t ity = end | _ -> assert false -let mk_rewrite st dtext where qs tl direction t = +let mk_rewrite st dtext where qs tl direction t ety = assert (List.length tl = 5); let predicate = List.nth tl 2 in - let e = Cn.mk_pattern 1 predicate in + let e = Cn.mk_pattern 1 ety predicate in let script = [T.Branch (qs, "")] in if (Cn.does_not_occur e) then script else T.Rewrite (direction, where, None, e, dtext) :: script @@ -284,17 +284,17 @@ and proc_letin st what name v w t = let st, hyp, rqv = match get_inner_types st what, get_inner_types st v with | Some (C.ALetIn _, _), _ -> st, C.Def (H.cic v, H.cic w), [T.Intros (Some 1, [intro], dtext)] - | _, Some (ity, _) -> + | _, Some (ity, ety) -> let st, rqv = match v with | C.AAppl (_, hd :: tl) when is_fwd_rewrite_right st hd tl -> - mk_fwd_rewrite st dtext intro tl true v t ity + mk_fwd_rewrite st dtext intro tl true v t ity ety | C.AAppl (_, hd :: tl) when is_fwd_rewrite_left st hd tl -> - mk_fwd_rewrite st dtext intro tl false v t ity + mk_fwd_rewrite st dtext intro tl false v t ity ety | v -> - assert (Ut.is_sober st.context (H.cic ity)); - let ity = H.acic_bc st.context ity in + assert (Ut.is_sober st.context (H.cic ety)); + let ety = H.acic_bc st.context ety in let qs = [proc_proof (next st) v; [T.Id ""]] in - st, [T.Branch (qs, ""); T.Cut (intro, ity, dtext)] + st, [T.Branch (qs, ""); T.Cut (intro, ety, dtext)] in st, C.Decl (H.cic ity), rqv | _, None -> @@ -340,7 +340,10 @@ and proc_appl st what hd tl = let parsno, argsno = List.length classes, List.length tl in let decurry = parsno - argsno in let diff = goal_arity - decurry in - if diff < 0 then failwith (Printf.sprintf "NOT TOTAL: %i %s |--- %s" diff (Pp.ppcontext st.context) (Pp.ppterm (H.cic hd))); + if diff < 0 then + let text = Printf.sprintf "partial application: %i" diff in + [T.Exact (what, dtext ^ text)] + else let classes = Cl.adjust st.context tl ?goal classes in let rec mk_synth a n = if n < 0 then a else mk_synth (I.S.add n a) (pred n) @@ -350,27 +353,32 @@ and proc_appl st what hd tl = let script = List.rev (mk_arg st hd) in let tactic b t n = if b then T.Apply (t, n) else T.Exact (t, n) in match rc with - | Some (i, j, uri, tyno) -> + | Some (i, j, uri, tyno) when decurry = 0 -> let classes2, tl2, _, where = split2_last classes tl in let script2 = List.rev (mk_arg st where) @ script in let synth2 = I.S.add 1 synth in let names = H.get_ind_names uri tyno in let qs = proc_bkd_proofs (next st) synth2 names classes2 tl2 in - if List.length qs <> List.length names then + let ety = match get_inner_types st what with + | Some (_, ety) -> ety + | None -> + Cn.fake_annotate "" st.context (get_type "TC3" st what) + in + if List.length qs <> List.length names then let qs = proc_bkd_proofs (next st) synth [] classes tl in let b, hd = mk_exp_args hd tl classes synth in script @ [tactic b hd (dtext ^ text); T.Branch (qs, "")] else if is_rewrite_right st hd then - script2 @ mk_rewrite st dtext where qs tl2 false what + script2 @ mk_rewrite st dtext where qs tl2 false what ety else if is_rewrite_left st hd then - script2 @ mk_rewrite st dtext where qs tl2 true what + script2 @ mk_rewrite st dtext where qs tl2 true what ety else let predicate = List.nth tl2 (parsno - i) in - let e = Cn.mk_pattern j predicate in + let e = Cn.mk_pattern j ety predicate in let using = Some hd in script2 @ [T.Elim (where, using, e, dtext ^ text); T.Branch (qs, "")] - | None -> + | _ -> let names = get_sub_names hd tl in let qs = proc_bkd_proofs (next st) synth names classes tl in let b, hd = mk_exp_args hd tl classes synth in @@ -390,7 +398,12 @@ and proc_case st what uri tyno u v ts = let ps, _ = H.get_ind_parameters st.context (H.cic v) in let _, rps = HEL.split_nth lpsno ps in let rpsno = List.length rps in - let e = Cn.mk_pattern rpsno u in + let ety = match get_inner_types st what with + | Some (_, ety) -> ety + | None -> + Cn.fake_annotate "" st.context (get_type "TC4" st what) + in + let e = Cn.mk_pattern rpsno ety u in let text = "" in let script = List.rev (mk_arg st v) in script @ [T.Cases (v, e, dtext ^ text); T.Branch (qs, "")]