src/Tools/Haskell/Haskell.thy
changeset 74197 1f78a40e4399
parent 74196 6dc7ff326906
child 74203 92f08f3d77bd
equal deleted inserted replaced
74196:6dc7ff326906 74197:1f78a40e4399
  2227 {-# LANGUAGE OverloadedStrings #-}
  2227 {-# LANGUAGE OverloadedStrings #-}
  2228 
  2228 
  2229 module Isabelle.Term (
  2229 module Isabelle.Term (
  2230   Indexname, Sort, Typ(..), Term(..),
  2230   Indexname, Sort, Typ(..), Term(..),
  2231   Free, lambda, declare_frees, incr_boundvars, subst_bound, dest_abs, strip_abs,
  2231   Free, lambda, declare_frees, incr_boundvars, subst_bound, dest_abs, strip_abs,
  2232   type_op0, type_op1, op0, op1, op2, typed_op1, typed_op2, binder,
  2232   type_op0, type_op1, op0, op1, op2, typed_op0, typed_op1, typed_op2, binder,
  2233   dummyS, dummyT, is_dummyT, propT, is_propT, (-->), dest_funT, (--->),
  2233   dummyS, dummyT, is_dummyT, propT, is_propT, (-->), dest_funT, (--->),
  2234   aconv, list_comb, strip_comb, head_of
  2234   aconv, list_comb, strip_comb, head_of
  2235 )
  2235 )
  2236 where
  2236 where
  2237 
  2237 
  2361   where
  2361   where
  2362     mk t u = App (App (Const (name, []), t), u)
  2362     mk t u = App (App (Const (name, []), t), u)
  2363     dest (App (App (Const (c, _), t), u)) | c == name = Just (t, u)
  2363     dest (App (App (Const (c, _), t), u)) | c == name = Just (t, u)
  2364     dest _ = Nothing
  2364     dest _ = Nothing
  2365 
  2365 
       
  2366 typed_op0 :: Name -> (Typ -> Term, Term -> Maybe Typ)
       
  2367 typed_op0 name = (mk, dest)
       
  2368   where
       
  2369     mk ty = Const (name, [ty])
       
  2370     dest (Const (c, [ty])) | c == name = Just ty
       
  2371     dest _ = Nothing
       
  2372 
  2366 typed_op1 :: Name -> (Typ -> Term -> Term, Term -> Maybe (Typ, Term))
  2373 typed_op1 :: Name -> (Typ -> Term -> Term, Term -> Maybe (Typ, Term))
  2367 typed_op1 name = (mk, dest)
  2374 typed_op1 name = (mk, dest)
  2368   where
  2375   where
  2369     mk ty t = App (Const (name, [ty]), t)
  2376     mk ty t = App (Const (name, [ty]), t)
  2370     dest (App (Const (c, [ty]), t)) | c == name = Just (ty, t)
  2377     dest (App (Const (c, [ty]), t)) | c == name = Just (ty, t)
  2477   mk_setT, dest_setT, mk_mem, dest_mem,
  2484   mk_setT, dest_setT, mk_mem, dest_mem,
  2478   mk_eq, dest_eq, true, is_true, false, is_false,
  2485   mk_eq, dest_eq, true, is_true, false, is_false,
  2479   mk_not, dest_not, mk_conj, dest_conj, mk_disj, dest_disj,
  2486   mk_not, dest_not, mk_conj, dest_conj, mk_disj, dest_disj,
  2480   mk_imp, dest_imp, mk_iff, dest_iff,
  2487   mk_imp, dest_imp, mk_iff, dest_iff,
  2481   mk_all_op, dest_all_op, mk_ex_op, dest_ex_op,
  2488   mk_all_op, dest_all_op, mk_ex_op, dest_ex_op,
  2482   mk_all, dest_all, mk_ex, dest_ex
  2489   mk_all, dest_all, mk_ex, dest_ex,
       
  2490   mk_undefined, dest_undefined
  2483 )
  2491 )
  2484 where
  2492 where
  2485 
  2493 
  2486 import qualified Isabelle.Name as Name
  2494 import qualified Isabelle.Name as Name
  2487 import Isabelle.Term
  2495 import Isabelle.Term
  2538 mk_all :: Free -> Term -> Term; dest_all :: Name.Context -> Term -> Maybe (Free, Term)
  2546 mk_all :: Free -> Term -> Term; dest_all :: Name.Context -> Term -> Maybe (Free, Term)
  2539 (mk_all, dest_all) = binder \<open>\<^const_name>\<open>All\<close>\<close>
  2547 (mk_all, dest_all) = binder \<open>\<^const_name>\<open>All\<close>\<close>
  2540 
  2548 
  2541 mk_ex :: Free -> Term -> Term; dest_ex :: Name.Context -> Term -> Maybe (Free, Term)
  2549 mk_ex :: Free -> Term -> Term; dest_ex :: Name.Context -> Term -> Maybe (Free, Term)
  2542 (mk_ex, dest_ex) = binder \<open>\<^const_name>\<open>Ex\<close>\<close>
  2550 (mk_ex, dest_ex) = binder \<open>\<^const_name>\<open>Ex\<close>\<close>
       
  2551 
       
  2552 mk_undefined :: Typ -> Term; dest_undefined :: Term -> Maybe Typ
       
  2553 (mk_undefined, dest_undefined) = typed_op0 \<open>\<^const_name>\<open>undefined\<close>\<close>
  2543 \<close>
  2554 \<close>
  2544 
  2555 
  2545 generate_file "Isabelle/Term_XML/Encode.hs" = \<open>
  2556 generate_file "Isabelle/Term_XML/Encode.hs" = \<open>
  2546 {-  Title:      Isabelle/Term_XML/Encode.hs
  2557 {-  Title:      Isabelle/Term_XML/Encode.hs
  2547     Author:     Makarius
  2558     Author:     Makarius