# HG changeset patch # User Achim D. Brucker # Date 1658733861 -3600 # Node ID 91cdf474b64d4f4be36f6d2af3182bd367140d31 # Parent 048bbe0bf807a07159714e59feab94283aa305b5 Support 'late use' of Code_Real_Approx_By_Float. diff -r 048bbe0bf807 -r 91cdf474b64d src/HOL/Library/Code_Real_Approx_By_Float.thy --- a/src/HOL/Library/Code_Real_Approx_By_Float.thy Sat Jul 23 12:19:45 2022 +0200 +++ b/src/HOL/Library/Code_Real_Approx_By_Float.thy Mon Jul 25 08:24:21 2022 +0100 @@ -20,6 +20,8 @@ purposes. \ +code_reserved SML Real + code_printing type_constructor real \ (SML) "real" @@ -183,16 +185,22 @@ code_printing constant Ratreal \ (SML) -definition Realfract :: "int \ int \ real" - where "Realfract p q = of_int p / of_int q" +definition Realfract :: "real \ real \ real" + where "Realfract p q = p / q" + +definition Realfract' :: "int \ int \ real" + where "Realfract' p q = Realfract (of_int p) (of_int q)" + + code_datatype Realfract code_printing - constant Realfract \ (SML) "Real.fromInt _/ '// Real.fromInt _" + constant Realfract \ (SML) "_/ '// _" + -lemma [code]: "Ratreal r = case_prod Realfract (quotient_of r)" - by (cases r) (simp add: Realfract_def quotient_of_Fract of_rat_rat) +lemma [code]: "Ratreal r = case_prod Realfract' (quotient_of r)" + by (cases r) (simp add: Realfract_def Realfract'_def quotient_of_Fract of_rat_rat) declare [[code drop: "HOL.equal :: real \ real \ bool" "plus :: real \ real \ real"