updated "op +", "op -", "op *". "HOL.divide" in src & test
find . -type f -exec sed -i s/"\"op +\""/"\"Groups.plus_class.plus\""/g {} \;
find . -type f -exec sed -i s/"\"op -\""/"\"Groups.minus_class.minus\""/g {} \;
find . -type f -exec sed -i s/"\"op *\""/"\"Groups.times_class.times\""/g {} \;
find . -type f -exec sed -i s/"\"HOL.divide\""/"\"Rings.inverse_class.divide\""/g {} \;
1 (* (c) Stefan Rath 2005
2 tests for sml/Scripts/calculate.sml
4 use"~/proto2/isac/src/smltest/Scripts/calculate-float.sml";
5 use"calculate-float.sml";
9 (*WN.28.3.03 fuer Matthias*)
10 (*Floatingpointnumbers, direkte Darstellung der abstrakten Syntax:*)
12 val t = str2term "Float ((1,2),(0,0))";
14 val t = (term_of o the o (parse thy))
15 "Float ((1,2),(0,0)) + Float ((3,4),(0,0)) * \
16 \Float ((5,6),(0,0)) / Float ((7,8),(0,0))";
18 (*die konkrete Syntax wird noch verschoenert*)
23 val SOME (ct,_) = calculate thy (the (assoc (calclist, op_))) ct;
25 (*-----WN050315------------------------------------------------------*)
27 val t = str2term "Float ((1,2),(0,0))";
29 val Const ("Float.Float",_) $
31 (Const ("Pair",_) $ Free (i1,_) $ Free (i2,_)) $ _) = t;
33 val t = str2term "Float ((1,2),(0,0)) + Float ((3,4),(0,0))";
35 (*-----WN050315------------------------------------------------------*)
40 (*.calculate the value of a pair of floats.*)
41 val ((a,b),(c,d)) = calc "Groups.plus_class.plus" ((~1,0),(0,0)) ((2,0),(0,0));
45 term_of_float HOLogic.realT ((~1,0),(0,0));
46 term_of_float HOLogic.realT ((~1,11),(0,0));
48 (*--18.3.05-------------------------*)
49 val t = Free ("sdfsdfsdf", HOLogic.realT);
50 val t = Free ("-123,456", HOLogic.realT);
51 val t = Free ("0,123456", HOLogic.realT);
53 (*----(1)------------------------------*)
54 val t = str2term "IFloat (1, 2, 3)";
55 val t = str2term "CFloat (1, 2)";
58 val SOME ct = parse Float.thy "IFloat (1, 2, 3)";
59 val SOME ct = parse Float.thy "CFloat (1, 2)";
62 (*----(2)------------------------------*)
63 val SOME ct = parse Float.thy "IFloat (-1, 2, 3)";
66 (*#######################################################################3
74 Free (commas, _) $ Free (exp, _))) = t;
84 Free (commas, _) $ Free (exp, _)))) =
85 Const ("Float.CFloat", HOLogic.realT(*wrong type*)) $
87 ("Pair", HOLogic.realT(*wrong type*)) $
88 Free (no^"."^commas, HOLogic.realT)
89 $ Free ("accuracy", HOLogic.realT))
92 raise error ("IFloat2CFloat: invalid argument "^term2str t);
94 val cf = IFloat2CFloat t;
97 (*in IsacKnowledge/Float.ML: fun pairt -> Pair-term*)
99 fun CFloat2Free (Const ("Float.CFloat", _) $
100 (Const ("Pair", _) $ Free (no_commas, _) $ _)) =
101 Free (no_commas, HOLogic.realT);
103 val t' = CFloat2Free cf;
106 fun CFloat2sml (Const ("Float.CFloat", _) $
107 (Const ("Pair", _) $ Free (float, _) $ _(**))) =
111 (*--18.3.05-------------------------*)
114 (*.the function evaluating a binary operator.*)
115 val t = str2term "Float ((1,2),(0,0)) + Float ((3,4),(0,0))";
116 val SOME (thmid, t) = eval_binop "#add_" "Groups.plus_class.plus" t thy;
120 (*.scan a term for a pair of floats.*)
121 val SOME (thmid,t') = get_pair thy op_ eval_fn t;
124 (*.use 'calculate' explicitly.*)
127 val t = str2term "sqrt (x ^^^ 2 + -3 * x) =\
128 \Float ((5,6),(0,0)) / Float ((7,8),(0,0))";
129 val SOME (t',_) = calculate_ thy (the (assoc (calclist, op_))) t;
133 (*.rewrite with ruleset TEST...simplify (calling calculate internally.*)
134 val t = str2term "a + Float ((1,2),(0,0)) + a + Float ((3,4),(0,0)) * \
135 \Float ((5,6),(0,0)) / Float ((7,8),(0,0))";
136 val SOME (t',_) = rewrite_set_ thy false norm_Rational(*///*) t; term2str t';
137 (*Float ((...,...) + 2*a*)
140 (*. parse a float as seen by the user .*)
141 val SOME t = parse Float.thy "123.456";
142 val SOME t = parse Float.thy "-123.456";
143 val SOME t = parse Float.thy "123.456 E6789";
144 val SOME t = parse Float.thy "123.456 E-6789";
145 val SOME t = parse Float.thy "-123.456 E-6789";
147 ################################################################*)