src/HOL/Bali/Term.thy
author wenzelm
Wed Feb 10 00:50:36 2010 +0100 (2010-02-10)
changeset 35069 09154b995ed8
parent 35067 af4c18c30593
child 35315 fbdc860d87a3
permissions -rw-r--r--
removed obsolete CVS Ids;
     1 (*  Title:      HOL/Bali/Term.thy
     2     Author:     David von Oheimb
     3 *)
     4 
     5 header {* Java expressions and statements *}
     6 
     7 theory Term imports Value Table begin
     8 
     9 text {*
    10 design issues:
    11 \begin{itemize}
    12 \item invocation frames for local variables could be reduced to special static
    13   objects (one per method). This would reduce redundancy, but yield a rather
    14   non-standard execution model more difficult to understand.
    15 \item method bodies separated from calls to handle assumptions in axiomat. 
    16   semantics
    17   NB: Body is intended to be in the environment of the called method.
    18 \item class initialization is regarded as (auxiliary) statement 
    19       (required for AxSem)
    20 \item result expression of method return is handled by a special result variable
    21   result variable is treated uniformly with local variables
    22   \begin{itemize}
    23   \item[+] welltypedness and existence of the result/return expression is 
    24            ensured without extra efford
    25   \end{itemize}
    26 \end{itemize}
    27 
    28 simplifications:
    29 \begin{itemize}
    30 \item expression statement allowed for any expression
    31 \item This  is modeled as a special non-assignable local variable
    32 \item Super is modeled as a general expression with the same value as This
    33 \item access to field x in current class via This.x
    34 \item NewA creates only one-dimensional arrays;
    35   initialization of further subarrays may be simulated with nested NewAs
    36 \item The 'Lit' constructor is allowed to contain a reference value.
    37   But this is assumed to be prohibited in the input language, which is enforced
    38   by the type-checking rules.
    39 \item a call of a static method via a type name may be simulated by a dummy 
    40       variable
    41 \item no nested blocks with inner local variables
    42 \item no synchronized statements
    43 \item no secondary forms of if, while (e.g. no for) (may be easily simulated)
    44 \item no switch (may be simulated with if)
    45 \item the @{text try_catch_finally} statement is divided into the 
    46       @{text try_catch} statement 
    47       and a finally statement, which may be considered as try..finally with 
    48       empty catch
    49 \item the @{text try_catch} statement has exactly one catch clause; 
    50       multiple ones can be
    51   simulated with instanceof
    52 \item the compiler is supposed to add the annotations {@{text _}} during 
    53       type-checking. This
    54   transformation is left out as its result is checked by the type rules anyway
    55 \end{itemize}
    56 *}
    57 
    58 
    59 
    60 types locals = "(lname, val) table"  --{* local variables *}
    61 
    62 
    63 datatype jump
    64         = Break label --{* break *}
    65         | Cont label  --{* continue *}
    66         | Ret         --{* return from method *}
    67 
    68 datatype xcpt        --{* exception *}
    69         = Loc loc    --{* location of allocated execption object *}
    70         | Std xname  --{* intermediate standard exception, see Eval.thy *}
    71 
    72 datatype error
    73        =  AccessViolation  --{* Access to a member that isn't permitted *}
    74         | CrossMethodJump  --{* Method exits with a break or continue *}
    75 
    76 datatype abrupt       --{* abrupt completion *} 
    77         = Xcpt xcpt   --{* exception *}
    78         | Jump jump   --{* break, continue, return *}
    79         | Error error -- {* runtime errors, we wan't to detect and proof absent
    80                             in welltyped programms *}
    81 types
    82   abopt  = "abrupt option"
    83 
    84 text {* Local variable store and exception. 
    85 Anticipation of State.thy used by smallstep semantics. For a method call, 
    86 we save the local variables of the caller in the term Callee to restore them 
    87 after method return. Also an exception must be restored after the finally
    88 statement *}
    89 
    90 translations
    91  "locals" <= (type) "(lname, val) table"
    92 
    93 datatype inv_mode                  --{* invocation mode for method calls *}
    94         = Static                   --{* static *}
    95         | SuperM                   --{* super  *}
    96         | IntVir                   --{* interface or virtual *}
    97 
    98 record  sig =              --{* signature of a method, cf. 8.4.2  *}
    99           name ::"mname"   --{* acutally belongs to Decl.thy *}
   100           parTs::"ty list"        
   101 
   102 translations
   103   "sig" <= (type) "\<lparr>name::mname,parTs::ty list\<rparr>"
   104   "sig" <= (type) "\<lparr>name::mname,parTs::ty list,\<dots>::'a\<rparr>"
   105 
   106 --{* function codes for unary operations *}
   107 datatype unop =  UPlus    -- {*{\tt +} unary plus*} 
   108                | UMinus   -- {*{\tt -} unary minus*}
   109                | UBitNot  -- {*{\tt ~} bitwise NOT*}
   110                | UNot     -- {*{\tt !} logical complement*}
   111 
   112 --{* function codes for binary operations *}
   113 datatype binop = Mul     -- {*{\tt * }   multiplication*}
   114                | Div     -- {*{\tt /}   division*}
   115                | Mod     -- {*{\tt \%}   remainder*}
   116                | Plus    -- {*{\tt +}   addition*}
   117                | Minus   -- {*{\tt -}   subtraction*}
   118                | LShift  -- {*{\tt <<}  left shift*}
   119                | RShift  -- {*{\tt >>}  signed right shift*}
   120                | RShiftU -- {*{\tt >>>} unsigned right shift*}
   121                | Less    -- {*{\tt <}   less than*}
   122                | Le      -- {*{\tt <=}  less than or equal*}
   123                | Greater -- {*{\tt >}   greater than*}
   124                | Ge      -- {*{\tt >=}  greater than or equal*}
   125                | Eq      -- {*{\tt ==}  equal*}
   126                | Neq     -- {*{\tt !=}  not equal*}
   127                | BitAnd  -- {*{\tt \&}   bitwise AND*}
   128                | And     -- {*{\tt \&}   boolean AND*}
   129                | BitXor  -- {*{\texttt \^}   bitwise Xor*}
   130                | Xor     -- {*{\texttt \^}   boolean Xor*}
   131                | BitOr   -- {*{\tt |}   bitwise Or*}
   132                | Or      -- {*{\tt |}   boolean Or*}
   133                | CondAnd -- {*{\tt \&\&}  conditional And*}
   134                | CondOr  -- {*{\tt ||}  conditional Or *}
   135 text{* The boolean operators {\tt \&} and {\tt |} strictly evaluate both
   136 of their arguments. The conditional operators {\tt \&\&} and {\tt ||} only 
   137 evaluate the second argument if the value of the whole expression isn't 
   138 allready determined by the first argument.
   139 e.g.: {\tt false \&\& e} e is not evaluated;  
   140       {\tt true || e} e is not evaluated; 
   141 *}
   142 
   143 datatype var
   144         = LVar lname --{* local variable (incl. parameters) *}
   145         | FVar qtname qtname bool expr vname ("{_,_,_}_.._"[10,10,10,85,99]90)
   146                      --{* class field *}
   147                      --{* @{term "{accC,statDeclC,stat}e..fn"}   *}
   148                      --{* @{text accC}: accessing class (static class were *}
   149                      --{* the code is declared. Annotation only needed for *}
   150                      --{* evaluation to check accessibility) *}
   151                      --{* @{text statDeclC}: static declaration class of field*}
   152                      --{* @{text stat}: static or instance field?*}
   153                      --{* @{text e}: reference to object*}
   154                      --{* @{text fn}: field name*}
   155         | AVar expr expr ("_.[_]"[90,10   ]90)
   156                      --{* array component *}
   157                      --{* @{term "e1.[e2]"}: e1 array reference; e2 index *}
   158         | InsInitV stmt var 
   159                      --{* insertion of initialization before evaluation   *}
   160                      --{* of var (technical term for smallstep semantics.)*}
   161 
   162 and expr
   163         = NewC qtname         --{* class instance creation *}
   164         | NewA ty expr ("New _[_]"[99,10   ]85) 
   165                               --{* array creation *} 
   166         | Cast ty expr        --{* type cast  *}
   167         | Inst expr ref_ty ("_ InstOf _"[85,99] 85)   
   168                               --{* instanceof *}     
   169         | Lit  val              --{* literal value, references not allowed *}
   170         | UnOp unop expr        --{* unary operation *}
   171         | BinOp binop expr expr --{* binary operation *}
   172         
   173         | Super               --{* special Super keyword *}
   174         | Acc  var            --{* variable access *}
   175         | Ass  var expr       ("_:=_"   [90,85   ]85)
   176                               --{* variable assign *} 
   177         | Cond expr expr expr ("_ ? _ : _" [85,85,80]80) --{* conditional *}  
   178         | Call qtname ref_ty inv_mode expr mname "(ty list)" "(expr list)"  
   179             ("{_,_,_}_\<cdot>_'( {_}_')"[10,10,10,85,99,10,10]85) 
   180                     --{* method call *} 
   181                     --{* @{term "{accC,statT,mode}e\<cdot>mn({pTs}args)"} " *}
   182                     --{* @{text accC}: accessing class (static class were *}
   183                     --{* the call code is declared. Annotation only needed for*}
   184                     --{* evaluation to check accessibility) *}
   185                     --{* @{text statT}: static declaration class/interface of *}
   186                     --{* method *}
   187                     --{* @{text mode}: invocation mode *}
   188                     --{* @{text e}: reference to object*}
   189                     --{* @{text mn}: field name*}   
   190                     --{* @{text pTs}: types of parameters *}
   191                     --{* @{text args}: the actual parameters/arguments *} 
   192         | Methd qtname sig    --{*   (folded) method (see below) *}
   193         | Body qtname stmt    --{* (unfolded) method body *}
   194         | InsInitE stmt expr  
   195                  --{* insertion of initialization before *}
   196                  --{* evaluation of expr (technical term for smallstep sem.) *}
   197         | Callee locals expr  --{* save callers locals in callee-Frame *}
   198                               --{* (technical term for smallstep semantics) *}
   199 and  stmt
   200         = Skip                  --{* empty      statement *}
   201         | Expr  expr            --{* expression statement *}
   202         | Lab   jump stmt       ("_\<bullet> _" [      99,66]66)
   203                                 --{* labeled statement; handles break *}
   204         | Comp  stmt stmt       ("_;; _"                  [      66,65]65)
   205         | If'   expr stmt stmt  ("If'(_') _ Else _"       [   80,79,79]70)
   206         | Loop  label expr stmt ("_\<bullet> While'(_') _"        [   99,80,79]70)
   207         | Jmp jump              --{* break, continue, return *}
   208         | Throw expr
   209         | TryC  stmt qtname vname stmt ("Try _ Catch'(_ _') _"  [79,99,80,79]70)
   210              --{* @{term "Try c1 Catch(C vn) c2"} *} 
   211              --{* @{text c1}: block were exception may be thrown *}
   212              --{* @{text C}:  execption class to catch *}
   213              --{* @{text vn}: local name for exception used in @{text c2}*}
   214              --{* @{text c2}: block to execute when exception is cateched*}
   215         | Fin  stmt  stmt        ("_ Finally _"               [      79,79]70)
   216         | FinA abopt stmt       --{* Save abruption of first statement *} 
   217                                 --{* technical term  for smallstep sem.) *}
   218         | Init  qtname          --{* class initialization *}
   219 
   220 
   221 text {*
   222 The expressions Methd and Body are artificial program constructs, in the
   223 sense that they are not used to define a concrete Bali program. In the 
   224 operational semantic's they are "generated on the fly" 
   225 to decompose the task to define the behaviour of the Call expression. 
   226 They are crucial for the axiomatic semantics to give a syntactic hook to insert 
   227 some assertions (cf. AxSem.thy, Eval.thy). 
   228 The Init statement (to initialize a class on its first use) is 
   229 inserted in various places by the semantics. 
   230 Callee, InsInitV, InsInitE,FinA are only needed as intermediate steps in the
   231 smallstep (transition) semantics (cf. Trans.thy). Callee is used to save the 
   232 local variables of the caller for method return. So ve avoid modelling a 
   233 frame stack.
   234 The InsInitV/E terms are only used by the smallstep semantics to model the
   235 intermediate steps of class-initialisation.
   236 *}
   237  
   238 types "term" = "(expr+stmt,var,expr list) sum3"
   239 translations
   240   "sig"   <= (type) "mname \<times> ty list"
   241   "var"   <= (type) "Term.var"
   242   "expr"  <= (type) "Term.expr"
   243   "stmt"  <= (type) "Term.stmt"
   244   "term"  <= (type) "(expr+stmt,var,expr list) sum3"
   245 
   246 abbreviation this :: expr
   247   where "this == Acc (LVar This)"
   248 
   249 abbreviation LAcc :: "vname \<Rightarrow> expr" ("!!")
   250   where "!!v == Acc (LVar (EName (VNam v)))"
   251 
   252 abbreviation
   253   LAss :: "vname \<Rightarrow> expr \<Rightarrow>stmt" ("_:==_" [90,85] 85)
   254   where "v:==e == Expr (Ass (LVar (EName (VNam  v))) e)"
   255 
   256 abbreviation
   257   Return :: "expr \<Rightarrow> stmt"
   258   where "Return e == Expr (Ass (LVar (EName Res)) e);; Jmp Ret" --{* \tt Res := e;; Jmp Ret *}
   259 
   260 abbreviation
   261   StatRef :: "ref_ty \<Rightarrow> expr"
   262   where "StatRef rt == Cast (RefT rt) (Lit Null)"
   263   
   264 constdefs
   265 
   266   is_stmt :: "term \<Rightarrow> bool"
   267  "is_stmt t \<equiv> \<exists>c. t=In1r c"
   268 
   269 ML {* bind_thms ("is_stmt_rews", sum3_instantiate @{context} @{thm is_stmt_def}) *}
   270 
   271 declare is_stmt_rews [simp]
   272 
   273 text {*
   274   Here is some syntactic stuff to handle the injections of statements,
   275   expressions, variables and expression lists into general terms.
   276 *}
   277 
   278 abbreviation (input)
   279   expr_inj_term :: "expr \<Rightarrow> term" ("\<langle>_\<rangle>\<^sub>e" 1000)
   280   where "\<langle>e\<rangle>\<^sub>e == In1l e"
   281 
   282 abbreviation (input)
   283   stmt_inj_term :: "stmt \<Rightarrow> term" ("\<langle>_\<rangle>\<^sub>s" 1000)
   284   where "\<langle>c\<rangle>\<^sub>s == In1r c"
   285 
   286 abbreviation (input)
   287   var_inj_term :: "var \<Rightarrow> term"  ("\<langle>_\<rangle>\<^sub>v" 1000)
   288   where "\<langle>v\<rangle>\<^sub>v == In2 v"
   289 
   290 abbreviation (input)
   291   lst_inj_term :: "expr list \<Rightarrow> term" ("\<langle>_\<rangle>\<^sub>l" 1000)
   292   where "\<langle>es\<rangle>\<^sub>l == In3 es"
   293 
   294 text {* It seems to be more elegant to have an overloaded injection like the
   295 following.
   296 *}
   297 
   298 axclass inj_term < "type"
   299 consts inj_term:: "'a::inj_term \<Rightarrow> term" ("\<langle>_\<rangle>" 1000)
   300 
   301 text {* How this overloaded injections work can be seen in the theory 
   302 @{text DefiniteAssignment}. Other big inductive relations on
   303 terms defined in theories @{text WellType}, @{text Eval}, @{text Evaln} and
   304 @{text AxSem} don't follow this convention right now, but introduce subtle 
   305 syntactic sugar in the relations themselves to make a distinction on 
   306 expressions, statements and so on. So unfortunately you will encounter a 
   307 mixture of dealing with these injections. The abbreviations above are used
   308 as bridge between the different conventions.  
   309 *}
   310 
   311 instance stmt::inj_term ..
   312 
   313 defs (overloaded)
   314 stmt_inj_term_def: "\<langle>c::stmt\<rangle> \<equiv> In1r c"
   315 
   316 lemma stmt_inj_term_simp: "\<langle>c::stmt\<rangle> = In1r c"
   317 by (simp add: stmt_inj_term_def)
   318 
   319 lemma  stmt_inj_term [iff]: "\<langle>x::stmt\<rangle> = \<langle>y\<rangle> \<equiv> x = y"
   320   by (simp add: stmt_inj_term_simp)
   321 
   322 instance expr::inj_term ..
   323 
   324 defs (overloaded)
   325 expr_inj_term_def: "\<langle>e::expr\<rangle> \<equiv> In1l e"
   326 
   327 lemma expr_inj_term_simp: "\<langle>e::expr\<rangle> = In1l e"
   328 by (simp add: expr_inj_term_def)
   329 
   330 lemma expr_inj_term [iff]: "\<langle>x::expr\<rangle> = \<langle>y\<rangle> \<equiv> x = y"
   331   by (simp add: expr_inj_term_simp)
   332 
   333 instance var::inj_term ..
   334 
   335 defs (overloaded)
   336 var_inj_term_def: "\<langle>v::var\<rangle> \<equiv> In2 v"
   337 
   338 lemma var_inj_term_simp: "\<langle>v::var\<rangle> = In2 v"
   339 by (simp add: var_inj_term_def)
   340 
   341 lemma var_inj_term [iff]: "\<langle>x::var\<rangle> = \<langle>y\<rangle> \<equiv> x = y"
   342   by (simp add: var_inj_term_simp)
   343 
   344 instance "list":: (type) inj_term ..
   345 
   346 defs (overloaded)
   347 expr_list_inj_term_def: "\<langle>es::expr list\<rangle> \<equiv> In3 es"
   348 
   349 lemma expr_list_inj_term_simp: "\<langle>es::expr list\<rangle> = In3 es"
   350 by (simp add: expr_list_inj_term_def)
   351 
   352 lemma expr_list_inj_term [iff]: "\<langle>x::expr list\<rangle> = \<langle>y\<rangle> \<equiv> x = y"
   353   by (simp add: expr_list_inj_term_simp)
   354 
   355 lemmas inj_term_simps = stmt_inj_term_simp expr_inj_term_simp var_inj_term_simp
   356                         expr_list_inj_term_simp
   357 lemmas inj_term_sym_simps = stmt_inj_term_simp [THEN sym] 
   358                             expr_inj_term_simp [THEN sym]
   359                             var_inj_term_simp [THEN sym]
   360                             expr_list_inj_term_simp [THEN sym]
   361 
   362 lemma stmt_expr_inj_term [iff]: "\<langle>t::stmt\<rangle> \<noteq> \<langle>w::expr\<rangle>"
   363   by (simp add: inj_term_simps)
   364 lemma expr_stmt_inj_term [iff]: "\<langle>t::expr\<rangle> \<noteq> \<langle>w::stmt\<rangle>"
   365   by (simp add: inj_term_simps)
   366 lemma stmt_var_inj_term [iff]: "\<langle>t::stmt\<rangle> \<noteq> \<langle>w::var\<rangle>"
   367   by (simp add: inj_term_simps)
   368 lemma var_stmt_inj_term [iff]: "\<langle>t::var\<rangle> \<noteq> \<langle>w::stmt\<rangle>"
   369   by (simp add: inj_term_simps)
   370 lemma stmt_elist_inj_term [iff]: "\<langle>t::stmt\<rangle> \<noteq> \<langle>w::expr list\<rangle>"
   371   by (simp add: inj_term_simps)
   372 lemma elist_stmt_inj_term [iff]: "\<langle>t::expr list\<rangle> \<noteq> \<langle>w::stmt\<rangle>"
   373   by (simp add: inj_term_simps)
   374 lemma expr_var_inj_term [iff]: "\<langle>t::expr\<rangle> \<noteq> \<langle>w::var\<rangle>"
   375   by (simp add: inj_term_simps)
   376 lemma var_expr_inj_term [iff]: "\<langle>t::var\<rangle> \<noteq> \<langle>w::expr\<rangle>"
   377   by (simp add: inj_term_simps)
   378 lemma expr_elist_inj_term [iff]: "\<langle>t::expr\<rangle> \<noteq> \<langle>w::expr list\<rangle>"
   379   by (simp add: inj_term_simps)
   380 lemma elist_expr_inj_term [iff]: "\<langle>t::expr list\<rangle> \<noteq> \<langle>w::expr\<rangle>"
   381   by (simp add: inj_term_simps)
   382 lemma var_elist_inj_term [iff]: "\<langle>t::var\<rangle> \<noteq> \<langle>w::expr list\<rangle>"
   383   by (simp add: inj_term_simps)
   384 lemma elist_var_inj_term [iff]: "\<langle>t::expr list\<rangle> \<noteq> \<langle>w::var\<rangle>"
   385   by (simp add: inj_term_simps)
   386 
   387 lemma term_cases: "
   388   \<lbrakk>\<And> v. P \<langle>v\<rangle>\<^sub>v; \<And> e. P \<langle>e\<rangle>\<^sub>e;\<And> c. P \<langle>c\<rangle>\<^sub>s;\<And> l. P \<langle>l\<rangle>\<^sub>l\<rbrakk>
   389   \<Longrightarrow> P t"
   390   apply (cases t)
   391   apply (case_tac a)
   392   apply auto
   393   done
   394 
   395 section {* Evaluation of unary operations *}
   396 consts eval_unop :: "unop \<Rightarrow> val \<Rightarrow> val"
   397 primrec
   398 "eval_unop UPlus   v = Intg (the_Intg v)"
   399 "eval_unop UMinus  v = Intg (- (the_Intg v))"
   400 "eval_unop UBitNot v = Intg 42"                -- "FIXME: Not yet implemented"
   401 "eval_unop UNot    v = Bool (\<not> the_Bool v)"
   402 
   403 section {* Evaluation of binary operations *}
   404 consts eval_binop :: "binop \<Rightarrow> val \<Rightarrow> val \<Rightarrow> val"
   405 primrec
   406 "eval_binop Mul     v1 v2 = Intg ((the_Intg v1) * (the_Intg v2))" 
   407 "eval_binop Div     v1 v2 = Intg ((the_Intg v1) div (the_Intg v2))"
   408 "eval_binop Mod     v1 v2 = Intg ((the_Intg v1) mod (the_Intg v2))"
   409 "eval_binop Plus    v1 v2 = Intg ((the_Intg v1) + (the_Intg v2))"
   410 "eval_binop Minus   v1 v2 = Intg ((the_Intg v1) - (the_Intg v2))"
   411 
   412 -- "Be aware of the explicit coercion of the shift distance to nat"
   413 "eval_binop LShift  v1 v2 = Intg ((the_Intg v1) *   (2^(nat (the_Intg v2))))"
   414 "eval_binop RShift  v1 v2 = Intg ((the_Intg v1) div (2^(nat (the_Intg v2))))"
   415 "eval_binop RShiftU v1 v2 = Intg 42" --"FIXME: Not yet implemented"
   416 
   417 "eval_binop Less    v1 v2 = Bool ((the_Intg v1) < (the_Intg v2))" 
   418 "eval_binop Le      v1 v2 = Bool ((the_Intg v1) \<le> (the_Intg v2))"
   419 "eval_binop Greater v1 v2 = Bool ((the_Intg v2) < (the_Intg v1))"
   420 "eval_binop Ge      v1 v2 = Bool ((the_Intg v2) \<le> (the_Intg v1))"
   421 
   422 "eval_binop Eq      v1 v2 = Bool (v1=v2)"
   423 "eval_binop Neq     v1 v2 = Bool (v1\<noteq>v2)"
   424 "eval_binop BitAnd  v1 v2 = Intg 42" -- "FIXME: Not yet implemented"
   425 "eval_binop And     v1 v2 = Bool ((the_Bool v1) \<and> (the_Bool v2))"
   426 "eval_binop BitXor  v1 v2 = Intg 42" -- "FIXME: Not yet implemented"
   427 "eval_binop Xor     v1 v2 = Bool ((the_Bool v1) \<noteq> (the_Bool v2))"
   428 "eval_binop BitOr   v1 v2 = Intg 42" -- "FIXME: Not yet implemented"
   429 "eval_binop Or      v1 v2 = Bool ((the_Bool v1) \<or> (the_Bool v2))"
   430 "eval_binop CondAnd v1 v2 = Bool ((the_Bool v1) \<and> (the_Bool v2))"
   431 "eval_binop CondOr  v1 v2 = Bool ((the_Bool v1) \<or> (the_Bool v2))"
   432 
   433 constdefs need_second_arg :: "binop \<Rightarrow> val \<Rightarrow> bool"
   434 "need_second_arg binop v1 \<equiv> \<not> ((binop=CondAnd \<and>  \<not> the_Bool v1) \<or>
   435                                (binop=CondOr  \<and> the_Bool v1))"
   436 text {* @{term CondAnd} and @{term CondOr} only evalulate the second argument
   437  if the value isn't already determined by the first argument*}
   438 
   439 lemma need_second_arg_CondAnd [simp]: "need_second_arg CondAnd (Bool b) = b" 
   440 by (simp add: need_second_arg_def)
   441 
   442 lemma need_second_arg_CondOr [simp]: "need_second_arg CondOr (Bool b) = (\<not> b)" 
   443 by (simp add: need_second_arg_def)
   444 
   445 lemma need_second_arg_strict[simp]: 
   446  "\<lbrakk>binop\<noteq>CondAnd; binop\<noteq>CondOr\<rbrakk> \<Longrightarrow> need_second_arg binop b"
   447 by (cases binop) 
   448    (simp_all add: need_second_arg_def)
   449 end