X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;ds=sidebyside;f=helm%2Fsoftware%2Fcomponents%2Ftactics%2Ftacticals.ml;h=f647ebccaa9d199181761b2233c59f00ace13f1d;hb=623cbb7a784ce2d983608ee4a44bf386dfe01bbc;hp=f3f7793032365bb5194137002b9356e0a2a80881;hpb=c6cc2a7227d6750076f591a62d7b1896ebf1ebfa;p=helm.git diff --git a/helm/software/components/tactics/tacticals.ml b/helm/software/components/tactics/tacticals.ml index f3f779303..f647ebcca 100644 --- a/helm/software/components/tactics/tacticals.ml +++ b/helm/software/components/tactics/tacticals.ml @@ -113,7 +113,7 @@ struct back to obtain the result of the tactic *) let mk_tactic f = PET.mk_tactic - (fun (proof, goal) as pstatus -> + (fun ((proof, goal) as pstatus) -> let stack = [ [ 1, Stack.Open goal ], [], [], `NoTag ] in let istatus = pstatus, stack in let (proof, _, _), stack = f istatus in @@ -182,6 +182,42 @@ let seq ~tactics = (* Tacticals that cannot be implemented on top of tynycals *) +let const_tac res = PET.mk_tactic (fun _ -> res) + +let if_ ~start ~continuation ~fail = + let if_ status = + let xoutput = + try + let result = PET.apply_tactic start status in + info (lazy ("Tacticals.if_: succedeed!!!")); + Some result + with PET.Fail _ -> None + in + let tactic = match xoutput with + | Some res -> then_ ~start:(const_tac res) ~continuation + | None -> fail + in + PET.apply_tactic tactic status + in + PET.mk_tactic if_ + +let ifs ~start ~continuations ~fail = + let ifs status = + let xoutput = + try + let result = PET.apply_tactic start status in + info (lazy ("Tacticals.ifs: succedeed!!!")); + Some result + with PET.Fail _ -> None + in + let tactic = match xoutput with + | Some res -> thens ~start:(const_tac res) ~continuations + | None -> fail + in + PET.apply_tactic tactic status + in + PET.mk_tactic ifs + let first ~tactics = let rec first ~(tactics: tactic list) status = info (lazy "in Tacticals.first"); @@ -197,7 +233,6 @@ let first ~tactics = in PET.mk_tactic (first ~tactics) - let rec do_tactic ~n ~tactic = PET.mk_tactic (function status ->