src/HOL/Tools/Metis/metis_translate.ML
changeset 41156 9aeaf8acf6c8
parent 41140 9c68004b8c9d
child 41491 a2ad5b824051
equal deleted inserted replaced
41155:85da8cbb4966 41156:9aeaf8acf6c8
   112                (@{const_name Not}, "Not"),
   112                (@{const_name Not}, "Not"),
   113                (@{const_name conj}, "conj"),
   113                (@{const_name conj}, "conj"),
   114                (@{const_name disj}, "disj"),
   114                (@{const_name disj}, "disj"),
   115                (@{const_name implies}, "implies"),
   115                (@{const_name implies}, "implies"),
   116                (@{const_name HOL.eq}, "equal"),
   116                (@{const_name HOL.eq}, "equal"),
       
   117                (@{const_name If}, "If"),
   117                (@{const_name Set.member}, "member"),
   118                (@{const_name Set.member}, "member"),
       
   119                (@{const_name Meson.COMBI}, "COMBI"),
       
   120                (@{const_name Meson.COMBK}, "COMBK"),
       
   121                (@{const_name Meson.COMBB}, "COMBB"),
       
   122                (@{const_name Meson.COMBC}, "COMBC"),
       
   123                (@{const_name Meson.COMBS}, "COMBS"),
   118                (@{const_name Metis.fFalse}, "fFalse"),
   124                (@{const_name Metis.fFalse}, "fFalse"),
   119                (@{const_name Metis.fTrue}, "fTrue"),
   125                (@{const_name Metis.fTrue}, "fTrue"),
   120                (@{const_name Metis.fNot}, "fNot"),
   126                (@{const_name Metis.fNot}, "fNot"),
   121                (@{const_name Metis.fconj}, "fconj"),
   127                (@{const_name Metis.fconj}, "fconj"),
   122                (@{const_name Metis.fdisj}, "fdisj"),
   128                (@{const_name Metis.fdisj}, "fdisj"),
   123                (@{const_name Metis.fimplies}, "fimplies"),
   129                (@{const_name Metis.fimplies}, "fimplies"),
   124                (@{const_name Metis.fequal}, "fequal"),
   130                (@{const_name Metis.fequal}, "fequal")]
   125                (@{const_name Meson.COMBI}, "COMBI"),
       
   126                (@{const_name Meson.COMBK}, "COMBK"),
       
   127                (@{const_name Meson.COMBB}, "COMBB"),
       
   128                (@{const_name Meson.COMBC}, "COMBC"),
       
   129                (@{const_name Meson.COMBS}, "COMBS"),
       
   130                (@{const_name If}, "If")]
       
   131 
   131 
   132 (* Invert the table of translations between Isabelle and ATPs. *)
   132 (* Invert the table of translations between Isabelle and ATPs. *)
   133 val const_trans_table_inv =
   133 val const_trans_table_inv =
   134   const_trans_table |> Symtab.dest |> map swap |> Symtab.make
   134   const_trans_table |> Symtab.dest |> map swap |> Symtab.make
   135   |> fold Symtab.update [("fFalse", @{const_name False}),
   135   |> fold Symtab.update [("fFalse", @{const_name False}),
   690               by (unfold fconj_def) fast+})),
   690               by (unfold fconj_def) fast+})),
   691    ("c_fdisj",
   691    ("c_fdisj",
   692     (false, @{lemma "~ P | fdisj P Q" "~ Q | fdisj P Q" "~ fdisj P Q | P | Q"
   692     (false, @{lemma "~ P | fdisj P Q" "~ Q | fdisj P Q" "~ fdisj P Q | P | Q"
   693               by (unfold fdisj_def) fast+})),
   693               by (unfold fdisj_def) fast+})),
   694    ("c_fimplies",
   694    ("c_fimplies",
   695     (false, @{lemma "P | Metis.fimplies P Q"
   695     (false, @{lemma "P | fimplies P Q" "~ Q | fimplies P Q"
   696                     "~ Q | Metis.fimplies P Q"
   696                     "~ fimplies P Q | ~ P | Q"
   697                     "~ Metis.fimplies P Q | ~ P | Q"
   697               by (unfold fimplies_def) fast+})),
   698               by (unfold Metis.fimplies_def) fast+})),
       
   699    ("c_If", (true, @{thms if_True if_False True_or_False})) (* FIXME *)]
   698    ("c_If", (true, @{thms if_True if_False True_or_False})) (* FIXME *)]
   700 
   699 
   701 (* ------------------------------------------------------------------------- *)
   700 (* ------------------------------------------------------------------------- *)
   702 (* Logic maps manage the interface between HOL and first-order logic.        *)
   701 (* Logic maps manage the interface between HOL and first-order logic.        *)
   703 (* ------------------------------------------------------------------------- *)
   702 (* ------------------------------------------------------------------------- *)
   730                         old_skolems = old_skolems}
   729                         old_skolems = old_skolems}
   731 
   730 
   732 fun const_in_metis c (pred, tm_list) =
   731 fun const_in_metis c (pred, tm_list) =
   733   let
   732   let
   734     fun in_mterm (Metis_Term.Var _) = false
   733     fun in_mterm (Metis_Term.Var _) = false
   735       | in_mterm (Metis_Term.Fn (".", tm_list)) = exists in_mterm tm_list
   734       | in_mterm (Metis_Term.Fn (nm, tm_list)) =
   736       | in_mterm (Metis_Term.Fn (nm, tm_list)) = c=nm orelse exists in_mterm tm_list
   735         c = nm orelse exists in_mterm tm_list
   737   in  c = pred orelse exists in_mterm tm_list  end;
   736   in c = pred orelse exists in_mterm tm_list end
   738 
   737 
   739 (* ARITY CLAUSE *)
   738 (* ARITY CLAUSE *)
   740 fun m_arity_cls (TConsLit ((c, _), (t, _), args)) =
   739 fun m_arity_cls (TConsLit ((c, _), (t, _), args)) =
   741     metis_lit true c [Metis_Term.Fn(t, map (Metis_Term.Var o fst) args)]
   740     metis_lit true c [Metis_Term.Fn(t, map (Metis_Term.Var o fst) args)]
   742   | m_arity_cls (TVarLit ((c, _), (s, _))) =
   741   | m_arity_cls (TVarLit ((c, _), (s, _))) =
   792       val lmap =
   791       val lmap =
   793         if mode = FO then
   792         if mode = FO then
   794           lmap
   793           lmap
   795         else
   794         else
   796           let
   795           let
   797             val fdefs = @{thms Metis.fFalse_def Metis.fTrue_def Metis.fNot_def
   796             val fdefs = @{thms fFalse_def fTrue_def fNot_def fconj_def fdisj_def
   798                                Metis.fconj_def Metis.fdisj_def
   797                                fimplies_def fequal_def}
   799                                Metis.fimplies_def Metis.fequal_def}
       
   800             val prepare_helper =
   798             val prepare_helper =
   801               zero_var_indexes
   799               zero_var_indexes
   802               #> `(Meson.make_meta_clause
   800               #> `(Meson.make_meta_clause
   803                    #> rewrite_rule (map safe_mk_meta_eq fdefs))
   801                    #> rewrite_rule (map safe_mk_meta_eq fdefs))
   804             val helper_ths =
   802             val helper_ths =