let eval_ng_tac (text, prefix_len, tac) =
match tac with
| GrafiteAst.NApply (_loc, t) -> NTactics.apply_tac (text,prefix_len,t)
- | GrafiteAst.NAssert (_loc, hyps, concl) ->
+ | GrafiteAst.NAssert (_loc, seqs) ->
NTactics.assert_tac
- (List.map (function (id,`Decl t) -> id,`Decl (text,prefix_len,t) | (id,`Def (b,t)) -> id,`Def ((text,prefix_len,b),(text,prefix_len,t))) hyps,
- (text,prefix_len,concl))
+ ((List.map
+ (function (hyps,concl) ->
+ List.map
+ (function
+ (id,`Decl t) -> id,`Decl (text,prefix_len,t)
+ |(id,`Def (b,t))->id,`Def((text,prefix_len,b),(text,prefix_len,t))
+ ) hyps,
+ (text,prefix_len,concl))
+ ) seqs)
| GrafiteAst.NCases (_loc, what, where) ->
NTactics.cases_tac
~what:(text,prefix_len,what)
ntactic: [
[ IDENT "napply"; t = tactic_term -> GrafiteAst.NApply (loc, t)
| IDENT "nassert";
+ seqs = LIST0 [
hyps = LIST0
[ id = IDENT ; SYMBOL ":" ; ty = tactic_term -> id,`Decl ty
| id = IDENT ; SYMBOL ":" ; ty = tactic_term ;
SYMBOL <:unicode<def>> ; bo = tactic_term ->
id,`Def (bo,ty)];
SYMBOL <:unicode<vdash>>;
- concl = tactic_term ->
- GrafiteAst.NAssert (loc, hyps, concl)
+ concl = tactic_term -> (hyps,concl) ] ->
+ GrafiteAst.NAssert (loc, seqs)
| IDENT "ncases"; what = tactic_term ; where = pattern_spec ->
GrafiteAst.NCases (loc, what, where)
| IDENT "nchange"; what = pattern_spec; "with"; with_what = tactic_term ->
if name = "_clearme" then clear_tac ["_clearme"] else id_tac ]
;;
-let assert_tac (hyps,concl) = distribute_tac (fun status goal ->
+let assert0_tac (hyps,concl) = distribute_tac (fun status goal ->
let gty = get_goalty status goal in
- let status,concl = disambiguate status concl None (ctx_of gty) in
- let status,concl = term_of_cic_term status concl (ctx_of gty) in
+ let eq status ctx t1 t2 =
+ let status,t1 = disambiguate status t1 None ctx in
+ let status,t1 = apply_subst status ctx t1 in
+ let status,t1 = term_of_cic_term status t1 ctx in
+ let t2 = mk_cic_term ctx t2 in
+ let status,t2 = apply_subst status ctx t2 in
+ let status,t2 = term_of_cic_term status t2 ctx in
+ prerr_endline ("COMPARING: " ^ NCicPp.ppterm ~subst:[] ~metasenv:[] ~context:ctx t1 ^ " vs " ^ NCicPp.ppterm ~subst:[] ~metasenv:[] ~context:ctx t2);
+ assert (t1=t2);
+ status
+ in
let status,gty' = term_of_cic_term status gty (ctx_of gty) in
- assert (concl=gty');
+ let status = eq status (ctx_of gty) concl gty' in
let status,_ =
List.fold_right2
(fun (id1,e1) ((id2,e2) as item) (status,ctx) ->
assert (id1=id2);
match e1,e2 with
`Decl t1, NCic.Decl t2 ->
- let status,t1 = disambiguate status t1 None ctx in
- let status,t1 = apply_subst status ctx t1 in
- let status,t1 = term_of_cic_term status t1 ctx in
- let t2 = mk_cic_term ctx t2 in
- let status,t2 = apply_subst status ctx t2 in
- let status,t2 = term_of_cic_term status t2 ctx in
- assert (t1=t2);
+ let status = eq status ctx t1 t2 in
status,item::ctx
| `Def (b1,t1), NCic.Def (b2,t2) ->
- let status,t1 = disambiguate status t1 None ctx in
- let status,t1 = apply_subst status ctx t1 in
- let status,t1 = term_of_cic_term status t1 ctx in
- let status,b1 = disambiguate status b1 None ctx in
- let status,b1 = apply_subst status ctx b1 in
- let status,b1 = term_of_cic_term status b1 ctx in
- let t2 = mk_cic_term ctx t2 in
- let status,t2 = apply_subst status ctx t2 in
- let status,t2 = term_of_cic_term status t2 ctx in
- let b2 = mk_cic_term ctx b2 in
- let status,b2 = apply_subst status ctx b2 in
- let status,b2 = term_of_cic_term status b2 ctx in
- assert (t1=t2 && b1=b2);
+ let status = eq status ctx t1 t2 in
+ let status = eq status ctx b1 b2 in
status,item::ctx
| _ -> assert false
) hyps (ctx_of gty) (status,[])
in
exec id_tac status goal)
;;
+
+let assert_tac seqs status =
+ match status.gstatus with
+ | [] -> assert false
+ | (g,_,_,_) :: s ->
+ assert (List.length g = List.length seqs);
+ (match seqs with
+ [] -> id_tac
+ | [seq] -> assert0_tac seq
+ | _ ->
+ block_tac
+ (branch_tac::
+ HExtlib.list_concat ~sep:[shift_tac]
+ (List.map (fun seq -> [assert0_tac seq]) seqs)@
+ [merge_tac])
+ ) status
+;;