src/Tools/isac/Specify/Specify.thy
author wneuper <Walther.Neuper@jku.at>
Tue, 05 Dec 2023 18:15:45 +0100
changeset 60772 ac0317936138
parent 60764 f82fd40eb400
child 60773 439e23525491
permissions -rw-r--r--
prepare 1: towards I_Model.T_POS in Specify/ (and no I_Model.T)
Walther@60764
     1
(* Title:  "Specify/Specify.thy"
wneuper@59594
     2
   Author: Walther Neuper 110226
wneuper@59594
     3
   (c) due to copyright terms
Walther@60764
     4
Walther@60764
     5
 Specification phase
wneuper@59594
     6
 *)
wneuper@59594
     7
wneuper@59594
     8
theory Specify
wenzelm@60314
     9
  imports "$ISABELLE_ISAC/MathEngBasic/MathEngBasic"
wenzelm@60314
    10
  keywords "cas" :: thy_decl
wneuper@59594
    11
begin
walther@59938
    12
  ML_file "o-model.sml"
Walther@60705
    13
  ML_file "pre-conditions.sml" (*uses Model_Def.i_model*)
walther@59938
    14
  ML_file "i-model.sml"
walther@59959
    15
  ML_file "p-model.sml"
walther@59984
    16
  ML_file "m-match.sml"
walther@59960
    17
  ML_file refine.sml
walther@59959
    18
  ML_file "test-out.sml"
walther@59933
    19
  ML_file "specify-step.sml"
walther@59981
    20
  ML_file specification.sml
walther@59982
    21
  ML_file "cas-command.sml"
walther@59984
    22
  ML_file "p-spec.sml"
Walther@60772
    23
  ML_file specify.sml                                            
Walther@60609
    24
  ML_file "sub-problem.sml"
walther@59764
    25
  ML_file "step-specify.sml"
wneuper@59595
    26
wneuper@59594
    27
ML \<open>
Walther@60772
    28
open P_Spec
walther@60009
    29
\<close> ML \<open>
Walther@60772
    30
\<close> ML \<open>
Walther@60772
    31
\<close> ML \<open>
Walther@60772
    32
\<close> ML \<open>
Walther@60772
    33
\<close> ML \<open>
Walther@60772
    34
\<close> ML \<open>
Walther@60772
    35
\<close> text \<open>
Walther@60772
    36
fun ori_2itm (feedb:feedback_POS) _ all (id, vt, fd, d, ts) = 
Walther@60772
    37
  let 
Walther@60772
    38
    val ts' = union op = (values_POS' feedb) ts;
Walther@60772
    39
    val complete = if eq_set op = (ts', all) then true else false
Walther@60772
    40
  in
Walther@60772
    41
    case feedb of
Walther@60772
    42
      Cor_POS _ => if fd = "#undef"
Walther@60772
    43
      then (id, vt, complete, fd, (Sup_POS (d, ts'), Position.none))
Walther@60772
    44
	    else (id, vt, complete, fd, (Cor_POS (d, ts'), Position.none))
Walther@60772
    45
    | Inc_POS _ => if complete
Walther@60772
    46
  	  then (id, vt, true,  fd, (Cor_POS (d, ts'), Position.none))
Walther@60772
    47
  	  else (id, vt, false, fd, (Inc_POS (d, ts'), Position.none))
Walther@60772
    48
    | Sup_POS (d, ts') =>
Walther@60772
    49
  	  (id, vt, complete, fd, (Sup_POS (d, ts'), Position.none))
Walther@60772
    50
    | i => raise ERROR ("ori_2itm: uncovered case of " ^ feedback_POS_to_string (ContextC.for_ERROR ()) i)
Walther@60772
    51
  end
Walther@60772
    52
;
Walther@60772
    53
ori_2itm: feedback_POS -> descriptor -> Model_Def.values -> O_Model.single -> I_Model.single_POS
Walther@60772
    54
\<close> ML \<open>
Walther@60772
    55
\<close> text \<open>
Walther@60772
    56
(*old code kept for test/*)
Walther@60772
    57
fun is_notyet_input ctxt (itms:I_Model.T_POS) all (i, v, f, d, ts) pbt =
Walther@60772
    58
  case find_first (fn (_, (d', _)) => d = d') pbt of
Walther@60772
    59
    SOME (_, (_, pid)) =>
Walther@60772
    60
      (case find_first (fn (_, _, _, f', (feedb, _)) =>
Walther@60772
    61
          f = f' andalso d = (descriptor_POS feedb)) itms of
Walther@60772
    62
        SOME (_, _, _, _, (feedb:feedback_POS, _)) =>
Walther@60772
    63
          let val ts' = inter op = (values_POS' feedb) ts
Walther@60772
    64
          in
Walther@60772
    65
            if subset op = (ts, ts') 
Walther@60772
    66
            then (((strs2str' o map (UnparseC.term ctxt)) ts') ^ " already input", empty_single_POS)
Walther@60772
    67
	          else ("", ori_2itm feedb pid all (i, v, f, d, subtract op = ts' ts))
Walther@60772
    68
	        end
Walther@60772
    69
	    | NONE => ("", ori_2itm (Inc_POS (TermC.empty, [])) pid all (i, v, f, d, ts)))
Walther@60772
    70
  | NONE => ("", ori_2itm (Sup_POS (d, ts)) TermC.empty all (i, v, f, d, ts))
Walther@60772
    71
;
Walther@60772
    72
is_notyet_input: Proof.context -> I_Model.T_POS -> O_Model.values ->
Walther@60772
    73
  O_Model.single -> Model_Pattern.T -> I_Model.message * I_Model.single_POS
Walther@60772
    74
\<close> ML \<open>
Walther@60772
    75
\<close> ML \<open>
Walther@60772
    76
fun is_e_ts [] = true
Walther@60772
    77
  | is_e_ts [Const (\<^const_name>\<open>Nil\<close>, _)] = true
Walther@60772
    78
  | is_e_ts _ = false;
Walther@60772
    79
\<close> ML \<open>
Walther@60772
    80
\<close> ML \<open>
Walther@60772
    81
\<close> ML \<open>
Walther@60772
    82
\<close> ML \<open>
Walther@60772
    83
\<close> ML \<open>
Walther@60772
    84
\<close> ML \<open>
Walther@60772
    85
\<close> ML \<open>
Walther@60772
    86
\<close> ML \<open>
wneuper@59594
    87
\<close> ML \<open>
wneuper@59594
    88
\<close>
wneuper@59594
    89
end