proper beta_norm after instantiation (amending 90c5aadcc4b2);
authorwenzelm
Sun, 17 Dec 2023 21:34:44 +0100
changeset 79272 899f37f6d218
parent 79271 b14b289caaf6
child 79273 d1e5f6d1ddca
proper beta_norm after instantiation (amending 90c5aadcc4b2);
src/Pure/General/same.ML
src/Pure/zterm.ML
--- a/src/Pure/General/same.ML	Sun Dec 17 21:30:21 2023 +0100
+++ b/src/Pure/General/same.ML	Sun Dec 17 21:34:44 2023 +0100
@@ -14,6 +14,7 @@
   val commit: 'a operation -> 'a -> 'a
   val commit_id: 'a operation -> 'a -> 'a * bool
   val catch: ('a, 'b) function -> 'a -> 'b option
+  val compose: 'a operation -> 'a operation -> 'a operation
   val function: ('a -> 'b option) -> ('a, 'b) function
   val map: 'a operation -> 'a list operation
   val map_option: ('a, 'b) function -> ('a option, 'b option) function
@@ -33,6 +34,11 @@
 
 fun catch f x = SOME (f x) handle SAME => NONE;
 
+fun compose g f x =
+  (case catch f x of
+    NONE => g x
+  | SOME y => commit g y);
+
 fun function f x =
   (case f x of
     NONE => raise SAME
--- a/src/Pure/zterm.ML	Sun Dec 17 21:30:21 2023 +0100
+++ b/src/Pure/zterm.ML	Sun Dec 17 21:34:44 2023 +0100
@@ -617,7 +617,9 @@
           val inst_term =
             ZVars.build (visible |> (fold o Term.fold_aterms) (fn Var v => add_var v | _ => I))
             |> instantiate_term_same inst_typ;
-        in Same.commit (map_proof_same inst_typ inst_term) prf end
+
+          val norm_term = Same.compose beta_norm_same inst_term;
+        in Same.commit (map_proof_same inst_typ norm_term) prf end
   end;
 
 fun norm_cache thy =