src/HOL/Codatatype/Examples/TreeFsetI.thy
author blanchet
Fri, 21 Sep 2012 15:53:29 +0200
changeset 49508 1e205327f059
parent 49463 83ac281bcdc2
child 49509 163914705f8d
permissions -rw-r--r--
adapted examples to renamings
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49463
83ac281bcdc2 provide predicator, define relator
blanchet
parents: 49369
diff changeset
     1
(*  Title:      HOL/Codatatype/Examples/TreeFsetI.thy
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     2
    Author:     Dmitriy Traytel, TU Muenchen
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     3
    Author:     Andrei Popescu, TU Muenchen
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     4
    Copyright   2012
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     5
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     6
Finitely branching possibly infinite trees, with sets of children.
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     7
*)
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     8
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     9
header {* Finitely Branching Possibly Infinite Trees, with Sets of Children *}
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    10
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    11
theory TreeFsetI
48980
debfa361f648 fixed import paths in examples
blanchet
parents: 48975
diff changeset
    12
imports "../Codatatype"
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    13
begin
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    14
49092
5eddc9aaebf1 hide newly introduced constant Sublist.sub to allow for name sub in TreeFsetI
Christian Sternagel
parents: 48980
diff changeset
    15
hide_const (open) Sublist.sub
49508
1e205327f059 adapted examples to renamings
blanchet
parents: 49463
diff changeset
    16
hide_fact (open) Quotient_Product.prod_rel_def
49092
5eddc9aaebf1 hide newly introduced constant Sublist.sub to allow for name sub in TreeFsetI
Christian Sternagel
parents: 48980
diff changeset
    17
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    18
definition pair_fun (infixr "\<odot>" 50) where
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    19
  "f \<odot> g \<equiv> \<lambda>x. (f x, g x)"
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    20
49074
d8af889dcbe3 renamed three BNF/(co)datatype-related commands
blanchet
parents: 48980
diff changeset
    21
codata_raw treeFsetI: 't = "'a \<times> 't fset"
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    22
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    23
(* selectors for trees *)
49508
1e205327f059 adapted examples to renamings
blanchet
parents: 49463
diff changeset
    24
definition "lab t \<equiv> fst (treeFsetI_dtor t)"
1e205327f059 adapted examples to renamings
blanchet
parents: 49463
diff changeset
    25
definition "sub t \<equiv> snd (treeFsetI_dtor t)"
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    26
49508
1e205327f059 adapted examples to renamings
blanchet
parents: 49463
diff changeset
    27
lemma dtor[simp]: "treeFsetI_dtor t = (lab t, sub t)"
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    28
unfolding lab_def sub_def by simp
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    29
49508
1e205327f059 adapted examples to renamings
blanchet
parents: 49463
diff changeset
    30
lemma unfold_pair_fun_lab: "lab (treeFsetI_dtor_unfold (f \<odot> g) t) = f t"
1e205327f059 adapted examples to renamings
blanchet
parents: 49463
diff changeset
    31
unfolding lab_def pair_fun_def treeFsetI.dtor_unfolds pre_treeFsetI_map_def by simp
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    32
49508
1e205327f059 adapted examples to renamings
blanchet
parents: 49463
diff changeset
    33
lemma unfold_pair_fun_sub: "sub (treeFsetI_dtor_unfold (f \<odot> g) t) = map_fset (treeFsetI_dtor_unfold (f \<odot> g)) (g t)"
1e205327f059 adapted examples to renamings
blanchet
parents: 49463
diff changeset
    34
unfolding sub_def pair_fun_def treeFsetI.dtor_unfolds pre_treeFsetI_map_def by simp
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    35
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    36
(* tree map (contrived example): *)
49508
1e205327f059 adapted examples to renamings
blanchet
parents: 49463
diff changeset
    37
definition "tmap f \<equiv> treeFsetI_dtor_unfold (f o lab \<odot> sub)"
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    38
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    39
lemma tmap_simps1[simp]: "lab (tmap f t) = f (lab t)"
49508
1e205327f059 adapted examples to renamings
blanchet
parents: 49463
diff changeset
    40
unfolding tmap_def by (simp add: unfold_pair_fun_lab)
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    41
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    42
lemma trev_simps2[simp]: "sub (tmap f t) = map_fset (tmap f) (sub t)"
49508
1e205327f059 adapted examples to renamings
blanchet
parents: 49463
diff changeset
    43
unfolding tmap_def by (simp add: unfold_pair_fun_sub)
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    44
49508
1e205327f059 adapted examples to renamings
blanchet
parents: 49463
diff changeset
    45
lemma pre_treeFsetI_rel[simp]: "pre_treeFsetI_rel R1 R2 a b = (R1 (fst a) (fst b) \<and>
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    46
  (\<forall>t \<in> fset (snd a). (\<exists>u \<in> fset (snd b). R2 t u)) \<and>
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    47
  (\<forall>t \<in> fset (snd b). (\<exists>u \<in> fset (snd a). R2 u t)))"
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    48
apply (cases a)
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    49
apply (cases b)
49508
1e205327f059 adapted examples to renamings
blanchet
parents: 49463
diff changeset
    50
apply (simp add: pre_treeFsetI_rel_def prod_rel_def fset_rel_def)
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    51
done
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    52
49508
1e205327f059 adapted examples to renamings
blanchet
parents: 49463
diff changeset
    53
lemmas treeFsetI_coind = mp[OF treeFsetI.rel_coinduct]
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    54
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    55
lemma "tmap (f o g) x = tmap f (tmap g x)"
49369
d9800bc28427 compile
blanchet
parents: 49222
diff changeset
    56
by (intro treeFsetI_coind[where P="%x1 x2. \<exists>x. x1 = tmap (f o g) x \<and> x2 = tmap f (tmap g x)"])
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    57
   force+
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    58
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    59
end