let anonymous_premise = C.Name "UNNAMED"
-let mk_exp_args hd tl classes synth qs =
+let mk_lapply_args hd tl classes =
+ let map _ = Cn.meta "" in
+ let args = List.rev_map map tl in
+ if args = [] then hd else C.AAppl ("", hd :: args)
+
+let mk_apply_args hd tl classes synth qs =
let exp = ref 0 in
- let meta id = C.AImplicit (id, None) in
let map v (cl, b) =
if I.overlaps synth cl
- then if b then v, v else meta "", v
- else meta "", meta ""
+ then if b then v, v else Cn.meta "", v
+ else Cn.meta "", Cn.meta ""
in
let rec rev a = function
| [] -> a
| hd :: tl ->
- if snd hd <> meta "" then incr exp;
+ if snd hd <> Cn.meta "" then incr exp;
rev (snd hd :: a) tl
in
let rec aux = function
| [] -> []
| hd :: tl ->
- if fst hd = meta "" then aux tl else rev [] (hd :: tl)
+ if fst hd = Cn.meta "" then aux tl else rev [] (hd :: tl)
in
let args = T.list_rev_map2 map tl classes in
let args = aux args in
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 ety
+ | C.AAppl (_, hd :: tl) ->
+ let ty = match get_inner_types st hd with
+ | Some (ity, _) -> H.cic ity
+ | None -> get_type "TC3" st hd
+ in
+ let classes, _ = Cl.classify st.context ty in
+ let parsno, argsno = List.length classes, List.length tl in
+ let decurry = parsno - argsno in
+ if decurry <> 0 then begin
+(* FG: we fall back in the cut case *)
+ 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, ety, dtext)]
+ end else
+ let names, synth = get_sub_names hd tl, I.S.empty in
+ let qs = proc_bkd_proofs (next st) synth names classes tl in
+ let hd = mk_lapply_args hd tl classes in
+ let qs = [T.Id ""] :: qs in
+ st, [T.Branch (qs, ""); T.LApply (intro, hd, dtext)]
| v ->
assert (Ut.is_sober st.context (H.cic ety));
let ety = H.acic_bc st.context ety in
in
if List.length qs <> List.length names then
let qs = proc_bkd_proofs (next st) synth [] classes tl in
- let b, hd, qs = mk_exp_args hd tl classes synth qs in
+ let b, hd, qs = mk_apply_args hd tl classes synth qs 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 ity
| _ ->
let names = get_sub_names hd tl in
let qs = proc_bkd_proofs (next st) synth names classes tl in
- let b, hd, qs = mk_exp_args hd tl classes synth qs in
+ let b, hd, qs = mk_apply_args hd tl classes synth qs in
script @ [tactic b hd (dtext ^ text); T.Branch (qs, "")]
else
[T.Exact (what, dtext)]
| Intros of count option * name list * note
| Cut of name * what * note
| LetIn of name * what * note
+ | LApply of name * what * note
| Rewrite of how * what * where * pattern * note
| Elim of what * using option * pattern * note
| Cases of what * pattern * note
let tactic = G.LetIn (floc, what, name) in
mk_tactic tactic punctation
+let mk_lapply name what punctation =
+ let tactic = G.LApply (floc, false, None, [], what, name) in
+ mk_tactic tactic punctation
+
let mk_rewrite direction what where pattern punctation =
let direction = if direction then `RightToLeft else `LeftToRight in
let pattern, rename = match where with
| Intros (c, ns, s) -> mk_intros c ns sep :: mk_tacnote s a
| Cut (n, t, s) -> mk_cut n t sep :: mk_tacnote s a
| LetIn (n, t, s) -> mk_letin n t sep :: mk_tacnote s a
+ | LApply (n, t, s) -> mk_lapply n t sep :: mk_tacnote s a
| Rewrite (b, t, w, e, s) -> mk_rewrite b t w e sep :: mk_tacnote s a
| Elim (t, xu, e, s) -> mk_elim t xu e sep :: mk_tacnote s a
| Cases (t, e, s) -> mk_cases t e sep :: mk_tacnote s a
| Exact (t, _)
| Cut (_, t, _)
| LetIn (_, t, _)
+ | LApply (_, t, _)
| Apply (t, _) -> count a (H.cic t)
| Rewrite (_, t, _, p, _)
| Elim (t, _, p, _)
| Intros (_, _, s)
| Cut (_, _, s)
| LetIn (_, _, s)
+ | LApply (_, _, s)
| Rewrite (_, _, _, _, s)
| Elim (_, _, _, s)
| Cases (_, _, s)