src/HOL/Tools/enriched_type.ML
changeset 43329 84472e198515
parent 42388 a44b0fdaa6c2
child 45291 57cd50f98fdc
equal deleted inserted replaced
43328:10d731b06ed7 43329:84472e198515
    96       (if co then [false] else []) @ (if contra then [true] else [])) variances;
    96       (if co then [false] else []) @ (if contra then [true] else [])) variances;
    97     val Ts21 = maps mk_argT ((Ts2 ~~ Ts1) ~~ variances);
    97     val Ts21 = maps mk_argT ((Ts2 ~~ Ts1) ~~ variances);
    98     val Ts32 = maps mk_argT ((Ts3 ~~ Ts2) ~~ variances);
    98     val Ts32 = maps mk_argT ((Ts3 ~~ Ts2) ~~ variances);
    99     fun invents n k nctxt =
    99     fun invents n k nctxt =
   100       let
   100       let
   101         val names = Name.invents nctxt n k;
   101         val names = Name.invent nctxt n k;
   102       in (names, fold Name.declare names nctxt) end;
   102       in (names, fold Name.declare names nctxt) end;
   103     val ((names21, names32), nctxt) = Variable.names_of ctxt
   103     val ((names21, names32), nctxt) = Variable.names_of ctxt
   104       |> invents "f" (length Ts21)
   104       |> invents "f" (length Ts21)
   105       ||>> invents "f" (length Ts32);
   105       ||>> invents "f" (length Ts32);
   106     val T1 = Type (tyco, Ts1);
   106     val T1 = Type (tyco, Ts1);
   118     val mapper21 = mk_mapper T2 T1 (map Free args21);
   118     val mapper21 = mk_mapper T2 T1 (map Free args21);
   119     val mapper32 = mk_mapper T3 T2 (map Free args32);
   119     val mapper32 = mk_mapper T3 T2 (map Free args32);
   120     val mapper31 = mk_mapper T3 T1 args31;
   120     val mapper31 = mk_mapper T3 T1 args31;
   121     val eq1 = (HOLogic.mk_Trueprop o HOLogic.mk_eq)
   121     val eq1 = (HOLogic.mk_Trueprop o HOLogic.mk_eq)
   122       (HOLogic.mk_comp (mapper21, mapper32), mapper31);
   122       (HOLogic.mk_comp (mapper21, mapper32), mapper31);
   123     val x = Free (the_single (Name.invents nctxt (Long_Name.base_name tyco) 1), T3)
   123     val x = Free (the_single (Name.invent nctxt (Long_Name.base_name tyco) 1), T3)
   124     val eq2 = (HOLogic.mk_Trueprop o HOLogic.mk_eq)
   124     val eq2 = (HOLogic.mk_Trueprop o HOLogic.mk_eq)
   125       (mapper21 $ (mapper32 $ x), mapper31 $ x);
   125       (mapper21 $ (mapper32 $ x), mapper31 $ x);
   126     val comp_prop = fold_rev Logic.all (map Free (args21 @ args32)) eq1;
   126     val comp_prop = fold_rev Logic.all (map Free (args21 @ args32)) eq1;
   127     val compositionality_prop = fold_rev Logic.all (map Free (args21 @ args32) @ [x]) eq2;
   127     val compositionality_prop = fold_rev Logic.all (map Free (args21 @ args32) @ [x]) eq2;
   128     fun prove_compositionality ctxt comp_thm = Skip_Proof.prove ctxt [] [] compositionality_prop
   128     fun prove_compositionality ctxt comp_thm = Skip_Proof.prove ctxt [] [] compositionality_prop