Theory Ctr_Sugar

(*  Title:      HOL/Ctr_Sugar.thy
    Author:     Jasmin Blanchette, TU Muenchen
    Author:     Dmitriy Traytel, TU Muenchen
    Copyright   2012, 2013

Wrapping existing freely generated type's constructors.
*)

section Wrapping Existing Freely Generated Type's Constructors

theory Ctr_Sugar
imports HOL
keywords
  "print_case_translations" :: diag and
  "free_constructors" :: thy_goal
begin

consts
  case_guard :: "bool  'a  ('a  'b)  'b"
  case_nil :: "'a  'b"
  case_cons :: "('a  'b)  ('a  'b)  'a  'b"
  case_elem :: "'a  'b  'a  'b"
  case_abs :: "('c  'b)  'b"

declare [[coercion_args case_guard - + -]]
declare [[coercion_args case_cons - -]]
declare [[coercion_args case_abs -]]
declare [[coercion_args case_elem - +]]

ML_file Tools/Ctr_Sugar/case_translation.ML

lemma iffI_np: "x  ¬ y; ¬ x  y  ¬ x  y"
  by (erule iffI) (erule contrapos_pn)

lemma iff_contradict:
  "¬ P  P  Q  Q  R"
  "¬ Q  P  Q  P  R"
  by blast+

ML_file Tools/Ctr_Sugar/ctr_sugar_util.ML
ML_file Tools/Ctr_Sugar/ctr_sugar_tactics.ML
ML_file Tools/Ctr_Sugar/ctr_sugar_code.ML
ML_file Tools/Ctr_Sugar/ctr_sugar.ML

text Coinduction method that avoids some boilerplate compared with coinduct.

ML_file Tools/coinduction.ML

end