equal
deleted
inserted
replaced
285 | _ => cv t) |
285 | _ => cv t) |
286 in h end; |
286 in h end; |
287 |
287 |
288 fun cterm_of_rat x = |
288 fun cterm_of_rat x = |
289 let |
289 let |
290 val (a, b) = Rat.quotient_of_rat x |
290 val (a, b) = Rat.dest x |
291 in |
291 in |
292 if b = 1 then Numeral.mk_cnumber @{ctyp "real"} a |
292 if b = 1 then Numeral.mk_cnumber @{ctyp "real"} a |
293 else Thm.apply (Thm.apply @{cterm "op / :: real => _"} |
293 else Thm.apply (Thm.apply @{cterm "op / :: real => _"} |
294 (Numeral.mk_cnumber @{ctyp "real"} a)) |
294 (Numeral.mk_cnumber @{ctyp "real"} a)) |
295 (Numeral.mk_cnumber @{ctyp "real"} b) |
295 (Numeral.mk_cnumber @{ctyp "real"} b) |
296 end; |
296 end; |
297 |
297 |
298 fun dest_ratconst t = |
298 fun dest_ratconst t = |
299 case Thm.term_of t of |
299 case Thm.term_of t of |
300 Const(@{const_name divide}, _)$a$b => Rat.rat_of_quotient(HOLogic.dest_number a |> snd, HOLogic.dest_number b |> snd) |
300 Const(@{const_name divide}, _)$a$b => Rat.make(HOLogic.dest_number a |> snd, HOLogic.dest_number b |> snd) |
301 | _ => Rat.rat_of_int (HOLogic.dest_number (Thm.term_of t) |> snd) |
301 | _ => Rat.of_int (HOLogic.dest_number (Thm.term_of t) |> snd) |
302 fun is_ratconst t = can dest_ratconst t |
302 fun is_ratconst t = can dest_ratconst t |
303 |
303 |
304 (* |
304 (* |
305 fun find_term p t = if p t then t else |
305 fun find_term p t = if p t then t else |
306 case t of |
306 case t of |