wneuper@59595
|
1 |
(* Title: collect all defitions for the Lucas-Interpreter
|
wneuper@59595
|
2 |
Author: Walther Neuper 110226
|
wneuper@59595
|
3 |
(c) due to copyright terms
|
wneuper@59595
|
4 |
*)
|
wneuper@59595
|
5 |
|
wneuper@59599
|
6 |
theory Input_Descript imports "~~/src/Tools/isac/CalcElements/CalcElements"
|
wneuper@59595
|
7 |
begin
|
wneuper@59595
|
8 |
|
wneuper@59595
|
9 |
subsection \<open>typedecl for descriptions of input in specify-phase\<close>
|
wneuper@59595
|
10 |
text \<open>
|
wneuper@59595
|
11 |
The typedecl below MUST ALL be registered in "fun is_dsc"
|
wneuper@59595
|
12 |
\<close>
|
wneuper@59595
|
13 |
typedecl nam (* named variables *)
|
wneuper@59595
|
14 |
typedecl una (* unnamed variables *)
|
wneuper@59595
|
15 |
typedecl unl (* unnamed variables of type list, elementwise input prohibited*)
|
wneuper@59595
|
16 |
typedecl str (* structured variables *)
|
wneuper@59595
|
17 |
typedecl toreal (* var with undef real value: forces typing *)
|
wneuper@59595
|
18 |
typedecl toreall (* var with undef real list value: forces typing *)
|
wneuper@59595
|
19 |
typedecl tobooll (* var with undef bool list value: forces typing *)
|
wneuper@59595
|
20 |
typedecl unknow (* input without dsc in fmz=[] *)
|
wneuper@59595
|
21 |
typedecl cpy (* copy-named variables identified by .._0, .._i .._' in pbt *)
|
wneuper@59595
|
22 |
|
wneuper@59595
|
23 |
subsection \<open>consts for general descriptions of input in specify-phase\<close>
|
wneuper@59595
|
24 |
|
wneuper@59595
|
25 |
consts
|
wneuper@59595
|
26 |
(*TODO.180331: review for localisation of model-patterns and of method's guards*)
|
wneuper@59595
|
27 |
someList :: "'a list => unl" (*not for elementwise input, eg. inssort*)
|
wneuper@59595
|
28 |
|
wneuper@59595
|
29 |
additionalRels :: "bool list => una"
|
wneuper@59595
|
30 |
boundVariable :: "real => una"
|
wneuper@59595
|
31 |
derivative :: "real => una"
|
wneuper@59595
|
32 |
equalities :: "bool list => tobooll" (*WN071228 see fixedValues*)
|
wneuper@59595
|
33 |
equality :: "bool => una"
|
wneuper@59595
|
34 |
errorBound :: "bool => nam"
|
wneuper@59595
|
35 |
|
wneuper@59595
|
36 |
fixedValues :: "bool list => nam"
|
wneuper@59595
|
37 |
functionEq :: "bool => una" (*6.5.03: functionTerm -> functionEq*)
|
wneuper@59595
|
38 |
antiDerivative :: "bool => una"
|
wneuper@59595
|
39 |
functionOf :: "real => una"
|
wneuper@59595
|
40 |
(*functionTerm :: 'a => toreal 28.11.00*)
|
wneuper@59595
|
41 |
functionTerm :: "real => una" (*6.5.03: functionTerm -> functionEq*)
|
wneuper@59595
|
42 |
functionName :: "real => una"
|
wneuper@59595
|
43 |
interval :: "real set => una"
|
wneuper@59595
|
44 |
maxArgument :: "bool => toreal"
|
wneuper@59595
|
45 |
maximum :: "real => toreal"
|
wneuper@59595
|
46 |
|
wneuper@59595
|
47 |
relations :: "bool list => una"
|
wneuper@59595
|
48 |
solutions :: "bool list => toreall"
|
wneuper@59595
|
49 |
(*solution :: bool => toreal WN0509 bool list=> toreall --->EqSystem*)
|
wneuper@59595
|
50 |
solveFor :: "real => una"
|
wneuper@59595
|
51 |
differentiateFor:: "real => una"
|
wneuper@59595
|
52 |
unknown :: "'a => unknow"
|
wneuper@59595
|
53 |
valuesFor :: "real list => toreall"
|
wneuper@59595
|
54 |
|
wneuper@59595
|
55 |
intTestGiven :: "int => una"
|
wneuper@59595
|
56 |
realTestGiven :: "real => una"
|
wneuper@59595
|
57 |
realTestFind :: "real => una"
|
wneuper@59595
|
58 |
boolTestGiven :: "bool => una"
|
wneuper@59595
|
59 |
boolTestFind :: "bool => una"
|
wneuper@59595
|
60 |
|
wneuper@59595
|
61 |
subsection \<open>Functions decking for descriptions of input in specify-phase\<close>
|
wneuper@59595
|
62 |
ML \<open>
|
wneuper@59595
|
63 |
\<close> ML \<open>
|
wneuper@59595
|
64 |
signature INPUT_DESCRIPT =
|
wneuper@59595
|
65 |
sig
|
wneuper@59595
|
66 |
val is_reall_dsc: term -> bool
|
wneuper@59595
|
67 |
val is_booll_dsc: term -> bool
|
wneuper@59595
|
68 |
val is_list_dsc: term -> bool
|
wneuper@59595
|
69 |
val is_unl: term -> bool
|
wneuper@59595
|
70 |
val is_dsc: term -> bool
|
wneuper@59599
|
71 |
val pbl_ids: Proof.context -> term -> term -> term list
|
wneuper@59595
|
72 |
(* ---- for tests only: shifted from below to remove the Warning "unused" at fun.def. --------- *)
|
wneuper@59595
|
73 |
(* NONE *)
|
walther@59702
|
74 |
(*/-------------------------------------------------------- ! aktivate for Test_Isac BEGIN ---\* )
|
wneuper@59595
|
75 |
(* NONE *)
|
walther@59702
|
76 |
( *\--- ! aktivate for Test_Isac END ----------------------------------------------------------/*)
|
wneuper@59595
|
77 |
end
|
wneuper@59595
|
78 |
\<close> ML \<open>
|
wneuper@59595
|
79 |
(**)
|
wneuper@59595
|
80 |
structure Input_Descript(**): INPUT_DESCRIPT =(**)
|
wneuper@59595
|
81 |
struct
|
wneuper@59595
|
82 |
(**)
|
wneuper@59595
|
83 |
(* distinguish input to Model (deep embedding of terms as Isac's object language) *)
|
wneuper@59595
|
84 |
fun is_reall_dsc (Const (_, Type("fun", [Type ("List.list", [Type ("Real.real", [])]), _]))) = true
|
wneuper@59595
|
85 |
| is_reall_dsc (Const (_, Type("fun", [Type ("List.list", [Type ("Real.real", [])]),_])) $ _) = true
|
wneuper@59595
|
86 |
| is_reall_dsc _ = false;
|
wneuper@59595
|
87 |
fun is_booll_dsc (Const (_, Type("fun", [Type ("List.list", [Type ("HOL.bool", [])]), _]))) = true
|
wneuper@59595
|
88 |
| is_booll_dsc (Const (_, Type("fun", [Type ("List.list", [Type ("HOL.bool", [])]),_])) $ _) = true
|
wneuper@59595
|
89 |
| is_booll_dsc _ = false;
|
wneuper@59595
|
90 |
fun is_list_dsc (Const (_, Type("fun", [Type("List.list", _), _]))) = true
|
wneuper@59595
|
91 |
| is_list_dsc (Const (_, Type("fun", [Type("List.list", _), _])) $ _) = true
|
wneuper@59595
|
92 |
(*WN:8.5.03: ??? TODO test/../scrtools.sml ~~~~ ???*)
|
wneuper@59595
|
93 |
| is_list_dsc _ = false;
|
wneuper@59595
|
94 |
fun is_unl (Const (_, Type("fun", [_, Type("Input_Descript.unl", _)]))) = true
|
wneuper@59595
|
95 |
| is_unl _ = false;
|
wneuper@59595
|
96 |
fun is_dsc (Const(_, Type("fun", [_, Type ("Input_Descript.nam",_)]))) = true
|
wneuper@59595
|
97 |
| is_dsc (Const(_, Type("fun", [_, Type ("Input_Descript.una",_)]))) = true
|
wneuper@59595
|
98 |
| is_dsc (Const(_, Type("fun", [_, Type ("Input_Descript.unl",_)]))) = true
|
wneuper@59595
|
99 |
| is_dsc (Const(_, Type("fun", [_, Type ("Input_Descript.str",_)]))) = true
|
wneuper@59595
|
100 |
| is_dsc (Const(_, Type("fun", [_, Type ("Input_Descript.toreal",_)]))) = true
|
wneuper@59595
|
101 |
| is_dsc (Const(_, Type("fun", [_, Type ("Input_Descript.toreall",_)])))= true
|
wneuper@59595
|
102 |
| is_dsc (Const(_, Type("fun", [_, Type ("Input_Descript.tobooll",_)])))= true
|
wneuper@59595
|
103 |
| is_dsc (Const(_, Type("fun", [_, Type ("Input_Descript.unknow",_)])))= true
|
wneuper@59595
|
104 |
| is_dsc (Const(_, Type("fun", [_, Type ("Input_Descript.cpy",_)])))= true
|
wneuper@59595
|
105 |
| is_dsc _ = false;
|
wneuper@59595
|
106 |
|
wneuper@59599
|
107 |
(* given the input value (from split_dts)
|
wneuper@59599
|
108 |
make the value in a problem-env according to description-type
|
wneuper@59599
|
109 |
28.8.01: .nam and .una impl. properly, others copied .. TODO.
|
wneuper@59599
|
110 |
19/03/15 17:33, Makarius wrote:
|
wneuper@59599
|
111 |
>>> val i = case HOLogic.dest_number t of
|
wneuper@59599
|
112 |
>>> (Type ("Nat.nat", []), i) => i
|
wneuper@59599
|
113 |
>> Formal names should never be hardwired as ML string constants. Use
|
wneuper@59599
|
114 |
>> @{type_name nat} above, or better @{typ nat} for the whole type *)
|
walther@59603
|
115 |
fun pbl_ids ctxt (Const(_, Type ("fun", [_, Type ("Input_Descript.nam", _)]))) v =
|
wneuper@59599
|
116 |
if TermC.is_list v
|
wneuper@59599
|
117 |
then [v] (*eg. [r=Arbfix]*)
|
wneuper@59599
|
118 |
else
|
wneuper@59599
|
119 |
(case v of (*eg. eps=#0*) (Const ("HOL.eq", _) $ l $ r) => [r, l]
|
walther@59603
|
120 |
| _ => error ("pbl_ids Input_Descript.nam: no equality " ^ Rule.term_to_string' ctxt v))
|
wneuper@59599
|
121 |
| pbl_ids _ (Const (_, Type ("fun", [_,Type ("Input_Descript.una", _)]))) v = [v]
|
wneuper@59599
|
122 |
| pbl_ids _ (Const (_, Type ("fun", [_,Type ("Input_Descript.unl", _)]))) v = [v]
|
wneuper@59599
|
123 |
| pbl_ids _ (Const (_, Type ("fun", [_,Type ("Input_Descript.str", _)]))) v = [v]
|
wneuper@59599
|
124 |
| pbl_ids _ (Const (_, Type ("fun", [_,Type ("Input_Descript.toreal", _)]))) v = [v]
|
wneuper@59599
|
125 |
| pbl_ids _ (Const (_, Type ("fun", [_,Type ("Input_Descript.toreall", _)])))v = [v]
|
wneuper@59599
|
126 |
| pbl_ids _ (Const (_, Type ("fun", [_,Type ("Input_Descript.unknown" ,_)])))v = [v]
|
wneuper@59599
|
127 |
| pbl_ids _ _ v = error ("pbl_ids: not implemented for " ^ Rule.term2str v);
|
wneuper@59599
|
128 |
|
wneuper@59599
|
129 |
(* given an already input itm, ((14.9.01: no difference to pbl_ids jet!!))
|
wneuper@59599
|
130 |
make the value in a problem-env according to description-type.
|
wneuper@59599
|
131 |
28.8.01: .nam and .una impl. properly, others copied .. TODO
|
walther@59603
|
132 |
fun pbl_ids' (Const(_, Type ("fun", [_, Type ("Input_Descript.nam", _)]))) vs =
|
wneuper@59599
|
133 |
(case vs of
|
walther@59603
|
134 |
[] => error ("pbl_ids' Input_Descript.nam called with []")
|
wneuper@59599
|
135 |
| [t] =>
|
wneuper@59599
|
136 |
(case t of (*eg. eps=#0*)
|
wneuper@59599
|
137 |
(Const ("HOL.eq",_) $ l $ r) => [r,l]
|
walther@59603
|
138 |
| _ => error ("pbl_ids' Input_Descript.nam: no equality " ^ term2str t))
|
wneuper@59599
|
139 |
| _ => vs (*14.9.01: ???TODO *))
|
wneuper@59599
|
140 |
| pbl_ids' (Const (_, Type ("fun", [_, Type("Input_Descript.una", _)]))) vs = vs
|
wneuper@59599
|
141 |
| pbl_ids' (Const (_, Type ("fun", [_, Type("Input_Descript.unl", _)]))) vs = vs
|
wneuper@59599
|
142 |
| pbl_ids' (Const (_, Type ("fun", [_, Type("Input_Descript.str", _)]))) vs = vs
|
wneuper@59599
|
143 |
| pbl_ids' (Const (_, Type ("fun", [_, Type("Input_Descript.toreal", _)]))) vs = vs
|
wneuper@59599
|
144 |
| pbl_ids' (Const (_, Type ("fun", [_, Type("Input_Descript.toreall", _)])))vs = vs
|
wneuper@59599
|
145 |
| pbl_ids' (Const (_, Type ("fun", [_, Type("Input_Descript.unknown", _)])))vs = vs
|
wneuper@59599
|
146 |
| pbl_ids' _ vs = error ("pbl_ids': not implemented for " ^ terms2str vs);*)
|
wneuper@59599
|
147 |
|
wneuper@59595
|
148 |
(**)end(**)
|
wneuper@59595
|
149 |
\<close> ML \<open>
|
wneuper@59595
|
150 |
\<close> ML \<open>
|
wneuper@59595
|
151 |
\<close>
|
wneuper@59595
|
152 |
|
wneuper@59599
|
153 |
end
|