src/HOL/Tools/SMT/smt_replay_methods.ML
changeset 69597 ff784d5a5bfb
parent 69593 3dda49e08b9d
child 72458 b44e894796d5
equal deleted inserted replaced
69596:c8a2755bf220 69597:ff784d5a5bfb
   190 fun abstract_bin abs f t t1 t2 = abstract_sub t (abs t1 ##>> abs t2 #>> f)
   190 fun abstract_bin abs f t t1 t2 = abstract_sub t (abs t1 ##>> abs t2 #>> f)
   191 
   191 
   192 fun abstract_ter abs f t t1 t2 t3 =
   192 fun abstract_ter abs f t t1 t2 t3 =
   193   abstract_sub t (abs t1 ##>> abs t2 ##>> abs t3 #>> (Scan.triple1 #> f))
   193   abstract_sub t (abs t1 ##>> abs t2 ##>> abs t3 #>> (Scan.triple1 #> f))
   194 
   194 
   195 fun abstract_lit (@{const HOL.Not} $ t) = abstract_term t #>> HOLogic.mk_not
   195 fun abstract_lit (\<^const>\<open>HOL.Not\<close> $ t) = abstract_term t #>> HOLogic.mk_not
   196   | abstract_lit t = abstract_term t
   196   | abstract_lit t = abstract_term t
   197 
   197 
   198 fun abstract_not abs (t as @{const HOL.Not} $ t1) =
   198 fun abstract_not abs (t as \<^const>\<open>HOL.Not\<close> $ t1) =
   199       abstract_sub t (abs t1 #>> HOLogic.mk_not)
   199       abstract_sub t (abs t1 #>> HOLogic.mk_not)
   200   | abstract_not _ t = abstract_lit t
   200   | abstract_not _ t = abstract_lit t
   201 
   201 
   202 fun abstract_conj (t as @{const HOL.conj} $ t1 $ t2) =
   202 fun abstract_conj (t as \<^const>\<open>HOL.conj\<close> $ t1 $ t2) =
   203       abstract_bin abstract_conj HOLogic.mk_conj t t1 t2
   203       abstract_bin abstract_conj HOLogic.mk_conj t t1 t2
   204   | abstract_conj t = abstract_lit t
   204   | abstract_conj t = abstract_lit t
   205 
   205 
   206 fun abstract_disj (t as @{const HOL.disj} $ t1 $ t2) =
   206 fun abstract_disj (t as \<^const>\<open>HOL.disj\<close> $ t1 $ t2) =
   207       abstract_bin abstract_disj HOLogic.mk_disj t t1 t2
   207       abstract_bin abstract_disj HOLogic.mk_disj t t1 t2
   208   | abstract_disj t = abstract_lit t
   208   | abstract_disj t = abstract_lit t
   209 
   209 
   210 fun abstract_prop (t as (c as @{const If (bool)}) $ t1 $ t2 $ t3) =
   210 fun abstract_prop (t as (c as @{const If (bool)}) $ t1 $ t2 $ t3) =
   211       abstract_ter abstract_prop (fn (t1, t2, t3) => c $ t1 $ t2 $ t3) t t1 t2 t3
   211       abstract_ter abstract_prop (fn (t1, t2, t3) => c $ t1 $ t2 $ t3) t t1 t2 t3
   212   | abstract_prop (t as @{const HOL.disj} $ t1 $ t2) =
   212   | abstract_prop (t as \<^const>\<open>HOL.disj\<close> $ t1 $ t2) =
   213       abstract_bin abstract_prop HOLogic.mk_disj t t1 t2
   213       abstract_bin abstract_prop HOLogic.mk_disj t t1 t2
   214   | abstract_prop (t as @{const HOL.conj} $ t1 $ t2) =
   214   | abstract_prop (t as \<^const>\<open>HOL.conj\<close> $ t1 $ t2) =
   215       abstract_bin abstract_prop HOLogic.mk_conj t t1 t2
   215       abstract_bin abstract_prop HOLogic.mk_conj t t1 t2
   216   | abstract_prop (t as @{const HOL.implies} $ t1 $ t2) =
   216   | abstract_prop (t as \<^const>\<open>HOL.implies\<close> $ t1 $ t2) =
   217       abstract_bin abstract_prop HOLogic.mk_imp t t1 t2
   217       abstract_bin abstract_prop HOLogic.mk_imp t t1 t2
   218   | abstract_prop (t as \<^term>\<open>HOL.eq :: bool => _\<close> $ t1 $ t2) =
   218   | abstract_prop (t as \<^term>\<open>HOL.eq :: bool => _\<close> $ t1 $ t2) =
   219       abstract_bin abstract_prop HOLogic.mk_eq t t1 t2
   219       abstract_bin abstract_prop HOLogic.mk_eq t t1 t2
   220   | abstract_prop t = abstract_not abstract_prop t
   220   | abstract_prop t = abstract_not abstract_prop t
   221 
   221 
   225           abstract_sub t (abstract_term t)
   225           abstract_sub t (abstract_term t)
   226       | abs (t as (c as Const _) $ Abs (s, T, t')) =
   226       | abs (t as (c as Const _) $ Abs (s, T, t')) =
   227           abstract_sub t (abs t' #>> (fn u' => c $ Abs (s, T, u')))
   227           abstract_sub t (abs t' #>> (fn u' => c $ Abs (s, T, u')))
   228       | abs (t as (c as Const (\<^const_name>\<open>If\<close>, _)) $ t1 $ t2 $ t3) =
   228       | abs (t as (c as Const (\<^const_name>\<open>If\<close>, _)) $ t1 $ t2 $ t3) =
   229           abstract_ter abs (fn (t1, t2, t3) => c $ t1 $ t2 $ t3) t t1 t2 t3
   229           abstract_ter abs (fn (t1, t2, t3) => c $ t1 $ t2 $ t3) t t1 t2 t3
   230       | abs (t as @{const HOL.Not} $ t1) = abstract_sub t (abs t1 #>> HOLogic.mk_not)
   230       | abs (t as \<^const>\<open>HOL.Not\<close> $ t1) = abstract_sub t (abs t1 #>> HOLogic.mk_not)
   231       | abs (t as @{const HOL.disj} $ t1 $ t2) =
   231       | abs (t as \<^const>\<open>HOL.disj\<close> $ t1 $ t2) =
   232           abstract_sub t (abs t1 ##>> abs t2 #>> HOLogic.mk_disj)
   232           abstract_sub t (abs t1 ##>> abs t2 #>> HOLogic.mk_disj)
   233       | abs (t as (c as Const (\<^const_name>\<open>uminus_class.uminus\<close>, _)) $ t1) =
   233       | abs (t as (c as Const (\<^const_name>\<open>uminus_class.uminus\<close>, _)) $ t1) =
   234           abstract_sub t (abs t1 #>> (fn u => c $ u))
   234           abstract_sub t (abs t1 #>> (fn u => c $ u))
   235       | abs (t as (c as Const (\<^const_name>\<open>plus_class.plus\<close>, _)) $ t1 $ t2) =
   235       | abs (t as (c as Const (\<^const_name>\<open>plus_class.plus\<close>, _)) $ t1 $ t2) =
   236           abstract_sub t (abs t1 ##>> abs t2 #>> (fn (u1, u2) => c $ u1 $ u2))
   236           abstract_sub t (abs t1 ##>> abs t2 #>> (fn (u1, u2) => c $ u1 $ u2))
   254             (case apply_abstracters abs (get_arith_abstracters ctxt) t cx of
   254             (case apply_abstracters abs (get_arith_abstracters ctxt) t cx of
   255               (SOME u, cx') => (u, cx')
   255               (SOME u, cx') => (u, cx')
   256             | (NONE, _) => abstract_term t cx))
   256             | (NONE, _) => abstract_term t cx))
   257   in abs u end
   257   in abs u end
   258 
   258 
   259 fun abstract_unit (t as (@{const HOL.Not} $ (@{const HOL.disj} $ t1 $ t2))) =
   259 fun abstract_unit (t as (\<^const>\<open>HOL.Not\<close> $ (\<^const>\<open>HOL.disj\<close> $ t1 $ t2))) =
   260       abstract_sub t (abstract_unit t1 ##>> abstract_unit t2 #>>
   260       abstract_sub t (abstract_unit t1 ##>> abstract_unit t2 #>>
   261         HOLogic.mk_not o HOLogic.mk_disj)
   261         HOLogic.mk_not o HOLogic.mk_disj)
   262   | abstract_unit (t as (@{const HOL.disj} $ t1 $ t2)) =
   262   | abstract_unit (t as (\<^const>\<open>HOL.disj\<close> $ t1 $ t2)) =
   263       abstract_sub t (abstract_unit t1 ##>> abstract_unit t2 #>>
   263       abstract_sub t (abstract_unit t1 ##>> abstract_unit t2 #>>
   264         HOLogic.mk_disj)
   264         HOLogic.mk_disj)
   265   | abstract_unit (t as (Const(\<^const_name>\<open>HOL.eq\<close>, _) $ t1 $ t2)) =
   265   | abstract_unit (t as (Const(\<^const_name>\<open>HOL.eq\<close>, _) $ t1 $ t2)) =
   266       if fastype_of t1 = \<^typ>\<open>bool\<close> then
   266       if fastype_of t1 = \<^typ>\<open>bool\<close> then
   267         abstract_sub t (abstract_unit t1 ##>> abstract_unit t2 #>>
   267         abstract_sub t (abstract_unit t1 ##>> abstract_unit t2 #>>
   268           HOLogic.mk_eq)
   268           HOLogic.mk_eq)
   269       else abstract_lit t
   269       else abstract_lit t
   270   | abstract_unit (t as (@{const HOL.Not} $ Const(\<^const_name>\<open>HOL.eq\<close>, _) $ t1 $ t2)) =
   270   | abstract_unit (t as (\<^const>\<open>HOL.Not\<close> $ Const(\<^const_name>\<open>HOL.eq\<close>, _) $ t1 $ t2)) =
   271       if fastype_of t1 = \<^typ>\<open>bool\<close> then
   271       if fastype_of t1 = \<^typ>\<open>bool\<close> then
   272         abstract_sub t (abstract_unit t1 ##>> abstract_unit t2 #>>
   272         abstract_sub t (abstract_unit t1 ##>> abstract_unit t2 #>>
   273           HOLogic.mk_eq #>> HOLogic.mk_not)
   273           HOLogic.mk_eq #>> HOLogic.mk_not)
   274       else abstract_lit t
   274       else abstract_lit t
   275   | abstract_unit (t as (@{const HOL.Not} $ t1)) =
   275   | abstract_unit (t as (\<^const>\<open>HOL.Not\<close> $ t1)) =
   276       abstract_sub t (abstract_unit t1 #>> HOLogic.mk_not)
   276       abstract_sub t (abstract_unit t1 #>> HOLogic.mk_not)
   277   | abstract_unit t = abstract_lit t
   277   | abstract_unit t = abstract_lit t
   278 
   278 
   279 
   279 
   280 (* theory lemmas *)
   280 (* theory lemmas *)