src/HOL/Ctr_Sugar.thy
author wenzelm
Wed Nov 01 20:46:23 2017 +0100 (22 months ago)
changeset 66983 df83b66f1d94
parent 64430 1d85ac286c72
child 69605 a96320074298
permissions -rw-r--r--
proper merge (amending fb46c031c841);
     1 (*  Title:      HOL/Ctr_Sugar.thy
     2     Author:     Jasmin Blanchette, TU Muenchen
     3     Author:     Dmitriy Traytel, TU Muenchen
     4     Copyright   2012, 2013
     5 
     6 Wrapping existing freely generated type's constructors.
     7 *)
     8 
     9 section \<open>Wrapping Existing Freely Generated Type's Constructors\<close>
    10 
    11 theory Ctr_Sugar
    12 imports HOL
    13 keywords
    14   "print_case_translations" :: diag and
    15   "free_constructors" :: thy_goal
    16 begin
    17 
    18 consts
    19   case_guard :: "bool \<Rightarrow> 'a \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b"
    20   case_nil :: "'a \<Rightarrow> 'b"
    21   case_cons :: "('a \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b"
    22   case_elem :: "'a \<Rightarrow> 'b \<Rightarrow> 'a \<Rightarrow> 'b"
    23   case_abs :: "('c \<Rightarrow> 'b) \<Rightarrow> 'b"
    24 
    25 declare [[coercion_args case_guard - + -]]
    26 declare [[coercion_args case_cons - -]]
    27 declare [[coercion_args case_abs -]]
    28 declare [[coercion_args case_elem - +]]
    29 
    30 ML_file "Tools/Ctr_Sugar/case_translation.ML"
    31 
    32 lemma iffI_np: "\<lbrakk>x \<Longrightarrow> \<not> y; \<not> x \<Longrightarrow> y\<rbrakk> \<Longrightarrow> \<not> x \<longleftrightarrow> y"
    33   by (erule iffI) (erule contrapos_pn)
    34 
    35 lemma iff_contradict:
    36   "\<not> P \<Longrightarrow> P \<longleftrightarrow> Q \<Longrightarrow> Q \<Longrightarrow> R"
    37   "\<not> Q \<Longrightarrow> P \<longleftrightarrow> Q \<Longrightarrow> P \<Longrightarrow> R"
    38   by blast+
    39 
    40 ML_file "Tools/Ctr_Sugar/ctr_sugar_util.ML"
    41 ML_file "Tools/Ctr_Sugar/ctr_sugar_tactics.ML"
    42 ML_file "Tools/Ctr_Sugar/ctr_sugar_code.ML"
    43 ML_file "Tools/Ctr_Sugar/ctr_sugar.ML"
    44 
    45 text \<open>Coinduction method that avoids some boilerplate compared with coinduct.\<close>
    46 
    47 ML_file "Tools/coinduction.ML"
    48 
    49 end