Repository navigation
Expand file tree
/
Copy pathProgramLiterals.lean
More file actions
66 lines (59 loc) · 3.08 KB
/
Copy pathProgramLiterals.lean
File metadata and controls
66 lines (59 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import Verified.ProgramAppend
import Verified.LiteralCoverage
namespace Verified
theorem TailBody.literals_renameFuns {S T : List Sig} (renameFuncs : FunRenaming S T)
(body : TailBody S params result Γ) :
(body.renameFuns renameFuncs).literals = body.literals := by
induction body <;>
simp_all only [TailBody.renameFuns, TailBody.literals_ret, TailBody.literals_next, TailBody.literals_ite, TailBody.literals_letE, TailBody.literals_letPair, TailBody.literals_treeCase,
Expr.literals_renameFuns]
theorem Prog.literals_cast {S T : List Sig} (types : S = T) (prog : Prog S) :
(cast (congrArg Prog types) prog).literals = prog.literals := by
cases types
rfl
theorem Prog.literals_cast_eq {S T : List Sig} (types : S = T)
(transport : Prog S = Prog T) (prog : Prog S) :
(cast transport prog).literals = prog.literals := by
cases types
rfl
theorem Prog.literals_append {S T : List Sig} (source : Prog S) (target : Prog T) :
(source.append target).literals = target.literals ++ source.literals := by
induction source with
| nil => simp only [Prog.append, Prog.literals, List.append_nil]
| @cons S func rest ih =>
let renameFuncs : FunRenaming S (S ++ T) := fun v => v.appendLeft T
have hCast : (Prog.append (.cons func rest) target).literals =
(Prog.cons (func.renameFuns renameFuncs) (rest.append target)).literals :=
Prog.literals_cast_eq
(congrArg (fun g => g :: (S ++ T)) (func.sig_renameFuns renameFuncs)) _ _
have hBody : (func.renameFuns renameFuncs).body.literals = func.body.literals :=
func.body.literals_renameFuns renameFuncs
rw [hCast]
change (rest.append target).literals ++ (func.renameFuns renameFuncs).body.literals = _
rw [ih, hBody]
exact List.append_assoc _ _ _
| @consRec S func rest ih =>
let renameFuncs : FunRenaming S (S ++ T) := fun v => v.appendLeft T
have hBody : (func.renameFuns renameFuncs).body.literals = func.body.literals :=
func.body.literals_renameFuns (renameFuncs.lift func.sig)
change (rest.append target).literals ++ (func.renameFuns renameFuncs).body.literals = _
rw [ih, hBody]
exact List.append_assoc _ _ _
| @consTail S func rest ih =>
let renameFuncs : FunRenaming S (S ++ T) := fun v => v.appendLeft T
have hCast : (Prog.append (.consTail func rest) target).literals =
(Prog.consTail (func.renameFuns renameFuncs) (rest.append target)).literals :=
Prog.literals_cast_eq
(congrArg (fun g => g :: (S ++ T)) (func.sig_renameFuns renameFuncs)) _ _
have hBody : (func.renameFuns renameFuncs).body.literals = func.body.literals :=
func.body.literals_renameFuns renameFuncs
rw [hCast]
change (rest.append target).literals ++ (func.renameFuns renameFuncs).body.literals = _
rw [ih, hBody]
exact List.append_assoc _ _ _
theorem Prog.covered_append {S T : List Sig} (source : Prog S) (target : Prog T)
(pool : Bytes.LiteralPool) :
(source.append target).Covered pool ↔ source.Covered pool ∧ target.Covered pool := by
rw [Prog.Covered, Prog.literals_append, List.append_subset]
exact and_comm
end Verified