Precedence_ord.thy
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Fri, 29 Jan 2016 17:06:02 +0000
changeset 97 c7ba70dc49bd
parent 63 b620a2a0806a
child 197 ca4ddf26a7c7
permissions -rw-r--r--
merged

header {* Order on product types *}

theory Precedence_ord
imports Main
begin

datatype precedence = Prc nat nat

instantiation precedence :: order
begin

definition
  precedence_le_def: "x \<le> y \<longleftrightarrow> (case (x, y) of
                                   (Prc fx sx, Prc fy sy) \<Rightarrow> 
                                 fx < fy \<or> (fx \<le> fy \<and> sy \<le> sx))"

lemma preced_leI1[intro]: 
  assumes "fx < fy"
  shows "Prc fx sx \<le> Prc fy sy"
  using assms
  by (simp add: precedence_le_def) 

lemma preced_leI2[intro]: 
  assumes "fx \<le> fy"
  and "sy \<le> sx"
  shows "Prc fx sx \<le> Prc fy sy"
  using assms
  by (simp add: precedence_le_def) 

definition
  precedence_less_def: "x < y \<longleftrightarrow> (case (x, y) of
                               (Prc fx sx, Prc fy sy) \<Rightarrow> 
                                     fx < fy \<or> (fx \<le> fy \<and> sy < sx))"

instance
proof
qed (auto simp: precedence_le_def precedence_less_def 
              intro: order_trans split:precedence.splits)
end

instance precedence :: preorder ..

instance precedence :: linorder 
proof
qed (auto simp: precedence_le_def precedence_less_def 
              intro: order_trans split:precedence.splits)

instantiation precedence :: zero
begin

definition Zero_precedence_def:
  "0 = Prc 0 0"

instance ..

end

end