changeset 59549 | e0e3d41ef86c |
parent 59547 | a6dcec53aec0 |
child 59585 | 0bb418c3855a |
59548:d44ce0c098a0 | 59549:e0e3d41ef86c |
---|---|
4 *) |
4 *) |
5 |
5 |
6 theory Atools imports Descript Script |
6 theory Atools imports Descript Script |
7 begin |
7 begin |
8 |
8 |
9 subsection \<open>preparation to build up a program from rules\<close> |
|
10 |
|
9 partial_function (tailrec) auto_generated :: "'z \<Rightarrow> 'z" |
11 partial_function (tailrec) auto_generated :: "'z \<Rightarrow> 'z" |
10 where "auto_generated t_t = t_t" |
12 where "auto_generated t_t = t_t" |
11 partial_function (tailrec) auto_generated_inst :: "'z \<Rightarrow> real \<Rightarrow> 'z" |
13 partial_function (tailrec) auto_generated_inst :: "'z \<Rightarrow> real \<Rightarrow> 'z" |
12 where "auto_generated_inst t_t v = t_t" |
14 where "auto_generated_inst t_t v = t_t" |
15 |
|
16 subsection \<open>use preparation\<close> |
|
13 ML_file "~~/src/Tools/isac/ProgLang/scrtools.sml" |
17 ML_file "~~/src/Tools/isac/ProgLang/scrtools.sml" |
18 |
|
19 subsection \<open>consts & axiomatization\<close> |
|
14 |
20 |
15 consts |
21 consts |
16 |
22 |
17 Arbfix :: "real" |
23 Arbfix :: "real" |
18 Undef :: "real" |
24 Undef :: "real" |
20 |
26 |
21 some'_occur'_in :: "[real list, 'a] => bool" ("some'_of _ occur'_in _") |
27 some'_occur'_in :: "[real list, 'a] => bool" ("some'_of _ occur'_in _") |
22 occurs'_in :: "[real , 'a] => bool" ("_ occurs'_in _") |
28 occurs'_in :: "[real , 'a] => bool" ("_ occurs'_in _") |
23 |
29 |
24 pow :: "[real, real] => real" (infixr "^^^" 80) |
30 pow :: "[real, real] => real" (infixr "^^^" 80) |
25 (* ~~~ power doesn't allow Free("2",real) ^ Free("2",nat) |
31 (* ~~~ power doesn't allow Free("2",real) ^ Free("2",nat) |
26 ~~~~ ~~~~ ~~~~ ~~~*) |
32 ~~~~ ~~~~ ~~~~ ~~~*) |
27 (*WN0603 at FE-interface encoded strings to '^', |
33 (*WN0603 at FE-interface encoded strings to '^', |
28 see 'fun encode', fun 'decode'*) |
34 see 'fun encode', fun 'decode'*) |
29 |
35 |
30 abs :: "real => real" ("(|| _ ||)") |
36 abs :: "real => real" ("(|| _ ||)") |
76 ( a <= (c / d)) = ((a*d) <= c )"(*Isa?*) and |
82 ( a <= (c / d)) = ((a*d) <= c )"(*Isa?*) and |
77 rat_leq3: "b ~= 0 ==> |
83 rat_leq3: "b ~= 0 ==> |
78 ((a / b) <= c ) = ( a <= (b*c))"(*Isa?*) |
84 ((a / b) <= c ) = ( a <= (b*c))"(*Isa?*) |
79 |
85 |
80 |
86 |
87 subsection \<open>Coding standards\<close> |
|
81 text \<open>copy from doc/math-eng.tex WN.28.3.03 |
88 text \<open>copy from doc/math-eng.tex WN.28.3.03 |
82 WN071228 extended\<close> |
89 WN071228 extended\<close> |
83 |
90 |
84 section \<open>Coding standards\<close> |
91 subsubsection \<open>Identifiers\<close> |
85 subsection \<open>Identifiers\<close> |
|
86 text \<open>Naming is particularily crucial, because Isabelles name space is global, and isac does not yet use the novel locale features introduces by Isar. For instance, {\tt probe} sounds reasonable as (1) a description in the model of a problem-pattern, (2) as an element of the problem hierarchies key, (3) as a socalled CAS-command, (4) as the name of a related script etc. However, all the cases (1)..(4) require different typing for one and the same identifier {\tt probe} which is impossible, and actually leads to strange errors (for instance (1) is used as string, except in a script addressing a Subproblem). |
92 text \<open>Naming is particularily crucial, because Isabelles name space is global, and isac does not yet use the novel locale features introduces by Isar. For instance, {\tt probe} sounds reasonable as (1) a description in the model of a problem-pattern, (2) as an element of the problem hierarchies key, (3) as a socalled CAS-command, (4) as the name of a related script etc. However, all the cases (1)..(4) require different typing for one and the same identifier {\tt probe} which is impossible, and actually leads to strange errors (for instance (1) is used as string, except in a script addressing a Subproblem). |
87 |
93 |
88 This are the preliminary rules for naming identifiers> |
94 This are the preliminary rules for naming identifiers> |
89 \begin{description} |
95 \begin{description} |
90 \item [elements of a key] into the hierarchy of problems or methods must not contain capital letters and may contain underscrores, e.g. {\tt probe, for_polynomials}. |
96 \item [elements of a key] into the hierarchy of problems or methods must not contain capital letters and may contain underscrores, e.g. {\tt probe, for_polynomials}. |
94 \item [???] ??? |
100 \item [???] ??? |
95 \item [???] ??? |
101 \item [???] ??? |
96 \end{description} |
102 \end{description} |
97 %WN071228 extended\<close> |
103 %WN071228 extended\<close> |
98 |
104 |
99 subsection \<open>Rule sets\<close> |
105 subsubsection \<open>Rule sets\<close> |
100 text \<open>The actual version of the coding standards for rulesets is in {\tt /IsacKnowledge/Atools.ML where it can be viewed using the knowledge browsers. |
106 text \<open>The actual version of the coding standards for rulesets is in {\tt /IsacKnowledge/Atools.ML where it can be viewed using the knowledge browsers. |
101 |
107 |
102 There are rulesets visible to the student, and there are rulesets visible (in general) only for math authors. There are also rulesets which {\em must} exist for {\em each} theory; these contain the identifier of the respective theory (including all capital letters) as indicated by {\it Thy} below. |
108 There are rulesets visible to the student, and there are rulesets visible (in general) only for math authors. There are also rulesets which {\em must} exist for {\em each} theory; these contain the identifier of the respective theory (including all capital letters) as indicated by {\it Thy} below. |
103 \begin{description} |
109 \begin{description} |
104 |
110 |
123 |
129 |
124 \end{description} |
130 \end{description} |
125 {\tt Rule.append_rls, Rule.merge_rls, remove_rls} TODO |
131 {\tt Rule.append_rls, Rule.merge_rls, remove_rls} TODO |
126 \<close> |
132 \<close> |
127 |
133 |
134 subsection \<open>evaluation of numerals and special predicates on the meta-level\<close> |
|
128 ML \<open> |
135 ML \<open> |
129 val thy = @{theory}; |
136 val thy = @{theory}; |
130 |
|
131 (** evaluation of numerals and special predicates on the meta-level **) |
|
132 |
137 |
133 fun occurs_in v t = member op = (((map strip_thy) o TermC.ids2str) t) (Term.term_name v); |
138 fun occurs_in v t = member op = (((map strip_thy) o TermC.ids2str) t) (Term.term_name v); |
134 |
139 |
135 (*("occurs_in", ("Atools.occurs'_in", eval_occurs_in ""))*) |
140 (*("occurs_in", ("Atools.occurs'_in", eval_occurs_in ""))*) |
136 fun eval_occurs_in _ "Atools.occurs'_in" |
141 fun eval_occurs_in _ "Atools.occurs'_in" |
413 *) |
418 *) |
414 |
419 |
415 |
420 |
416 \<close> |
421 \<close> |
417 |
422 |
423 subsection \<open>evaluation on the meta-level\<close> |
|
418 ML \<open> |
424 ML \<open> |
419 (** evaluation on the metalevel **) |
|
420 |
|
421 (*. evaluate HOL.divide .*) |
425 (*. evaluate HOL.divide .*) |
422 (*("DIVIDE" ,("Rings.divide_class.divide" ,eval_cancel "#divide_e"))*) |
426 (*("DIVIDE" ,("Rings.divide_class.divide" ,eval_cancel "#divide_e"))*) |
423 fun eval_cancel (thmid:string) "Rings.divide_class.divide" (t as |
427 fun eval_cancel (thmid:string) "Rings.divide_class.divide" (t as |
424 (Const (op0,t0) $ Free (n1,t1) $ Free(n2,t2))) thy = |
428 (Const (op0,t0) $ Free (n1,t1) $ Free(n2,t2))) thy = |
425 (case (TermC.int_of_str_opt n1, TermC.int_of_str_opt n2) of |
429 (case (TermC.int_of_str_opt n1, TermC.int_of_str_opt n2) of |
510 val sum = list2sum lhss |
514 val sum = list2sum lhss |
511 in SOME ((Rule.term2str p) ^ " = " ^ (Rule.term2str sum), |
515 in SOME ((Rule.term2str p) ^ " = " ^ (Rule.term2str sum), |
512 HOLogic.Trueprop $ (TermC.mk_equality (p, sum))) |
516 HOLogic.Trueprop $ (TermC.mk_equality (p, sum))) |
513 end |
517 end |
514 | eval_boollist2sum _ _ _ _ = NONE; |
518 | eval_boollist2sum _ _ _ _ = NONE; |
515 |
519 \<close> |
516 |
520 |
517 |
521 subsection \<open>rule sets, for evaluating list-expressions in scripts, etc\<close> |
522 ML \<open> |
|
518 local |
523 local |
519 |
524 |
520 open Term; |
525 open Term; |
521 |
526 |
522 in |
527 in |
523 fun termlessI (_: Rule.subst) uv = LibraryC.termless uv; |
528 fun termlessI (_: Rule.subst) uv = LibraryC.termless uv; |
524 fun term_ordI (_: Rule.subst) uv = Term_Ord.term_ord uv; |
529 fun term_ordI (_: Rule.subst) uv = Term_Ord.term_ord uv; |
525 end; |
530 end; |
526 |
|
527 |
|
528 (** rule set, for evaluating list-expressions in scripts 8.01.02 **) |
|
529 |
|
530 |
531 |
531 val list_rls = Rule.append_rls "list_rls" list_rls |
532 val list_rls = Rule.append_rls "list_rls" list_rls |
532 [Rule.Calc ("Groups.times_class.times",eval_binop "#mult_"), |
533 [Rule.Calc ("Groups.times_class.times",eval_binop "#mult_"), |
533 Rule.Calc ("Groups.plus_class.plus", eval_binop "#add_"), |
534 Rule.Calc ("Groups.plus_class.plus", eval_binop "#add_"), |
534 Rule.Calc ("Orderings.ord_class.less",eval_equ "#less_"), |
535 Rule.Calc ("Orderings.ord_class.less",eval_equ "#less_"), |
665 scr = Rule.Prog ((Thm.term_of o the o (parse @{theory})) "empty_script") |
666 scr = Rule.Prog ((Thm.term_of o the o (parse @{theory})) "empty_script") |
666 }); |
667 }); |
667 *) |
668 *) |
668 "******* Atools.ML end *******"; |
669 "******* Atools.ML end *******"; |
669 \<close> |
670 \<close> |
671 subsection \<open>write to KEStore: calcs, rule-sets\<close> |
|
670 setup \<open>KEStore_Elems.add_calcs |
672 setup \<open>KEStore_Elems.add_calcs |
671 [("occurs_in",("Atools.occurs'_in", eval_occurs_in "#occurs_in_")), |
673 [("occurs_in",("Atools.occurs'_in", eval_occurs_in "#occurs_in_")), |
672 ("some_occur_in", |
674 ("some_occur_in", |
673 ("Atools.some'_occur'_in", eval_some_occur_in "#some_occur_in_")), |
675 ("Atools.some'_occur'_in", eval_some_occur_in "#some_occur_in_")), |
674 ("is_atom" ,("Atools.is'_atom", eval_is_atom "#is_atom_")), |
676 ("is_atom" ,("Atools.is'_atom", eval_is_atom "#is_atom_")), |