| ApplyS of loc * 'term * 'term auto_params
| Assumption of loc
| AutoBatch of loc * 'term auto_params
- | Cases of loc * 'term * 'ident intros_spec
+ | Cases of loc * 'term * ('term, 'lazy_term, 'ident) pattern *
+ 'ident intros_spec
| Change of loc * ('term, 'lazy_term, 'ident) pattern * 'lazy_term
| Clear of loc * 'ident list
| ClearBody of loc * 'ident
| AutoBatch (_,params) -> "autobatch " ^
pp_auto_params ~term_pp params
| Assumption _ -> "assumption"
- | Cases (_, term, specs) -> Printf.sprintf "cases " ^ term_pp term ^
+ | Cases (_, term, pattern, specs) -> Printf.sprintf "cases " ^ term_pp term ^
+ pp_tactic_pattern pattern ^
pp_intros_specs "names " specs
| Change (_, where, with_what) ->
Printf.sprintf "change %s with %s" (pp_tactic_pattern where) (lazy_term_pp with_what)
| GrafiteAst.AutoBatch (_,params) ->
Tactics.auto ~params ~dbd:(LibraryDb.instance ())
~universe:status.GrafiteTypes.universe
- | GrafiteAst.Cases (_, what, (howmany, names)) ->
+ | GrafiteAst.Cases (_, what, pattern, (howmany, names)) ->
Tactics.cases_intros ?howmany ~mk_fresh_name_callback:(namer_of names)
- what
+ ~pattern what
| GrafiteAst.Change (_, pattern, with_what) ->
Tactics.change ~pattern with_what
| GrafiteAst.Clear (_,id) -> Tactics.clear id
| GrafiteAst.AutoBatch (loc,params) ->
let metasenv, params = disambiguate_auto_params metasenv params in
metasenv,GrafiteAst.AutoBatch (loc,params)
- | GrafiteAst.Cases (loc, what, idents) ->
+ | GrafiteAst.Cases (loc, what, pattern, idents) ->
let metasenv,what = disambiguate_term context metasenv what in
- metasenv,GrafiteAst.Cases (loc, what, idents)
+ let pattern = disambiguate_pattern pattern in
+ metasenv,GrafiteAst.Cases (loc, what, pattern, idents)
| GrafiteAst.Change (loc, pattern, with_what) ->
let with_what = disambiguate_lazy_term with_what in
let pattern = disambiguate_pattern pattern in
| IDENT "autobatch"; params = auto_params ->
GrafiteAst.AutoBatch (loc,params)
| IDENT "cases"; what = tactic_term;
+ pattern = OPT pattern_spec;
specs = intros_spec ->
- GrafiteAst.Cases (loc, what, specs)
+ let pattern = match pattern with
+ | None -> None, [], Some Ast.UserInput
+ | Some pattern -> pattern
+ in
+ GrafiteAst.Cases (loc, what, pattern, specs)
| IDENT "clear"; ids = LIST1 IDENT ->
GrafiteAst.Clear (loc, ids)
| IDENT "clearbody"; id = IDENT ->
List.map
(fun id ->
let rel,_ = ProofEngineHelpers.find_hyp id context in
- id,(Some (PET.const_lazy_term rel), [], Some (ProofEngineTypes.hole))
+ id,(Some (fun ctx m u -> CicSubstitution.lift (List.length ctx - List.length context) rel,m,u), [], Some (ProofEngineTypes.hole))
) generalize_hyps in
let tactics =
List.map
PET.mk_tactic reorder_pattern
;;
-let cases_intros_tac ?(howmany=(-1)) ?(mk_fresh_name_callback = FreshNamesGenerator.mk_fresh_name ~subst:[]) term =
- let cases_tac ~term (proof, goal) =
+let cases_intros_tac ?(howmany=(-1)) ?(mk_fresh_name_callback = FreshNamesGenerator.mk_fresh_name ~subst:[]) ?(pattern = PET.conclusion_pattern None) term =
+ let cases_tac pattern (proof, goal) =
let module TC = CicTypeChecker in
let module U = UriManager in
let module R = CicReduction in
let module C = Cic in
let (curi,metasenv,_subst, proofbo,proofty, attrs) = proof in
let metano,context,ty = CicUtil.lookup_meta goal metasenv in
+ let pattern = pattern_after_generalize_pattern_tac pattern in
+ let _cpattern =
+ match pattern with
+ | None, [], Some cpattern ->
+ let rec is_hole =
+ function
+ Cic.Implicit (Some `Hole) -> true
+ | Cic.Prod (Cic.Anonymous,so,tgt) -> is_hole so && is_hole tgt
+ | _ -> false
+ in
+ if not (is_hole cpattern) then
+ raise (PET.Fail (lazy "not implemented"))
+ | _ -> raise (PET.Fail (lazy "not implemented")) in
let termty,_ = TC.type_of_aux' metasenv context term CicUniv.oblivion_ugraph in
let termty = CicReduction.whd context termty in
let (termty,metasenv',arguments,fresh_meta) =
in
proof'', patched_new_goals
in
- PET.mk_tactic (cases_tac ~term)
+ let reorder_pattern ((proof, goal) as status) =
+ let _,metasenv,_,_,_,_ = proof in
+ let conjecture = CicUtil.lookup_meta goal metasenv in
+ let _,context,_ = conjecture in
+ let pattern = ProofEngineHelpers.sort_pattern_hyps context pattern in
+ PET.apply_tactic
+ (Tacticals.then_ ~start:(generalize_pattern_tac pattern)
+ ~continuation:(PET.mk_tactic (cases_tac pattern))) status
+ in
+ PET.mk_tactic reorder_pattern
;;
val cases_intros_tac:
?howmany:int ->
?mk_fresh_name_callback:ProofEngineTypes.mk_fresh_name_type ->
- Cic.term -> ProofEngineTypes.tactic
+ ?pattern:ProofEngineTypes.lazy_pattern -> Cic.term ->
+ ProofEngineTypes.tactic
(* FG *)
val cases_intros :
?howmany:int ->
?mk_fresh_name_callback:ProofEngineTypes.mk_fresh_name_type ->
+ ?pattern:ProofEngineTypes.lazy_pattern ->
Cic.term -> ProofEngineTypes.tactic
val change :
?with_cast:bool ->