Skip to content

Commit d100a1e

Browse files
committed
refactor(match): retry f_match_core under eta-normalisation
When [f_match_core] hits a mismatch it already tries beta-reduction, higher-order matching, and delta-unfolding. Adds an eta-normalisation fallback that runs [EcReduction.eta_norm] on both sides and retries once. Also exposes [eta_norm] from [EcReduction]'s signature. The matcher is sensitive to how functions are eta-packaged: a slot written `fun i => f i` vs the equivalent `f` would fail to match if one side was stored with an extra lambda. Rather than normalising at every rewrite site, handle it once inside the unifier.
1 parent af029c9 commit d100a1e

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/ecMatching.ml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,13 @@ let f_match_core opts hyps (ue, ev) f1 f2 =
11441144
failure ();
11451145
doit env (subst, mxs) f1' f2' in
11461146

1147+
let try_etared () =
1148+
let f1' = EcReduction.eta_norm f1 in
1149+
let f2' = EcReduction.eta_norm f2 in
1150+
if f1 == (*phy*) f1' && f2 == (*phy*) f2' then
1151+
failure ();
1152+
doit env (subst, mxs) f1' f2' in
1153+
11471154
let try_horder () =
11481155
if not opts.fm_horder then
11491156
failure ();
@@ -1193,7 +1200,7 @@ let f_match_core opts hyps (ue, ev) f1 f2 =
11931200
List.find_map_opt
11941201
(fun doit ->
11951202
try Some (doit ()) with MatchFailure -> None)
1196-
[try_betared; try_horder; try_delta; default]
1203+
[try_betared; try_etared; try_horder; try_delta; default]
11971204
|> oget ~exn:MatchFailure
11981205

11991206
and doit_args env ilc fs1 fs2 =

src/ecReduction.mli

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ end
5959
(* -------------------------------------------------------------------- *)
6060
val can_eta : ident -> form * form list -> bool
6161

62+
(* -------------------------------------------------------------------- *)
63+
val eta_norm : form -> form
64+
6265
(* -------------------------------------------------------------------- *)
6366
type reduction_info = {
6467
beta : bool;

0 commit comments

Comments
 (0)