src/HOL/Tools/SMT/z3_real.ML
author wenzelm
Sun Nov 26 21:08:32 2017 +0100 (18 months ago)
changeset 67091 1393c2340eec
parent 61609 77b453bd616f
child 69204 d5ab1636660b
permissions -rw-r--r--
more symbols;
     1 (*  Title:      HOL/Tools/SMT/z3_real.ML
     2     Author:     Sascha Boehme, TU Muenchen
     3 
     4 Z3 setup for reals.
     5 *)
     6 
     7 structure Z3_Real: sig end =
     8 struct
     9 
    10 fun real_type_parser (SMTLIB.Sym "Real", []) = SOME @{typ Real.real}
    11   | real_type_parser _ = NONE
    12 
    13 fun real_term_parser (SMTLIB.Dec (i, 0), []) = SOME (HOLogic.mk_number @{typ Real.real} i)
    14   | real_term_parser (SMTLIB.Sym "/", [t1, t2]) =
    15       SOME (@{term "Rings.divide :: real => _"} $ t1 $ t2)
    16   | real_term_parser (SMTLIB.Sym "to_real", [t]) = SOME (@{term "Int.of_int :: int => _"} $ t)
    17   | real_term_parser _ = NONE
    18 
    19 fun abstract abs t =
    20   (case t of
    21     (c as @{term "Rings.divide :: real => _"}) $ t1 $ t2 =>
    22       abs t1 ##>> abs t2 #>> (fn (u1, u2) => SOME (c $ u1 $ u2))
    23   | (c as @{term "Int.of_int :: int => _"}) $ t =>
    24       abs t #>> (fn u => SOME (c $ u))
    25   | _ => pair NONE)
    26 
    27 val _ = Theory.setup (Context.theory_map (
    28   SMTLIB_Proof.add_type_parser real_type_parser #>
    29   SMTLIB_Proof.add_term_parser real_term_parser #>
    30   Z3_Replay_Methods.add_arith_abstracter abstract))
    31 
    32 end;