src/HOL/Tools/SMT/z3_interface.ML
changeset 59621 291934bac95e
parent 59586 ddf6deaadfe8
child 59632 5980e75a204e
equal deleted inserted replaced
59620:92d7d8e4f1bf 59621:291934bac95e
   110 
   110 
   111 fun mk_builtin_num _ i @{typ int} = SOME (Numeral.mk_cnumber @{ctyp int} i)
   111 fun mk_builtin_num _ i @{typ int} = SOME (Numeral.mk_cnumber @{ctyp int} i)
   112   | mk_builtin_num ctxt i T =
   112   | mk_builtin_num ctxt i T =
   113       chained_mk_builtin_num ctxt (get_mk_builtins ctxt) i T
   113       chained_mk_builtin_num ctxt (get_mk_builtins ctxt) i T
   114 
   114 
   115 val mk_true = Thm.cterm_of @{theory} (@{const Not} $ @{const False})
   115 val mk_true = Thm.global_cterm_of @{theory} (@{const Not} $ @{const False})
   116 val mk_false = Thm.cterm_of @{theory} @{const False}
   116 val mk_false = Thm.global_cterm_of @{theory} @{const False}
   117 val mk_not = Thm.apply (Thm.cterm_of @{theory} @{const Not})
   117 val mk_not = Thm.apply (Thm.global_cterm_of @{theory} @{const Not})
   118 val mk_implies = Thm.mk_binop (Thm.cterm_of @{theory} @{const HOL.implies})
   118 val mk_implies = Thm.mk_binop (Thm.global_cterm_of @{theory} @{const HOL.implies})
   119 val mk_iff = Thm.mk_binop (Thm.cterm_of @{theory} @{const HOL.eq (bool)})
   119 val mk_iff = Thm.mk_binop (Thm.global_cterm_of @{theory} @{const HOL.eq (bool)})
   120 val conj = Thm.cterm_of @{theory} @{const HOL.conj}
   120 val conj = Thm.global_cterm_of @{theory} @{const HOL.conj}
   121 val disj = Thm.cterm_of @{theory} @{const HOL.disj}
   121 val disj = Thm.global_cterm_of @{theory} @{const HOL.disj}
   122 
   122 
   123 fun mk_nary _ cu [] = cu
   123 fun mk_nary _ cu [] = cu
   124   | mk_nary ct _ cts = uncurry (fold_rev (Thm.mk_binop ct)) (split_last cts)
   124   | mk_nary ct _ cts = uncurry (fold_rev (Thm.mk_binop ct)) (split_last cts)
   125 
   125 
   126 val eq = SMT_Util.mk_const_pat @{theory} @{const_name HOL.eq} SMT_Util.destT1
   126 val eq = SMT_Util.mk_const_pat @{theory} @{const_name HOL.eq} SMT_Util.destT1
   137   SMT_Util.mk_const_pat @{theory} @{const_name fun_upd} (Thm.dest_ctyp o SMT_Util.destT1)
   137   SMT_Util.mk_const_pat @{theory} @{const_name fun_upd} (Thm.dest_ctyp o SMT_Util.destT1)
   138 fun mk_update array index value =
   138 fun mk_update array index value =
   139   let val cTs = Thm.dest_ctyp (Thm.ctyp_of_cterm array)
   139   let val cTs = Thm.dest_ctyp (Thm.ctyp_of_cterm array)
   140   in Thm.apply (Thm.mk_binop (SMT_Util.instTs cTs update) array index) value end
   140   in Thm.apply (Thm.mk_binop (SMT_Util.instTs cTs update) array index) value end
   141 
   141 
   142 val mk_uminus = Thm.apply (Thm.cterm_of @{theory} @{const uminus (int)})
   142 val mk_uminus = Thm.apply (Thm.global_cterm_of @{theory} @{const uminus (int)})
   143 val add = Thm.cterm_of @{theory} @{const plus (int)}
   143 val add = Thm.global_cterm_of @{theory} @{const plus (int)}
   144 val int0 = Numeral.mk_cnumber @{ctyp int} 0
   144 val int0 = Numeral.mk_cnumber @{ctyp int} 0
   145 val mk_sub = Thm.mk_binop (Thm.cterm_of @{theory} @{const minus (int)})
   145 val mk_sub = Thm.mk_binop (Thm.global_cterm_of @{theory} @{const minus (int)})
   146 val mk_mul = Thm.mk_binop (Thm.cterm_of @{theory} @{const times (int)})
   146 val mk_mul = Thm.mk_binop (Thm.global_cterm_of @{theory} @{const times (int)})
   147 val mk_div = Thm.mk_binop (Thm.cterm_of @{theory} @{const z3div})
   147 val mk_div = Thm.mk_binop (Thm.global_cterm_of @{theory} @{const z3div})
   148 val mk_mod = Thm.mk_binop (Thm.cterm_of @{theory} @{const z3mod})
   148 val mk_mod = Thm.mk_binop (Thm.global_cterm_of @{theory} @{const z3mod})
   149 val mk_lt = Thm.mk_binop (Thm.cterm_of @{theory} @{const less (int)})
   149 val mk_lt = Thm.mk_binop (Thm.global_cterm_of @{theory} @{const less (int)})
   150 val mk_le = Thm.mk_binop (Thm.cterm_of @{theory} @{const less_eq (int)})
   150 val mk_le = Thm.mk_binop (Thm.global_cterm_of @{theory} @{const less_eq (int)})
   151 
   151 
   152 fun mk_builtin_fun ctxt sym cts =
   152 fun mk_builtin_fun ctxt sym cts =
   153   (case (sym, cts) of
   153   (case (sym, cts) of
   154     (Sym ("true", _), []) => SOME mk_true
   154     (Sym ("true", _), []) => SOME mk_true
   155   | (Sym ("false", _), []) => SOME mk_false
   155   | (Sym ("false", _), []) => SOME mk_false