src/HOL/List.ML
changeset 7224 e41e64476f9b
parent 7032 d6efb3b8e669
child 7246 33058867d6eb
equal deleted inserted replaced
7223:b0198ca65867 7224:e41e64476f9b
   251 local
   251 local
   252 
   252 
   253 val list_eq_pattern =
   253 val list_eq_pattern =
   254   Thm.read_cterm (Theory.sign_of List.thy) ("(xs::'a list) = ys",HOLogic.boolT);
   254   Thm.read_cterm (Theory.sign_of List.thy) ("(xs::'a list) = ys",HOLogic.boolT);
   255 
   255 
   256 fun last (cons as Const("List.list.op #",_) $ _ $ xs) =
   256 fun last (cons as Const("List.list.Cons",_) $ _ $ xs) =
   257       (case xs of Const("List.list.[]",_) => cons | _ => last xs)
   257       (case xs of Const("List.list.Nil",_) => cons | _ => last xs)
   258   | last (Const("List.op @",_) $ _ $ ys) = last ys
   258   | last (Const("List.op @",_) $ _ $ ys) = last ys
   259   | last t = t;
   259   | last t = t;
   260 
   260 
   261 fun list1 (Const("List.list.op #",_) $ _ $ Const("List.list.[]",_)) = true
   261 fun list1 (Const("List.list.Cons",_) $ _ $ Const("List.list.Nil",_)) = true
   262   | list1 _ = false;
   262   | list1 _ = false;
   263 
   263 
   264 fun butlast ((cons as Const("List.list.op #",_) $ x) $ xs) =
   264 fun butlast ((cons as Const("List.list.Cons",_) $ x) $ xs) =
   265       (case xs of Const("List.list.[]",_) => xs | _ => cons $ butlast xs)
   265       (case xs of Const("List.list.Nil",_) => xs | _ => cons $ butlast xs)
   266   | butlast ((app as Const("List.op @",_) $ xs) $ ys) = app $ butlast ys
   266   | butlast ((app as Const("List.op @",_) $ xs) $ ys) = app $ butlast ys
   267   | butlast xs = Const("List.list.[]",fastype_of xs);
   267   | butlast xs = Const("List.list.Nil",fastype_of xs);
   268 
   268 
   269 val rearr_tac =
   269 val rearr_tac =
   270   simp_tac (HOL_basic_ss addsimps [append_assoc,append_Nil,append_Cons]);
   270   simp_tac (HOL_basic_ss addsimps [append_assoc,append_Nil,append_Cons]);
   271 
   271 
   272 fun list_eq sg _ (F as (eq as Const(_,eqT)) $ lhs $ rhs) =
   272 fun list_eq sg _ (F as (eq as Const(_,eqT)) $ lhs $ rhs) =