thys2/ClosedForms.thy
author Chengsong
Tue, 15 Mar 2022 16:37:41 +0000
changeset 451 7a016eeb118d
parent 445 e072cfc2f2ee
child 453 d68b9db4c9ec
permissions -rw-r--r--
finiteness
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
444
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
     1
theory ClosedForms imports
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
     2
"BasicIdentities"
443
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
     3
begin
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
     4
451
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
     5
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
     6
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
     7
lemma simp_rdistinct_f: shows 
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
     8
"f ` rset = frset \<Longrightarrow> rsimp (rsimp_ALTs (map f (rdistinct rs rset))) = rsimp (rsimp_ALTs (rdistinct (map f rs) frset))  "
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
     9
  apply(induct rs arbitrary: rset)
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    10
   apply simp
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    11
   apply(case_tac "a \<in> rset")
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    12
  apply(case_tac " f a \<in> frset")
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    13
   apply simp
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    14
   apply blast
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    15
  apply(subgoal_tac "f a \<notin> frset")
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    16
   apply(simp)
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    17
   apply(subgoal_tac "f ` (insert a rset) = insert (f a) frset")
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    18
  prefer 2
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    19
  apply (meson image_insert)
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    20
  
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    21
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    22
  
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    23
  sorry
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    24
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    25
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    26
lemma distinct_der:
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    27
  shows "rsimp (rsimp_ALTs (map (rder x) (rdistinct rs {}))) = rsimp ( rsimp_ALTs (rdistinct (map (rder x) rs) {}))"
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    28
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    29
  sorry
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    30
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    31
444
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    32
lemma alts_closed_form: shows 
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    33
"rsimp (rders_simp (RALTS rs) s) = 
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    34
rsimp (RALTS (map (\<lambda>r. rders_simp r s) rs))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    35
  apply(induct s rule: rev_induct)
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    36
   apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    37
  apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    38
  apply(subst rders_simp_append)
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    39
  apply(subgoal_tac " rsimp (rders_simp (rders_simp (RALTS rs) xs) [x]) = 
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    40
 rsimp(rders_simp (rsimp_ALTs (rdistinct (rflts (map (rsimp \<circ> (\<lambda>r. rders_simp r xs)) rs)) {})) [x])")
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    41
   prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    42
  apply (metis inside_simp_removal rders_simp_one_char)
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    43
  apply(simp only: )
451
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    44
  apply(subst rders_simp_one_char)
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    45
  apply(subst rsimp_idem)
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    46
  apply(subgoal_tac "rsimp (rder x (rsimp_ALTs (rdistinct (rflts (map (rsimp \<circ> (\<lambda>r. rders_simp r xs)) rs)) {}))) =
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    47
                     rsimp ((rsimp_ALTs (map (rder x) (rdistinct (rflts (map (rsimp \<circ> (\<lambda>r. rders_simp r xs)) rs)) {})))) ")
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    48
  prefer 2
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    49
  using rder_rsimp_ALTs_commute apply presburger
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    50
  apply(simp only:)
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    51
  apply(subgoal_tac "rsimp (rsimp_ALTs (map (rder x) (rdistinct (rflts (map (rsimp \<circ> (\<lambda>r. rders_simp r xs)) rs)) {})))
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    52
= rsimp (rsimp_ALTs (rdistinct (map (rder x) (rflts (map (rsimp \<circ> (\<lambda>r. rders_simp r xs)) rs))) {}))")
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    53
   prefer 2
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    54
  
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    55
  using distinct_der apply presburger
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    56
  apply(simp only:)
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
    57
444
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    58
  sorry
443
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    59
444
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    60
lemma alts_closed_form_variant: shows 
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    61
"s \<noteq> [] \<Longrightarrow> rders_simp (RALTS rs) s = 
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    62
rsimp (RALTS (map (\<lambda>r. rders_simp r s) rs))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    63
  sorry
443
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    64
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    65
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    66
444
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    67
lemma star_closed_form:
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    68
  shows "rders_simp (RSTAR r0) (c#s) = 
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    69
rsimp ( RALTS ( (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0) ) (star_updates s r0 [[c]]) ) ))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    70
  apply(induct s)
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    71
   apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    72
  sorry
443
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    73
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    74
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    75
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    76
lemma seq_closed_form: shows 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    77
"rsimp (rders_simp (RSEQ r1 r2) s) = 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    78
rsimp ( RALTS ( (RSEQ (rders_simp r1 s) r2) # 
445
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
    79
                (map (rders_simp r2) (vsuf s r1)) 
443
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    80
              )  
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    81
      )"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    82
  apply(induct s)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    83
  apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    84
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    85
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    86
444
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    87
lemma seq_closed_form_variant: shows
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    88
"s \<noteq> [] \<Longrightarrow> (rders_simp (RSEQ r1 r2) s) = 
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
    89
rsimp (RALTS ((RSEQ (rders_simp r1 s) r2) # (map (rders_simp r2) (vsuf s r1))))"
445
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
    90
  apply(induct s rule: rev_induct)
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
    91
   apply simp
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
    92
  apply(subst rders_simp_append)
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
    93
  apply(subst rders_simp_one_char)
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
    94
  apply(subst rsimp_idem[symmetric])
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
    95
  apply(subst rders_simp_one_char[symmetric])
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
    96
  apply(subst rders_simp_append[symmetric])
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
    97
  apply(insert seq_closed_form)
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
    98
  apply(subgoal_tac "rsimp (rders_simp (RSEQ r1 r2) (xs @ [x]))
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
    99
 = rsimp (RALTS (RSEQ (rders_simp r1 (xs @ [x])) r2 # map (rders_simp r2) (vsuf (xs @ [x]) r1)))")
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   100
   apply force
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
   101
  by presburger
443
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   102
444
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
   103
end