# HG changeset patch # User haftmann # Date 1204904817 -3600 # Node ID b7d8c2338585a245f559624acfcd125ae5e6dc0d # Parent cc630a75b62a3dcb1d6efd261f30c428cda49f30 added Option_ord.thy diff -r cc630a75b62a -r b7d8c2338585 src/HOL/Library/Option_ord.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/HOL/Library/Option_ord.thy Fri Mar 07 16:46:57 2008 +0100 @@ -0,0 +1,59 @@ +(* Title: HOL/Library/Option_ord.thy + ID: $Id$ + Author: Florian Haftmann, TU Muenchen +*) + +header {* Canonical order on option type *} + +theory Option_ord +imports ATP_Linkup +begin + +instantiation option :: (order) order +begin + +definition less_eq_option where + [code func del]: "x \ y \ (case x of None \ True | Some x \ (case y of None \ False | Some y \ x \ y))" + +definition less_option where + [code func del]: "x < y \ (case y of None \ False | Some y \ (case x of None \ True | Some x \ x < y))" + +lemma less_eq_option_None [simp]: "None \ (x\'a option)" + by (simp add: less_eq_option_def) + +lemma less_eq_option_None_code [code]: "None \ (x\'a option) \ True" + by simp + +lemma less_eq_option_None_is_None: "(x\'a option) \ None \ x = None" + by (cases x) (simp_all add: less_eq_option_def) + +lemma less_eq_option_Some_None [simp, code]: "Some (x\'a) \ None \ False" + by (simp add: less_eq_option_def) + +lemma less_eq_option_Some [simp, code]: "Some (x\'a) \ Some y \ x \ y" + by (simp add: less_eq_option_def) + +lemma less_option_None [simp, code]: "(x\'a option) < None \ False" + by (simp add: less_option_def) + +lemma less_option_None_is_Some: "None < (x\'a option) \ \z. x = Some z" + by (cases x) (simp_all add: less_option_def) + +lemma less_option_None_Some [simp]: "None < Some (x\'a)" + by (simp add: less_option_def) + +lemma less_option_None_Some_code [code]: "None < Some (x\'a) \ True" + by simp + +lemma less_option_Some [simp, code]: "Some (x\'a) < Some y \ x < y" + by (simp add: less_option_def) + +instance by default + (auto simp add: less_eq_option_def less_option_def split: option.splits) + +end + +instance option :: (linorder) linorder + by default (auto simp add: less_eq_option_def less_option_def split: option.splits) + +end