Folds.thy
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Fri, 01 Mar 2013 17:28:25 +0000
changeset 376 209fd285c86f
parent 203 5d724fe0e096
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
85
a3e0056c228b separated the definition of folds into a separate file
urbanc
parents:
diff changeset
     1
theory Folds
203
5d724fe0e096 changes according to afp-submission
urbanc
parents: 85
diff changeset
     2
imports "Regular_Exp"
85
a3e0056c228b separated the definition of folds into a separate file
urbanc
parents:
diff changeset
     3
begin
a3e0056c228b separated the definition of folds into a separate file
urbanc
parents:
diff changeset
     4
203
5d724fe0e096 changes according to afp-submission
urbanc
parents: 85
diff changeset
     5
section {* ``Summation'' for regular expressions *}
85
a3e0056c228b separated the definition of folds into a separate file
urbanc
parents:
diff changeset
     6
a3e0056c228b separated the definition of folds into a separate file
urbanc
parents:
diff changeset
     7
text {*
a3e0056c228b separated the definition of folds into a separate file
urbanc
parents:
diff changeset
     8
  To obtain equational system out of finite set of equivalence classes, a fold operation
a3e0056c228b separated the definition of folds into a separate file
urbanc
parents:
diff changeset
     9
  on finite sets @{text "folds"} is defined. The use of @{text "SOME"} makes @{text "folds"}
a3e0056c228b separated the definition of folds into a separate file
urbanc
parents:
diff changeset
    10
  more robust than the @{text "fold"} in the Isabelle library. The expression @{text "folds f"}
a3e0056c228b separated the definition of folds into a separate file
urbanc
parents:
diff changeset
    11
  makes sense when @{text "f"} is not @{text "associative"} and @{text "commutitive"},
a3e0056c228b separated the definition of folds into a separate file
urbanc
parents:
diff changeset
    12
  while @{text "fold f"} does not.  
a3e0056c228b separated the definition of folds into a separate file
urbanc
parents:
diff changeset
    13
*}
a3e0056c228b separated the definition of folds into a separate file
urbanc
parents:
diff changeset
    14
a3e0056c228b separated the definition of folds into a separate file
urbanc
parents:
diff changeset
    15
a3e0056c228b separated the definition of folds into a separate file
urbanc
parents:
diff changeset
    16
definition 
a3e0056c228b separated the definition of folds into a separate file
urbanc
parents:
diff changeset
    17
  folds :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a set \<Rightarrow> 'b"
a3e0056c228b separated the definition of folds into a separate file
urbanc
parents:
diff changeset
    18
where
a3e0056c228b separated the definition of folds into a separate file
urbanc
parents:
diff changeset
    19
  "folds f z S \<equiv> SOME x. fold_graph f z S x"
a3e0056c228b separated the definition of folds into a separate file
urbanc
parents:
diff changeset
    20
203
5d724fe0e096 changes according to afp-submission
urbanc
parents: 85
diff changeset
    21
text {* Plus-combination for a set of regular expressions *}
5d724fe0e096 changes according to afp-submission
urbanc
parents: 85
diff changeset
    22
5d724fe0e096 changes according to afp-submission
urbanc
parents: 85
diff changeset
    23
abbreviation
5d724fe0e096 changes according to afp-submission
urbanc
parents: 85
diff changeset
    24
  Setalt :: "'a rexp set \<Rightarrow> 'a rexp" ("\<Uplus>_" [1000] 999) 
5d724fe0e096 changes according to afp-submission
urbanc
parents: 85
diff changeset
    25
where
5d724fe0e096 changes according to afp-submission
urbanc
parents: 85
diff changeset
    26
  "\<Uplus>A \<equiv> folds Plus Zero A"
5d724fe0e096 changes according to afp-submission
urbanc
parents: 85
diff changeset
    27
5d724fe0e096 changes according to afp-submission
urbanc
parents: 85
diff changeset
    28
text {* 
5d724fe0e096 changes according to afp-submission
urbanc
parents: 85
diff changeset
    29
  For finite sets, @{term Setalt} is preserved under @{term lang}.
5d724fe0e096 changes according to afp-submission
urbanc
parents: 85
diff changeset
    30
*}
5d724fe0e096 changes according to afp-submission
urbanc
parents: 85
diff changeset
    31
5d724fe0e096 changes according to afp-submission
urbanc
parents: 85
diff changeset
    32
lemma folds_plus_simp [simp]:
5d724fe0e096 changes according to afp-submission
urbanc
parents: 85
diff changeset
    33
  fixes rs::"('a rexp) set"
5d724fe0e096 changes according to afp-submission
urbanc
parents: 85
diff changeset
    34
  assumes a: "finite rs"
5d724fe0e096 changes according to afp-submission
urbanc
parents: 85
diff changeset
    35
  shows "lang (\<Uplus>rs) = \<Union> (lang ` rs)"
5d724fe0e096 changes according to afp-submission
urbanc
parents: 85
diff changeset
    36
unfolding folds_def
5d724fe0e096 changes according to afp-submission
urbanc
parents: 85
diff changeset
    37
apply(rule set_eqI)
5d724fe0e096 changes according to afp-submission
urbanc
parents: 85
diff changeset
    38
apply(rule someI2_ex)
5d724fe0e096 changes according to afp-submission
urbanc
parents: 85
diff changeset
    39
apply(rule_tac finite_imp_fold_graph[OF a])
5d724fe0e096 changes according to afp-submission
urbanc
parents: 85
diff changeset
    40
apply(erule fold_graph.induct)
5d724fe0e096 changes according to afp-submission
urbanc
parents: 85
diff changeset
    41
apply(auto)
5d724fe0e096 changes according to afp-submission
urbanc
parents: 85
diff changeset
    42
done
85
a3e0056c228b separated the definition of folds into a separate file
urbanc
parents:
diff changeset
    43
a3e0056c228b separated the definition of folds into a separate file
urbanc
parents:
diff changeset
    44
end