Theory Codegenerator_Pretty

Up to index of Isabelle/HOL/ex

theory Codegenerator_Pretty
imports RealDef Efficient_Nat
begin

(*  Title:      HOL/ex/Codegenerator_Pretty.thy
    ID:         $Id: Codegenerator_Pretty.thy,v 1.4 2007/09/06 09:36:25 berghofe Exp $
    Author:     Florian Haftmann, TU Muenchen
*)

header {* Simple examples for pretty numerals and such *}

theory Codegenerator_Pretty
imports "~~/src/HOL/Real/RealDef" Efficient_Nat
begin

definition
  foo :: "rat => rat => rat => rat" where
  "foo r s t = (t + s) / t"

definition
  bar :: "rat => rat => rat => bool" where
  "bar r s t <-> (r - s) ≤ t ∨ (s - t) ≤ r"

definition
  "R1 = Fract 3 7"

definition
  "R2 = Fract (-7) 5"

definition
  "R3 = Fract 11 (-9)"

definition
  "foobar = (foo R1 1 R3, bar R2 0 R3, foo R1 R3 R2)"

definition
  foo' :: "real => real => real => real" where
  "foo' r s t = (t + s) / t"

definition
  bar' :: "real => real => real => bool" where
  "bar' r s t <-> (r - s) ≤ t ∨ (s - t) ≤ r"

definition
  "R1' = real_of_rat (Fract 3 7)"

definition
  "R2' = real_of_rat (Fract (-7) 5)"

definition
  "R3' = real_of_rat (Fract 11 (-9))"

definition
  "foobar' = (foo' R1' 1 R3', bar' R2' 0 R3', foo' R1' R3' R2')"

export_code foobar foobar' in SML module_name Foo
  in OCaml file -
  in Haskell file -
ML {* (Foo.foobar, Foo.foobar') *}

end