From: Michele Galatà ?> Date: Thu, 31 Oct 2002 14:49:40 +0000 (+0000) Subject: Added variousTactic with Constructor, Left, Right, Exists, Reflexivity, Symmetry... X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=373eaf73bebec626e031a4a534ddfdd4f1c1b474;p=helm.git Added variousTactic with Constructor, Left, Right, Exists, Reflexivity, Symmetry, Transitivity Added tacticals Repeat, Do, Try, Solve --- diff --git a/helm/gTopLevel/.depend b/helm/gTopLevel/.depend index bcf5bbd72..88a318793 100644 --- a/helm/gTopLevel/.depend +++ b/helm/gTopLevel/.depend @@ -22,24 +22,31 @@ primitiveTactics.cmx: proofEngineHelpers.cmx proofEngineReduction.cmx \ proofEngineTypes.cmx reductionTactics.cmx tacticals.cmx \ primitiveTactics.cmi primitiveTactics.cmi: proofEngineTypes.cmo +variousTactics.cmo: primitiveTactics.cmi proofEngineTypes.cmo tacticals.cmi \ + variousTactics.cmi +variousTactics.cmx: primitiveTactics.cmx proofEngineTypes.cmx tacticals.cmx \ + variousTactics.cmi +variousTactics.cmi: proofEngineTypes.cmo ring.cmo: primitiveTactics.cmi proofEngineStructuralRules.cmi \ - proofEngineTypes.cmo tacticals.cmi ring.cmi + proofEngineTypes.cmo tacticals.cmi variousTactics.cmi ring.cmi ring.cmx: primitiveTactics.cmx proofEngineStructuralRules.cmx \ - proofEngineTypes.cmx tacticals.cmx ring.cmi + proofEngineTypes.cmx tacticals.cmx variousTactics.cmx ring.cmi ring.cmi: proofEngineTypes.cmo fourierR.cmo: fourier.cmo primitiveTactics.cmi proofEngineHelpers.cmi \ - proofEngineReduction.cmi proofEngineTypes.cmo ring.cmi tacticals.cmi \ - fourierR.cmi + proofEngineReduction.cmi proofEngineTypes.cmo reductionTactics.cmi \ + ring.cmi tacticals.cmi fourierR.cmi fourierR.cmx: fourier.cmx primitiveTactics.cmx proofEngineHelpers.cmx \ - proofEngineReduction.cmx proofEngineTypes.cmx ring.cmx tacticals.cmx \ - fourierR.cmi + proofEngineReduction.cmx proofEngineTypes.cmx reductionTactics.cmx \ + ring.cmx tacticals.cmx fourierR.cmi fourierR.cmi: proofEngineTypes.cmo proofEngine.cmo: fourierR.cmi primitiveTactics.cmi proofEngineHelpers.cmi \ proofEngineReduction.cmi proofEngineStructuralRules.cmi \ - proofEngineTypes.cmo ring.cmi proofEngine.cmi + proofEngineTypes.cmo ring.cmi tacticals.cmi variousTactics.cmi \ + proofEngine.cmi proofEngine.cmx: fourierR.cmx primitiveTactics.cmx proofEngineHelpers.cmx \ proofEngineReduction.cmx proofEngineStructuralRules.cmx \ - proofEngineTypes.cmx ring.cmx proofEngine.cmi + proofEngineTypes.cmx ring.cmx tacticals.cmx variousTactics.cmx \ + proofEngine.cmi proofEngine.cmi: proofEngineTypes.cmo doubleTypeInference.cmo: doubleTypeInference.cmi doubleTypeInference.cmx: doubleTypeInference.cmi diff --git a/helm/gTopLevel/Makefile b/helm/gTopLevel/Makefile index b2680c27b..200305cbe 100644 --- a/helm/gTopLevel/Makefile +++ b/helm/gTopLevel/Makefile @@ -18,7 +18,7 @@ DEPOBJS = xml2Gdome.ml xml2Gdome.mli proofEngineTypes.ml proofEngineHelpers.ml \ proofEngineReduction.ml proofEngineReduction.mli \ proofEngineStructuralRules.ml proofEngineStructuralRules.mli \ tacticals.ml tacticals.mli reductionTactics.ml reductionTactics.mli \ - primitiveTactics.ml primitiveTactics.mli \ + primitiveTactics.ml primitiveTactics.mli variousTactics.ml variousTactics.mli \ ring.ml ring.mli fourier.ml fourierR.ml fourierR.mli\ proofEngine.ml proofEngine.mli \ doubleTypeInference.ml doubleTypeInference.mli cic2acic.ml \ @@ -29,6 +29,7 @@ DEPOBJS = xml2Gdome.ml xml2Gdome.mli proofEngineTypes.ml proofEngineHelpers.ml \ TOPLEVELOBJS = xml2Gdome.cmo proofEngineTypes.cmo proofEngineHelpers.cmo \ proofEngineReduction.cmo proofEngineStructuralRules.cmo \ tacticals.cmo reductionTactics.cmo primitiveTactics.cmo \ + variousTactics.cmo \ ring.cmo fourier.cmo fourierR.cmo proofEngine.cmo \ doubleTypeInference.cmo cic2acic.cmo cic2Xml.cmo \ logicalOperations.cmo sequentPp.cmo mQueryGenerator.cmo \ diff --git a/helm/gTopLevel/esempi/various.cic b/helm/gTopLevel/esempi/various.cic new file mode 100644 index 000000000..11141d4ab --- /dev/null +++ b/helm/gTopLevel/esempi/various.cic @@ -0,0 +1,7 @@ + +!n:nat.(eq nat n n) + +!n:nat.!m:nat.(eq nat n m)->(eq nat m n) + +!n:nat.!m:nat.!p:nat.(eq nat n p)->(eq nat p m)->(eq nat n m) + diff --git a/helm/gTopLevel/fourierR.ml b/helm/gTopLevel/fourierR.ml index c8c856459..247a47248 100644 --- a/helm/gTopLevel/fourierR.ml +++ b/helm/gTopLevel/fourierR.ml @@ -1048,7 +1048,7 @@ theoreme,so let's parse our thesis *) " disequazioni\n"); let res=fourier_lineq (!lineq) in - let tac=ref Ring.id_tac in + let tac=ref Tacticals.id_tac in if res=[] then (print_string "Tactic Fourier fails.\n";flush stdout; failwith "fourier_tac fails") @@ -1234,7 +1234,7 @@ theoreme,so let's parse our thesis *) let r = Ring.ring_tac ~status in debug ("end RING\n"); r) - ; "id", Ring.id_tac] + ; "id", Tacticals.id_tac] ]) (* CSC: NOW THE BUG IS HERE: tac2 DOES NOT WORK ANY MORE *) ;tac2])) diff --git a/helm/gTopLevel/gTopLevel.ml b/helm/gTopLevel/gTopLevel.ml index d0aef1a04..4a7302832 100644 --- a/helm/gTopLevel/gTopLevel.ml +++ b/helm/gTopLevel/gTopLevel.ml @@ -61,15 +61,21 @@ let htmlfooter = (* let prooffile = "/home/tassi/miohelm/tmp/currentproof";; -*) let prooffile = "/public/sacerdot/currentproof";; -let prooffiletype = "/public/sacerdot/currentprooftype";; +*) + +let prooffile = "/home/galata/miohelm/currentproof";; +let prooffiletype = "/home/galata/miohelm/currentprooftype";; + (*CSC: the getter should handle the innertypes, not the FS *) (* let innertypesfile = "/home/tassi/miohelm/tmp/innertypes";; -*) let innertypesfile = "/public/sacerdot/innertypes";; -let constanttypefile = "/public/sacerdot/constanttype";; +*) + +let innertypesfile = "/home/galata/miohelm/innertypes";; +let constanttypefile = "/home/galata/miohelm/constanttype";; + (* GLOBAL REFERENCES (USED BY CALLBACKS) *) @@ -747,7 +753,29 @@ let fourier rendering_window = let rewritesimpl rendering_window = call_tactic_with_input ProofEngine.rewrite_simpl rendering_window ;; - +let reflexivity rendering_window = + call_tactic ProofEngine.reflexivity rendering_window +;; +let symmetry rendering_window = + call_tactic ProofEngine.symmetry rendering_window +;; +let transitivity rendering_window = + call_tactic_with_input ProofEngine.transitivity rendering_window +;; +let left rendering_window = + call_tactic ProofEngine.left rendering_window +;; +let right rendering_window = + call_tactic ProofEngine.right rendering_window +;; +let assumption rendering_window = + call_tactic ProofEngine.assumption rendering_window +;; +(* +let prova_tatticali rendering_window = + call_tactic ProofEngine.prova_tatticali rendering_window +;; +*) let whd_in_scratch scratch_window = @@ -1592,6 +1620,27 @@ class rendering_window output proofw (label : GMisc.label) = let rewritesimplb = GButton.button ~label:"RewriteSimpl ->" ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in + let reflexivityb = + GButton.button ~label:"Reflexivity" + ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in + let symmetryb = + GButton.button ~label:"Symmetry" + ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in + let transitivityb = + GButton.button ~label:"Transitivity" + ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in + let leftb = + GButton.button ~label:"Left" + ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in + let rightb = + GButton.button ~label:"Right" + ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in + let assumptionb = + GButton.button ~label:"Assumption" + ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in + let prova_tatticalib = + GButton.button ~label:"Prova_tatticali" + ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in let outputhtml = GHtml.xmhtml ~source:"
" @@ -1647,6 +1696,15 @@ object(self) ignore(clearb#connect#clicked (clear self)) ; ignore(fourierb#connect#clicked (fourier self)) ; ignore(rewritesimplb#connect#clicked (rewritesimpl self)) ; + ignore(reflexivityb#connect#clicked (reflexivity self)) ; + ignore(symmetryb#connect#clicked (symmetry self)) ; + ignore(transitivityb#connect#clicked (transitivity self)) ; + ignore(leftb#connect#clicked (left self)) ; + ignore(rightb#connect#clicked (right self)) ; + ignore(assumptionb#connect#clicked (assumption self)) ; +(* + ignore(prova_tatticalib#connect#clicked (prova_tatticali self)) ; +*) ignore(introsb#connect#clicked (intros self)) ; Logger.log_callback := (Logger.log_to_html ~print_and_flush:(output_html outputhtml)) diff --git a/helm/gTopLevel/proofEngine.ml b/helm/gTopLevel/proofEngine.ml index 972ae962a..b47f8856a 100644 --- a/helm/gTopLevel/proofEngine.ml +++ b/helm/gTopLevel/proofEngine.ml @@ -288,3 +288,16 @@ let elim_type term = apply_tactic (Ring.elim_type_tac ~term) let ring () = apply_tactic Ring.ring_tac let fourier () = apply_tactic FourierR.fourier_tac let rewrite_simpl term = apply_tactic (FourierR.rewrite_simpl_tac ~term) + +let reflexivity () = apply_tactic VariousTactics.reflexivity_tac +let symmetry () = apply_tactic VariousTactics.symmetry_tac +let transitivity term = apply_tactic (VariousTactics.transitivity_tac ~term) + +let left () = apply_tactic VariousTactics.left_tac +let right () = apply_tactic VariousTactics.right_tac + +let assumption () = apply_tactic VariousTactics.assumption_tac +(* +let prova_tatticali () = apply_tactic Tacticals.prova_tac +*) + diff --git a/helm/gTopLevel/proofEngine.mli b/helm/gTopLevel/proofEngine.mli index c3b623c08..cbe4c8bc5 100644 --- a/helm/gTopLevel/proofEngine.mli +++ b/helm/gTopLevel/proofEngine.mli @@ -60,3 +60,16 @@ val elim_type : Cic.term -> unit val ring : unit -> unit val fourier : unit -> unit val rewrite_simpl : Cic.term -> unit + +val reflexivity : unit -> unit +val symmetry : unit -> unit +val transitivity : Cic.term -> unit + +val left : unit -> unit +val right : unit -> unit + +val assumption : unit -> unit + +(* +val prova_tatticali : unit -> unit +*) diff --git a/helm/gTopLevel/ring.ml b/helm/gTopLevel/ring.ml index d30df1aaa..399d2c289 100644 --- a/helm/gTopLevel/ring.ml +++ b/helm/gTopLevel/ring.ml @@ -397,8 +397,6 @@ let build_segments ~terms = Cic.Appl [apolynomial_normalize_ok lxy_false varmap rtheory ; t] ) aterms -let id_tac ~status:(proof,goal) = - (proof,[goal]) let status_of_single_goal_tactic_result = function @@ -414,7 +412,7 @@ let status_of_single_goal_tactic_result = let elim_type_tac ~term ~status = warn "in Ring.elim_type_tac"; Tacticals.thens ~start:(cut_tac ~term) - ~continuations:[elim_simpl_intros_tac ~term:(Cic.Rel 1) ; id_tac] ~status + ~continuations:[elim_simpl_intros_tac ~term:(Cic.Rel 1) ; Tacticals.id_tac] ~status (** auxiliary tactic, use elim_type and try to close 2nd subgoal using proof @@ -425,8 +423,9 @@ let elim_type_tac ~term ~status = let elim_type2_tac ~term ~proof ~status = warn "in Ring.elim_type2"; Tacticals.thens ~start:(elim_type_tac ~term) - ~continuations:[id_tac ; exact_tac ~term:proof] ~status + ~continuations:[Tacticals.id_tac ; exact_tac ~term:proof] ~status +(* spostata in variousTactics.ml (** Reflexivity tactic, try to solve current goal using "refl_eqT" Warning: this isn't equale to the coq's Reflexivity because this one tries @@ -441,6 +440,7 @@ let reflexivity_tac ~status:(proof, goal) = with (Fail _) as e -> let e_str = Printexc.to_string e in raise (Fail ("Reflexivity failed with exception: " ^ e_str)) +*) (** lift an 8-uple of debrujins indexes of n *) let lift ~n (a,b,c,d,e,f,g,h) = @@ -498,7 +498,7 @@ let ring_tac ~status:((proof, goal) as status) = Tacticals.try_tactics ~status ~tactics:[ - "reflexivity", reflexivity_tac ; + "reflexivity", VariousTactics.reflexivity_tac ; "exact t1'_eq_t1''", exact_tac ~term:t1'_eq_t1'' ; "exact t2'_eq_t2''", exact_tac ~term:t2'_eq_t2'' ; "exact sym_eqt su t1 ...", exact_tac @@ -570,7 +570,7 @@ let ring_tac ~status:((proof, goal) as status) = in try (* try to solve main goal *) warn "trying reflexivity ...."; - reflexivity_tac ~status:status' + VariousTactics.reflexivity_tac ~status:status' with (Fail _) -> (* leave conclusion to the user *) warn "reflexivity failed, solution's left as an ex :-)"; purge_hyps_tac ~count:!new_hyps ~status:status')] diff --git a/helm/gTopLevel/ring.mli b/helm/gTopLevel/ring.mli index 224f150cc..79cb6f559 100644 --- a/helm/gTopLevel/ring.mli +++ b/helm/gTopLevel/ring.mli @@ -4,5 +4,7 @@ val ring_tac: ProofEngineTypes.tactic (* auxiliary tactics *) val elim_type_tac: term: Cic.term -> ProofEngineTypes.tactic + +(* spostata in variousTactics.ml val reflexivity_tac: ProofEngineTypes.tactic -val id_tac : ProofEngineTypes.tactic +*) diff --git a/helm/gTopLevel/tacticals.ml b/helm/gTopLevel/tacticals.ml index 2c1b1883b..d48b6a02c 100644 --- a/helm/gTopLevel/tacticals.ml +++ b/helm/gTopLevel/tacticals.ml @@ -37,22 +37,32 @@ let warn s = if debug then prerr_endline ("TACTICALS WARNING: " ^ s) -(** AUX TACTIC{,AL}S *) + +(** TACTIC{,AL}S *) + + (* not a tactical, but it's used only here (?) *) + +let id_tac ~status:(proof,goal) = + (proof,[goal]) + (** naive implementation of ORELSE tactical, try a sequence of tactics in turn: if one fails pass to the next one and so on, eventually raises (failure "no tactics left") TODO warning: not tail recursive due to "try .. with" boxing + + Galla: is this exactly Coq's "First"? + *) let rec try_tactics ~(tactics: (string * tactic) list) ~status = - warn "in Ring.try_tactics"; + warn "in Tacticals.try_tactics"; match tactics with | (descr, tac)::tactics -> - warn ("Ring.try_tactics IS TRYING " ^ descr); + warn ("Tacticals.try_tactics IS TRYING " ^ descr); (try let res = tac ~status in - warn ("Ring.try_tactics: " ^ descr ^ " succedeed!!!"); + warn ("Tacticals.try_tactics: " ^ descr ^ " succedeed!!!"); res with e -> @@ -61,13 +71,15 @@ let rec try_tactics ~(tactics: (string * tactic) list) ~status = | (CicTypeChecker.NotWellTyped _) | (CicUnification.UnificationFailed) -> warn ( - "Ring.try_tactics failed with exn: " ^ + "Tacticals.try_tactics failed with exn: " ^ Printexc.to_string e); try_tactics ~tactics ~status | _ -> raise e (* [e] must not be caught ; let's re-raise it *) ) | [] -> raise (Fail "try_tactics: no tactics left") + + let thens ~start ~continuations ~status = let (proof,new_goals) = start ~status in try @@ -79,6 +91,8 @@ let thens ~start ~continuations ~status = with Invalid_argument _ -> raise (Fail "thens: wrong number of new goals") + + let then_ ~start ~continuation ~status = let (proof,new_goals) = start ~status in List.fold_left @@ -86,3 +100,145 @@ let then_ ~start ~continuation ~status = let (proof',new_goals') = continuation ~status:(proof,goal) in (proof',goals@new_goals') ) (proof,[]) new_goals + + +(* Galla *) +(* si suppone che tutte le tattiche sollevano solamente Fail? *) + +(* TODO: x debug: i due tatticali seguenti non contano quante volte hanno applicato la tattica *) + +(* This keep on appling tactic until it fails *) +(* When