@@ -598,9 +598,10 @@ let process_rewrite1_core ?mode ?(close = true) ?target (s, p, o) pt tc =
598598 tc_error !! tc " r-pattern does not match the rewriting rule"
599599
600600(* -------------------------------------------------------------------- *)
601- let process_delta ~und_delta ?target (s , o , p ) tc =
601+ let process_delta ~und_delta ?( rigid = false ) ? target (s , o , p ) tc =
602602 let env, hyps, concl = FApi. tc1_eflat tc in
603603 let o = norm_rwocc o in
604+ let occmode = if rigid then Some om_rigid else None in
604605
605606 let idtg, target =
606607 match target with
@@ -668,7 +669,7 @@ let process_delta ~und_delta ?target (s, o, p) tc =
668669 match s with
669670 | `LtoR -> begin
670671 let matches =
671- try ignore (PT. pf_find_occurence ptenv ~ptn: p target); true
672+ try ignore (PT. pf_find_occurence ptenv ?occmode ~ptn: p target); true
672673 with PT. FindOccFailure _ -> false
673674 in
674675
@@ -729,23 +730,26 @@ let process_delta ~und_delta ?target (s, o, p) tc =
729730 with EcEnv. NotReducible -> fp
730731 in
731732
732- let matches =
733- try ignore (PT. pf_find_occurence ptenv ~ptn: fp target); true
734- with PT. FindOccFailure _ -> false
735- in
733+ begin
734+ match PT. pf_find_occurence ?occmode ptenv ~ptn: fp target with
735+ | (_ , occmode ) ->
736+ let p = concretize_form ptenv p in
737+ let fp = concretize_form ptenv fp in
738+ let cpos =
739+ try
740+ FPosition. select_form
741+ ~xconv: (if rigid then `AlphaEq else `Conv )
742+ ~keyed: occmode.k_keyed
743+ hyps o fp target
744+ with InvalidOccurence ->
745+ tc_error !! tc " invalid occurences selector" in
736746
737- if matches then begin
738- let p = concretize_form ptenv p in
739- let fp = concretize_form ptenv fp in
740- let cpos =
741- try FPosition. select_form hyps o fp target
742- with InvalidOccurence ->
743- tc_error !! tc " invalid occurences selector"
744- in
747+ let target = FPosition. map cpos (fun _ -> p) target in
748+ t_change ~ri ?target:idtg target tc
745749
746- let target = FPosition. map cpos ( fun _ -> p) target in
747- t_change ~ri ?target:idtg target tc
748- end else t_id tc
750+ | exception ( PT. FindOccFailure _ ) ->
751+ t_id tc
752+ end
749753
750754(* -------------------------------------------------------------------- *)
751755let process_rewrite1_r ttenv ?target ri tc =
@@ -768,11 +772,11 @@ let process_rewrite1_r ttenv ?target ri tc =
768772 let target = target |> omap (fst -| ((LDecl. hyp_by_name^~ hyps) -| unloc)) in
769773 t_simplify_lg ?target ~delta: `IfApplied (ttenv, logic) tc
770774
771- | RWDelta ((s , r , o , px ), p ) -> begin
775+ | RWDelta (rigid , (s , r , o , px ), p ) -> begin
772776 if Option. is_some px then
773777 tc_error !! tc " cannot use pattern selection in delta-rewrite rules" ;
774778
775- let do1 tc = process_delta ~und_delta ?target (s, o, p) tc in
779+ let do1 tc = process_delta ~und_delta ~rigid ?target (s, o, p) tc in
776780
777781 match r with
778782 | None -> do1 tc
0 commit comments