diff -r 48ce16d61e03 -r 61eff2abb0b6 thys2/SizeBoundStrong.thy --- a/thys2/SizeBoundStrong.thy Sat Apr 16 09:52:57 2022 +0100 +++ b/thys2/SizeBoundStrong.thy Tue Apr 19 09:08:01 2022 +0100 @@ -502,6 +502,31 @@ decode (retrieve (bders (intern r) (s @ [c])) v) r" by (simp add: bders_append) qed +corollary main_decode1_horribly_wrong: + assumes "\ v : ders s r" + shows "Some(v) = decode (retrieve (bders (intern r) s) v) r" + using assms +proof (induct s arbitrary: v rule: rev_induct) + case Nil + have "\ v : ders [] r" by fact + then have "\ v: r" by simp + then have "Some v = decode (retrieve (intern r) v) r" + using decode_code retrieve_code by force + then show "Some (v) = decode (retrieve (bders (intern r) []) v) r" + by simp +next + case (snoc c s v) + have IH: "\v. \ v : ders s r \ + Some ( v) = decode (retrieve (bders (intern r) s) v ) r" by fact + have asm: "\ v: ders (s @ [c]) r" by fact + then have asm2: "\ injval (ders s r) c v : ders s r" + using Prf_injval ders_snoc by force + then have injv: "Some (injval (ders s r) c v) = +decode (retrieve (bders (intern r) s) (injval (ders s r) c v)) r" + by (simp add: IH asm2) + oops + + definition blex where "blex a s \ if bnullable (bders a s) then Some (bmkeps (bders a s)) else None" @@ -592,17 +617,17 @@ | \collect erasedR2 (r # rs) = collect erasedR2 rs\ -fun pruneRexp where +fun pruneRexp :: "arexp \ rexp list \ arexp" + where "pruneRexp (ASEQ bs r1 r2) allowableTerms = (let termsTruncated = (collect (erase r2) allowableTerms) in (let pruned = pruneRexp r1 termsTruncated in - (bsimp_ASEQ1 bs pruned r2)))" + (bsimp_ASEQ bs pruned r2)))" | \pruneRexp (AALTs bs rs) allowableTerms = (let rsp = (filter (\r. r \ AZERO) (map (\r. pruneRexp r allowableTerms) rs) ) in bsimp_AALTs bs rsp ) \ | \pruneRexp r allowableTerms = (if (erase r) \ (set allowableTerms) then r else AZERO)\ - fun oneSimp :: \rexp \ rexp\ where \ oneSimp (SEQ ONE r) = r \ | \ oneSimp (SEQ r1 r2) = SEQ (oneSimp r1) r2 \ @@ -617,14 +642,16 @@ where \addToAcc r acc = filter (\r1. oneSimp r1 \ set acc) (breakIntoTerms (erase r)) \ + +(*newSubRexps: terms that are new--have not existed in acc before*) fun dBStrong :: "arexp list \ rexp list \ arexp list" where -"dBStrong [] acc = []" + "dBStrong [] acc = []" | "dBStrong (r # rs) acc = (if (erase r) \ (set acc) then dBStrong rs acc else let newSubRexps = (addToAcc r acc) in (case (pruneRexp r newSubRexps) of - AZERO \ dBStrong rs (newSubRexps @ acc) | - r1 \ r1 # (dBStrong rs (newSubRexps @ acc)) + AZERO \ dBStrong rs (map oneSimp newSubRexps @ acc) | + r1 \ r1 # (dBStrong rs (map oneSimp newSubRexps @ acc)) ) ) "