X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Ftactics%2FdiscriminationTactics.ml;h=15d7968d34c5476e5192fa4c085c4d544bccc59f;hb=d3c72d6856cd185e5b3e9f2e8b928b78c7031ed1;hp=c413d4694e266ae35a48f76f18bf1878217689f2;hpb=caf8d6cf32c9a9ec8d3fba0aa912d080ff5f7d52;p=helm.git diff --git a/helm/ocaml/tactics/discriminationTactics.ml b/helm/ocaml/tactics/discriminationTactics.ml index c413d4694..15d7968d3 100644 --- a/helm/ocaml/tactics/discriminationTactics.ml +++ b/helm/ocaml/tactics/discriminationTactics.ml @@ -23,6 +23,7 @@ * http://cs.unibo.it/helm/. *) +open HelmLibraryObjects let rec injection_tac ~term ~status:((proof, goal) as status) = let module C = Cic in @@ -30,12 +31,12 @@ let rec injection_tac ~term ~status:((proof, goal) as status) = let module P = PrimitiveTactics in let module T = Tacticals in let _,metasenv,_,_ = proof in - let _,context,_ = List.find (function (m,_,_) -> m=goal) metasenv in + let _,context,_ = CicUtil.lookup_meta goal metasenv in let termty = (CicTypeChecker.type_of_aux' metasenv context term) in (match termty with (C.Appl [(C.MutInd (equri, 0, [])) ; tty ; t1 ; t2]) - when (U.eq equri (U.uri_of_string "cic:/Coq/Init/Logic/eq.ind")) - or (U.eq equri (U.uri_of_string "cic:/Coq/Init/Logic_Type/eqT.ind")) -> ( + when (U.eq equri Logic.eq_URI) + or (U.eq equri Logic_Type.eqt_URI) -> ( match tty with (C.MutInd (turi,typeno,exp_named_subst)) | (C.Appl (C.MutInd (turi,typeno,exp_named_subst)::_)) -> ( @@ -82,12 +83,12 @@ and injection1_tac ~term ~i ~status:((proof, goal) as status) = let module P = PrimitiveTactics in let module T = Tacticals in let _,metasenv,_,_ = proof in - let _,context,_ = List.find (function (m,_,_) -> m=goal) metasenv in + let _,context,_ = CicUtil.lookup_meta goal metasenv in let termty = (CicTypeChecker.type_of_aux' metasenv context term) in match termty with (* an equality *) (C.Appl [(C.MutInd (equri, 0, [])) ; tty ; t1 ; t2]) - when (U.eq equri (U.uri_of_string "cic:/Coq/Init/Logic/eq.ind")) - or (U.eq equri (U.uri_of_string "cic:/Coq/Init/Logic_Type/eqT.ind")) -> ( + when (U.eq equri Logic.eq_URI) or + (U.eq equri Logic_Type.eqt_URI) -> ( match tty with (* some inductive type *) (C.MutInd (turi,typeno,exp_named_subst)) | (C.Appl (C.MutInd (turi,typeno,exp_named_subst)::_)) -> @@ -150,7 +151,7 @@ prerr_endline ("XXXX cominciamo!") ; ~start: (fun ~status:((proof,goal) as status) -> let _,metasenv,_,_ = proof in - let _,context,gty = List.find (function (m,_,_) -> m=goal) metasenv in + let _,context,gty = CicUtil.lookup_meta goal metasenv in prerr_endline ("XXXX goal " ^ string_of_int goal) ; prerr_endline ("XXXX gty " ^ CicPp.ppterm gty) ; prerr_endline ("XXXX old t1' " ^ CicPp.ppterm t1') ; @@ -206,12 +207,11 @@ let discriminate'_tac ~term ~status:((proof, goal) as status) = let module P = PrimitiveTactics in let module T = Tacticals in let _,metasenv,_,_ = proof in - let _,context,_ = List.find (function (m,_,_) -> m=goal) metasenv in + let _,context,_ = CicUtil.lookup_meta goal metasenv in let termty = (CicTypeChecker.type_of_aux' metasenv context term) in match termty with (C.Appl [(C.MutInd (equri, 0, [])) ; tty ; t1 ; t2]) - when (U.eq equri (U.uri_of_string "cic:/Coq/Init/Logic/eq.ind")) - or (U.eq equri (U.uri_of_string "cic:/Coq/Init/Logic_Type/eqT.ind")) -> ( + when (U.eq equri Logic.eq_URI) or (U.eq equri Logic_Type.eqt_URI) -> ( match tty with (C.MutInd (turi,typeno,exp_named_subst)) | (C.Appl (C.MutInd (turi,typeno,exp_named_subst)::_)) -> @@ -275,8 +275,8 @@ prerr_endline ("XXXX nth funzionano ") ; C.Lambda (binder,source,(aux target (k+1))) | _ -> if (id = false_constr_id) - then (C.MutInd((U.uri_of_string "cic:/Coq/Init/Logic/False.ind"),0,[])) - else (C.MutInd((U.uri_of_string "cic:/Coq/Init/Logic/True.ind"),0,[])) + then (C.MutInd(Logic.false_URI,0,[])) + else (C.MutInd(Logic.true_URI,0,[])) in aux red_ty 1 ) constructor_list @@ -285,27 +285,15 @@ prerr_endline ("XXXX nth funzionano ") ; let (proof',goals') = EliminationTactics.elim_type_tac - ~term:(C.MutInd((U.uri_of_string "cic:/Coq/Init/Logic/False.ind"),0,[])) + ~term:(C.MutInd(Logic.false_URI,0,[])) ~status in (match goals' with [goal'] -> let _,metasenv',_,_ = proof' in - let _,context',gty' = List.find (function (m,_,_) -> m=goal') metasenv' in -prerr_endline ("XXXX gty " ^ CicPp.ppterm gty') ; -prerr_endline ("XXXX tty " ^ CicPp.ppterm tty) ; -prerr_endline ("XXXX t1 " ^ CicPp.ppterm t1) ; -prerr_endline ("XXXX t2 " ^ CicPp.ppterm t2) ; -ignore (List.map (fun t -> prerr_endline ("XXXX t " ^ CicPp.ppterm t)) pattern) ; -prerr_endline ("XXXX case " ^ CicPp.ppterm (C.Appl [ - C.Lambda ( - C.Name "x", tty, - C.MutCase ( - turi, typeno, - (C.Lambda ((C.Name "x"),tty,(C.Sort C.Prop))), - (C.Rel 1), pattern - ) - ); t2])) ; + let _,context',gty' = + CicUtil.lookup_meta goal' metasenv' + in T.then_ ~start: (P.change_tac @@ -375,7 +363,7 @@ let compare_tac ~term ~status:((proof, goal) as status) = Tacticals.id_tac ~stat let module P = PrimitiveTactics in let module T = Tacticals in let _,metasenv,_,_ = proof in - let _,context,gty = List.find (function (m,_,_) -> m=goal) metasenv in + let _,context,gty = CicUtil.lookup_meta goal metasenv in let termty = (CicTypeChecker.type_of_aux' metasenv context term) in match termty with (C.Appl [(C.MutInd (uri, 0, [])); _; t1; t2]) when (uri = (U.uri_of_string "cic:/Coq/Init/Logic/eq.ind")) -> @@ -431,7 +419,7 @@ let discriminate_tac ~term ~status:((proof, goal) as status) = let module P = PrimitiveTactics in let module T = Tacticals in let _,metasenv,_,_ = proof in - let _,context,_ = List.find (function (m,_,_) -> m=goal) metasenv in + let _,context,_ = CicUtil.lookup_meta goal metasenv in let termty = (CicTypeChecker.type_of_aux' metasenv context term) in match termty with (C.Appl [(C.MutInd (equri, 0, [])) ; tty ; t1 ; t2]) @@ -516,21 +504,9 @@ prerr_endline ("XXXX nth funzionano ") ; (match goals' with [goal'] -> let _,metasenv',_,_ = proof' in - let _,context',gty' = List.find (function (m,_,_) -> m=goal') metasenv' in -prerr_endline ("XXXX gty " ^ CicPp.ppterm gty') ; -prerr_endline ("XXXX tty " ^ CicPp.ppterm tty) ; -prerr_endline ("XXXX t1' " ^ CicPp.ppterm t1') ; -prerr_endline ("XXXX t2' " ^ CicPp.ppterm t2') ; -ignore (List.map (fun t -> prerr_endline ("XXXX t " ^ CicPp.ppterm t)) pattern) ; -prerr_endline ("XXXX case " ^ CicPp.ppterm (C.Appl [ - C.Lambda ( - C.Name "x", tty, - C.MutCase ( - turi, typeno, - (C.Lambda ((C.Name "x"),tty,(C.Sort C.Prop))), - (C.Rel 1), pattern - ) - ); t2'])) ; + let _,context',gty' = + CicUtil.lookup_meta goal' metasenv' + in T.then_ ~start: (P.change_tac