From 706fcc9a5598a85d3d63ad0c9dd4245c8e0233f6 Mon Sep 17 00:00:00 2001 From: Ferruccio Guidi Date: Wed, 13 May 2009 18:44:42 +0000 Subject: [PATCH] - matitaEngine: some commands like "coercion" must not be executed when mma's are dumped. This hack will be removed when mma's will be executed while dumped - primitiveTactics: bugxix in the generation of the predicate for elim: we leave to the refiner the task of instantiating the types of the pattern variables. Note: the head beta-reductions after the elimination must be performed following the instantiated predicate because (\lambda x:?.t v) does not beta-reduce (bug or feature?) --- .../software/components/tactics/primitiveTactics.ml | 13 +++++++++---- helm/software/matita/matitaEngine.ml | 12 ++++++++++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/helm/software/components/tactics/primitiveTactics.ml b/helm/software/components/tactics/primitiveTactics.ml index 420934944..2862d3c5d 100644 --- a/helm/software/components/tactics/primitiveTactics.ml +++ b/helm/software/components/tactics/primitiveTactics.ml @@ -526,16 +526,16 @@ let mk_predicate_for_elim let map (_context_of_t, t) l = t :: l in let what = List.fold_right map selected_terms [] in let arg' = MS.apply_subst subst arg' in - let argty = MS.apply_subst subst argty in let pred = PER.replace_with_rel_1_from ~equality:(==) ~what 1 pred in let pred = MS.apply_subst subst pred in - let pred = C.Lambda (fresh_name, argty, pred) in + let pred = C.Lambda (fresh_name, C.Implicit None, pred) in let cpattern' = C.Lambda (C.Anonymous, C.Implicit None, cpattern') in mk_pred metasenv subst (hyp :: context') pred arg' cpattern' tail in let metasenv, subst, pred, arg = mk_pred metasenv subst context goal arg cpattern (List.rev actual_args) in + HLog.debug ("PREDICATE CONTEXT:\n" ^ CicPp.ppcontext ~metasenv context); HLog.debug ("PREDICATE: " ^ CicPp.ppterm ~metasenv pred ^ " ARGS: " ^ String.concat " " (List.map (CicPp.ppterm ~metasenv) actual_args)); metasenv, subst, pred, arg, actual_args @@ -847,6 +847,10 @@ let elim_tac ?using ?(pattern = PET.conclusion_pattern None) term = let refined_term,_refined_termty,metasenv'',subst,_ugraph = CicRefine.type_of metasenv' subst context term_to_refine ugraph in + let ipred = match refined_term with + | C.Appl ts -> List.nth ts (List.length ts - pred_pos) + | _ -> assert false + in let new_goals = ProofEngineHelpers.compare_metasenvs ~oldmetasenv:metasenv ~newmetasenv:metasenv'' @@ -864,8 +868,9 @@ let elim_tac ?using ?(pattern = PET.conclusion_pattern None) term = in let res = proof'', patched_new_goals in let upto = List.length actual_args in - if upto = 0 then res else - let continuation = beta_after_elim_tac upto pred in + if upto = 0 then res else +(* FG: we use ipred (instantiated pred) instead of pred (not instantiated) *) + let continuation = beta_after_elim_tac upto ipred in let dummy_status = proof,goal in PET.apply_tactic (T.then_ ~start:(PET.mk_tactic (fun _ -> res)) ~continuation) diff --git a/helm/software/matita/matitaEngine.ml b/helm/software/matita/matitaEngine.ml index e2bb6feb9..a8dcf9809 100644 --- a/helm/software/matita/matitaEngine.ml +++ b/helm/software/matita/matitaEngine.ml @@ -25,7 +25,7 @@ (* $Id$ *) -open Printf +module G = GrafiteAst let debug = false ;; let debug_print = if debug then prerr_endline else ignore ;; @@ -61,6 +61,7 @@ let disambiguate_macro lexicon_status_ref grafite_status macro context = let eval_ast ?do_heavy_checks lexicon_status grafite_status (text,prefix_len,ast) = + let dump = not (Helm_registry.get_bool "matita.moo") in let lexicon_status_ref = ref lexicon_status in let baseuri = GrafiteTypes.get_baseuri grafite_status in let changed_lexicon = ref false in @@ -76,11 +77,18 @@ let eval_ast ?do_heavy_checks lexicon_status { s with NTacStatus.istatus = { s.NTacStatus.istatus with NTacStatus.lstatus = lexicon_status }}} in let new_grafite_status,new_objs = + match ast with + | G.Executable (_, G.Command (_, G.Coercion _)) when dump -> +(* FG: some commands can not be executed when mmas are parsed *************) +(* To be removed when mmas will be executed *) + grafite_status, `Old [] + | ast -> GrafiteEngine.eval_ast ~disambiguate_tactic:(wrap (disambiguate_tactic text prefix_len lexicon_status_ref)) ~disambiguate_command:(wrap (disambiguate_command lexicon_status_ref)) ~disambiguate_macro:(wrap (disambiguate_macro lexicon_status_ref)) - ?do_heavy_checks grafite_status (text,prefix_len,ast) in + ?do_heavy_checks grafite_status (text,prefix_len,ast) + in let new_lexicon_status = if !changed_lexicon then !lexicon_status_ref -- 2.39.2