src/HOL/Tools/SMT/smt_translate.ML
changeset 41785 77dcc197df9a
parent 41426 09615ed31f04
child 42319 9a8ba59aed06
equal deleted inserted replaced
41784:537013b8ba8e 41785:77dcc197df9a
   352 
   352 
   353 local
   353 local
   354   val term_bool = @{lemma "SMT.term_true ~= SMT.term_false"
   354   val term_bool = @{lemma "SMT.term_true ~= SMT.term_false"
   355     by (simp add: SMT.term_true_def SMT.term_false_def)}
   355     by (simp add: SMT.term_true_def SMT.term_false_def)}
   356 
   356 
       
   357   val is_quant = member (op =) [@{const_name All}, @{const_name Ex}]
       
   358 
   357   val fol_rules = [
   359   val fol_rules = [
   358     Let_def,
   360     Let_def,
   359     mk_meta_eq @{thm SMT.term_true_def},
   361     mk_meta_eq @{thm SMT.term_true_def},
   360     mk_meta_eq @{thm SMT.term_false_def},
   362     mk_meta_eq @{thm SMT.term_false_def},
   361     @{lemma "P = True == P" by (rule eq_reflection) simp},
   363     @{lemma "P = True == P" by (rule eq_reflection) simp},
   393       (case Term.strip_comb t of
   395       (case Term.strip_comb t of
   394         (@{const True}, []) => @{const SMT.term_true}
   396         (@{const True}, []) => @{const SMT.term_true}
   395       | (@{const False}, []) => @{const SMT.term_false}
   397       | (@{const False}, []) => @{const SMT.term_false}
   396       | (u as Const (@{const_name If}, _), [t1, t2, t3]) =>
   398       | (u as Const (@{const_name If}, _), [t1, t2, t3]) =>
   397           u $ in_form t1 $ in_term t2 $ in_term t3
   399           u $ in_form t1 $ in_term t2 $ in_term t3
   398       | (Const c, ts) =>
   400       | (Const (c as (n, _)), ts) =>
   399           if is_builtin_conn_or_pred ctxt c ts then wrap_in_if (in_form t)
   401           if is_builtin_conn_or_pred ctxt c ts then wrap_in_if (in_form t)
       
   402           else  if is_quant n then wrap_in_if (in_form t)
   400           else Term.list_comb (Const c, map in_term ts)
   403           else Term.list_comb (Const c, map in_term ts)
   401       | (Free c, ts) => Term.list_comb (Free c, map in_term ts)
   404       | (Free c, ts) => Term.list_comb (Free c, map in_term ts)
   402       | _ => t)
   405       | _ => t)
   403 
   406 
   404     and in_weight ((c as @{const SMT.weight}) $ w $ t) = c $ w $ in_form t
   407     and in_weight ((c as @{const SMT.weight}) $ w $ t) = c $ w $ in_form t
   416       | in_trigger t = in_weight t
   419       | in_trigger t = in_weight t
   417 
   420 
   418     and in_form t =
   421     and in_form t =
   419       (case Term.strip_comb t of
   422       (case Term.strip_comb t of
   420         (q as Const (qn, _), [Abs (n, T, u)]) =>
   423         (q as Const (qn, _), [Abs (n, T, u)]) =>
   421           if member (op =) [@{const_name All}, @{const_name Ex}] qn then
   424           if is_quant qn then q $ Abs (n, T, in_trigger u)
   422             q $ Abs (n, T, in_trigger u)
       
   423           else as_term (in_term t)
   425           else as_term (in_term t)
   424       | (Const c, ts) =>
   426       | (Const c, ts) =>
   425           (case SMT_Builtin.dest_builtin_conn ctxt c ts of
   427           (case SMT_Builtin.dest_builtin_conn ctxt c ts of
   426             SOME (_, _, us, mk) => mk (map in_form us)
   428             SOME (_, _, us, mk) => mk (map in_form us)
   427           | NONE =>
   429           | NONE =>