* `isEncap_same`, `isEncap_other`: the type predicate answers `#t` for an object of its own type and
open Term
(he : Env.lookup se e = some (encapA k)) (hd : Env.lookup sd e = some (decapA k))
refine Steps.head (.evalPair _ _ _) ?_
refine Steps.trans (Steps.combOp _ _ (.evalSym hd)) ?_
refine Steps.head (.combApp _ _ (by repeat constructor)) ?_
refine Steps.head (.evalPair _ _ _) ?_
refine Steps.trans (Steps.combOp _ _ (.evalSym he)) ?_
refine Steps.head (.combApp _ _ (by repeat constructor)) ?_
refine Steps.trans (Steps.comb _ (Steps.refl _) (Steps.pair hc (Steps.refl _))) ?_
exact Steps.top (.deltaEncap k _ hv)
refine Steps.trans (Steps.comb _ (Steps.refl _) (Steps.pair hin (Steps.refl _))) ?_
exact Steps.top (.deltaDecap k _)
have hk : isCapsuleOf k (capsule k v) = true := by
simp only [isCapsuleOf]; exact decide_eq_true rfl
have h := Top.deltaIsEncap (b := true) k e (.pair (.capsule k v) .nil)
(by simp only [capsCheck, hk, Bool.and_self, Option.map_some])
exact Steps.top h
have h := Top.deltaIsEncap (b := false) k e (.pair (.capsule k' v) .nil)
(by simp [capsCheck, isCapsuleOf, hk])
exact Steps.top h
| dat (n : Nat) : Clean k (dat n)
| sym (s : Nat) : Clean k (sym s)
| ign : Clean k ign
| nil : Clean k nil
| envNil : Clean k (env [])
| envCons (s : Nat) {t : Term} {r : Env} : Clean k t -> Clean k (env r) -> Clean k (env ((s, t) :: r))
| oper {a b c d : Term} : Clean k a -> Clean k b -> Clean k c -> Clean k d -> Clean k (oper a b c d)
| dat (n : Nat) : CSim k (dat n) (dat n)
| sym (s : Nat) : CSim k (sym s) (sym s)
| ign : CSim k ign ign
| nil : CSim k nil nil
| envNil : CSim k (env []) (env [])
| oper {a a' b b' c c' d d' : Term} :
CSim k a a' -> CSim k b b' -> CSim k c c' -> CSim k d d' -> CSim k (oper a b c d) (oper a' b' c' d')
| comb {a a' b b' c c' : Term} :
namespace CSim
| .env bs => reflEnv bs
| .app t => .app (refl t)
| .capsule k' v => .capsule k' (refl v)
theorem selfEval {k : Nat} {t t' : Term} (h : CSim k t t') (hs : SelfEval t) : SelfEval t' := by¶ node
theorem isList {k : Nat} {ts ts' : Term} (h : CSim k ts ts') (hl : IsList ts) : IsList ts' := by¶ node
(hl : IsList ts) : CSim k (VauE.evalList e ts) (VauE.evalList e' ts') := by
(Env.lookup s bs = none -> Env.lookup s bs' = none) /\
(forall u, Env.lookup s bs = some u -> exists u', Env.lookup s bs' = some u' /\ CSim k u u') := by
exact And.intro (fun _ => rfl) (fun u hu => by simp [Env.lookup] at hu)
simp only [Env.lookup]
CSim k p p' -> CSim k t t' -> exists m', VauE.ematch p' t' = some m' /\ CSim k (.env m) (.env m')
simp only [VauE.ematch] at hm; cases hm
cases t <;> simp [VauE.ematch] at hm
simp only [VauE.ematch] at hm; cases hm
simp only [VauE.ematch] at hm
Exists.intro (Env.join m1' m2') (And.intro
(by simp only [VauE.ematch, hsa, hsb, hdis, if_true, h1'.1, h2'.1])
(join h1'.2 h2'.2))
| _ => simp [VauE.ematch] at hm
| .dat _, _, _, _, _, hm, _, _ => by simp [VauE.ematch] at hm
| .prim _, _, _, _, _, hm, _, _ => by simp [VauE.ematch] at hm
| .env _, _, _, _, _, hm, _, _ => by simp [VauE.ematch] at hm
| .oper _ _ _ _, _, _, _, _, hm, _, _ => by simp [VauE.ematch] at hm
| .app _, _, _, _, _, hm, _, _ => by simp [VauE.ematch] at hm
| .eval _ _, _, _, _, _, hm, _, _ => by simp [VauE.ematch] at hm
| .comb _ _ _, _, _, _, _, hm, _, _ => by simp [VauE.ematch] at hm
| .capsule _ _, _, _, _, _, hm, _, _ => by simp [VauE.ematch] at hm
CSim k x x' -> exists r', VauE.buildListStar x' = some r' /\ CSim k r r'
simp only [VauE.buildListStar] at hb; cases hb
simp only [VauE.buildListStar, Option.map_eq_some_iff] at hb
(buildListStar hr0.1 (.pair hc hd)).elim fun r1 hr1 => by
. simp only [VauE.buildListStar, hr1.1, Option.map_some]
| _ => simp [VauE.buildListStar] at hb
| .dat _, _, _, hb, _ => by simp [VauE.buildListStar] at hb
| .prim _, _, _, hb, _ => by simp [VauE.buildListStar] at hb
| .sym _, _, _, hb, _ => by simp [VauE.buildListStar] at hb
| .ign, _, _, hb, _ => by simp [VauE.buildListStar] at hb
| .nil, _, _, hb, _ => by simp [VauE.buildListStar] at hb
| .env _, _, _, hb, _ => by simp [VauE.buildListStar] at hb
| .oper _ _ _ _, _, _, hb, _ => by simp [VauE.buildListStar] at hb
| .app _, _, _, hb, _ => by simp [VauE.buildListStar] at hb
| .eval _ _, _, _, hb, _ => by simp [VauE.buildListStar] at hb
| .comb _ _ _, _, _, hb, _ => by simp [VauE.buildListStar] at hb
| .capsule _ _, _, _, hb, _ => by simp [VauE.buildListStar] at hb
isCapsuleOf j x' = isCapsuleOf j x := by
theorem capsCheck {k j : Nat} : forall {vs vs' : Term} {b : Bool}, VauE.capsCheck j vs = some b ->¶ node
CSim k vs vs' -> VauE.capsCheck j vs' = some b
simp only [VauE.capsCheck, Option.map_eq_some_iff] at hc
simp only [VauE.capsCheck, capsCheck hb0.1 h2, Option.map_some, isCapsuleOf_eq h1]
| .dat _, _, _, hc, _ => by simp [VauE.capsCheck] at hc
| .prim _, _, _, hc, _ => by simp [VauE.capsCheck] at hc
| .sym _, _, _, hc, _ => by simp [VauE.capsCheck] at hc
| .ign, _, _, hc, _ => by simp [VauE.capsCheck] at hc
| .env _, _, _, hc, _ => by simp [VauE.capsCheck] at hc
| .oper _ _ _ _, _, _, hc, _ => by simp [VauE.capsCheck] at hc
| .app _, _, _, hc, _ => by simp [VauE.capsCheck] at hc
| .eval _ _, _, _, hc, _ => by simp [VauE.capsCheck] at hc
| .comb _ _ _, _, _, hc, _ => by simp [VauE.capsCheck] at hc
| .capsule _ _, _, _, hc, _ => by simp [VauE.capsCheck] at hc
end CSim
namespace Clean
(hl : Env.lookup s bs = some u) : Clean k u := by
| nil => simp [Env.lookup] at hl
simp only [Env.lookup] at hl
theorem ematch {k : Nat} : forall {p t : Term} {m : Env}, VauE.ematch p t = some m -> Clean k t ->¶ node
Clean k (.env m)
| .ign, _, _, hm, _ => by simp only [VauE.ematch] at hm; cases hm; exact .envNil
| .nil, t, _, hm, _ => by cases t <;> simp [VauE.ematch] at hm; cases hm; exact .envNil
| .sym s, _, _, hm, ht => by simp only [VauE.ematch] at hm; cases hm; exact .envCons s ht .envNil
simp only [VauE.ematch] at hm
| _ => simp [VauE.ematch] at hm
| .dat _, _, _, hm, _ => by simp [VauE.ematch] at hm
| .prim _, _, _, hm, _ => by simp [VauE.ematch] at hm
| .env _, _, _, hm, _ => by simp [VauE.ematch] at hm
| .oper _ _ _ _, _, _, hm, _ => by simp [VauE.ematch] at hm
| .app _, _, _, hm, _ => by simp [VauE.ematch] at hm
| .eval _ _, _, _, hm, _ => by simp [VauE.ematch] at hm
| .comb _ _ _, _, _, hm, _ => by simp [VauE.ematch] at hm
| .capsule _ _, _, _, hm, _ => by simp [VauE.ematch] at hm
Clean k (VauE.evalList e ts) := by
| nil => simp only [VauE.buildListStar] at hb; cases hb; exact ha
simp only [VauE.buildListStar, Option.map_eq_some_iff] at hb
rw [<- hr0.2]; exact .pair ha (buildListStar hr0.1 hr)
| _ => simp [VauE.buildListStar] at hb
| .dat _, _, hb, _ => by simp [VauE.buildListStar] at hb
| .prim _, _, hb, _ => by simp [VauE.buildListStar] at hb
| .sym _, _, hb, _ => by simp [VauE.buildListStar] at hb
| .ign, _, hb, _ => by simp [VauE.buildListStar] at hb
| .nil, _, hb, _ => by simp [VauE.buildListStar] at hb
| .env _, _, hb, _ => by simp [VauE.buildListStar] at hb
| .oper _ _ _ _, _, hb, _ => by simp [VauE.buildListStar] at hb
| .app _, _, hb, _ => by simp [VauE.buildListStar] at hb
| .eval _ _, _, hb, _ => by simp [VauE.buildListStar] at hb
| .comb _ _ _, _, hb, _ => by simp [VauE.buildListStar] at hb
| .capsule _ _, _, hb, _ => by simp [VauE.buildListStar] at hb
| evalSym hl => cases hc with | eval _ he => exact lookup he hl
| comb hf hx he => cases hf with | app h1 => exact .comb h1 (evalList he hx hl) he
| deltaListStar e hv hr => cases hc with | comb _ hx _ => exact buildListStar hr hx
| tail _ hs ih => exact step hs ih
| comb _ _ _ iha ihb ihc => cases hc with | comb ha hb hc' => exact .comb (iha ha) (ihb hb) (ihc hc')
end Clean
theorem csim_top {k : Nat} {t u t' : Term} (hc : Clean k t) (hs : CSim k t t') (h : Top t u) :¶ node
exact (CSim.env_inv he).elim fun bs' hb => by
subst hb
exact Exists.intro _ (And.intro (Steps.top (.evalSelf _ (ha.selfEval hse))) ha)
exact (CSim.env_inv he).elim fun bs' hb => by
subst hb
exact ((CSim.lookup he x).2 _ hl).elim fun u' hu' =>
Exists.intro u' (And.intro (Steps.top (.evalSym hu'.1)) hu'.2)
exact (CSim.env_inv he).elim fun bs' hb => by
subst hb
exact Exists.intro _ (And.intro (Steps.top (.evalPair _ _ _)) (.comb (.eval h1 he) h2 he))
exact (CSim.env_inv he).elim fun bs' hb => by
subst hb
exact Exists.intro _ (And.intro (Steps.top (.evalApp _ _)) (.app (.eval h1 he)))
exact (CSim.env_inv h4).elim fun e1' he1 => by
subst he1
exact (CSim.env_inv he).elim fun e2' he2 => by
subst he2
exact (CSim.ematch hm (.pair h1 h2) (.pair hx he)).elim fun m' hm' =>
(Steps.top (.beta (h1.isValue hv1) (h2.isValue hv2) (hx.isValue hv3) hm'.1))
(.eval h3 (CSim.join hm'.2 h4)))
exact (CSim.env_inv he).elim fun bs' hb => by
subst hb
exact Exists.intro _ (And.intro (Steps.top (.combApp _ _ (hx.isList hl)))
(.comb h1 (CSim.evalList he hx hl) he))
exact (CSim.env_inv he).elim fun bs' hb => by
subst hb
(Steps.top (.deltaVau _ (h1.isValue hv1) (h2.isValue hv2) (h3.isValue hv3)))
exact (CSim.env_inv he).elim fun bs' hb => by
subst hb
exact Exists.intro _ (And.intro (Steps.top (.deltaWrap _ (h1.isValue hv))) (.app h1))
exact (CSim.env_inv he).elim fun bs' hb => by
subst hb
exact Exists.intro _ (And.intro (Steps.top (.deltaUnwrap _ (h2.isValue hv))) h2)
exact (CSim.env_inv h2).elim fun e1' he1 => by
subst he1
exact (CSim.env_inv he).elim fun bs' hb => by
subst hb
exact Exists.intro _ (And.intro (Steps.top (.deltaEval _ _ (h1.isValue hv)))
exact (CSim.env_inv he).elim fun bs' hb => by
subst hb
exact (CSim.buildListStar hr hx).elim fun r' hr' =>
Exists.intro r' (And.intro (Steps.top (.deltaListStar _ (hx.isValue hv) hr'.1)) hr'.2)
exact (CSim.env_inv he).elim fun bs' hb => by
subst hb
exact Exists.intro _ (And.intro (Steps.top (.deltaEncap k' _ (h1.isValue hv)))
exact (CSim.env_inv he).elim fun bs' hb => by
subst hb
(Steps.top (.deltaIsEncap k' _ (hx.isValue hv) (CSim.capsCheck hcs hx))) (.dat _))
exact (CSim.env_inv he).elim fun bs' hb => by
subst hb
exact Exists.intro _ (And.intro (Steps.top (.deltaDecap k' _)) h2)
| top h => exact fun t' hc hs => csim_top hc hs h
Exists.intro _ (And.intro (Steps.envCons h1.1 (Steps.refl _)) (.envCons s h1.2 hr))
exact (ih _ hcr hr).elim fun u1 h1 => (CSim.env_inv_right (CSim.symm h1.2)).elim fun l hl => by
subst hl
exact Exists.intro _ (And.intro (Steps.envCons (Steps.refl _) h1.1) (.envCons s ha h1.2))
(And.intro (Steps.oper h1.1 (Steps.refl _) (Steps.refl _) (Steps.refl _)) (.oper h1.2 hb hc' hd))
(And.intro (Steps.oper (Steps.refl _) h1.1 (Steps.refl _) (Steps.refl _)) (.oper ha h1.2 hc' hd))
(And.intro (Steps.oper (Steps.refl _) (Steps.refl _) h1.1 (Steps.refl _)) (.oper ha hb h1.2 hd))
(And.intro (Steps.oper (Steps.refl _) (Steps.refl _) (Steps.refl _) h1.1) (.oper ha hb hc' h1.2))
(And.intro (Steps.pair h1.1 (Steps.refl _)) (.pair h1.2 hb))
(And.intro (Steps.pair (Steps.refl _) h1.1) (.pair ha h1.2))
exact (ih _ hca ha).elim fun a1 h1 => Exists.intro _ (And.intro (Steps.app h1.1) (.app h1.2))
(And.intro (Steps.eval h1.1 (Steps.refl _)) (.eval h1.2 hb))
(And.intro (Steps.eval (Steps.refl _) h1.1) (.eval ha h1.2))
(And.intro (Steps.comb3 h1.1 (Steps.refl _) (Steps.refl _)) (.comb h1.2 hb hc'))
(And.intro (Steps.comb3 (Steps.refl _) h1.1 (Steps.refl _)) (.comb ha h1.2 hc'))
(And.intro (Steps.comb3 (Steps.refl _) (Steps.refl _) h1.1) (.comb ha hb h1.2))
| hidden => exact Exists.intro _ (And.intro (Steps.refl _) (.hidden _ _))
(And.intro (Steps.capsule h1.1) (.capsule k' h1.2))
| hidden v v' => exact Exists.intro _ (And.intro (Steps.refl _) (.hidden _ _))
theorem csim_steps {k : Nat} {t t' u : Term} (hc : Clean k t) (hs : CSim k t t') (h : Steps t u) :¶ node
| refl => exact Exists.intro t' (And.intro (Steps.refl _) hs)
exact ih.elim fun v' hv => (csim_step hstep v' (Clean.steps hp hc) hv.2).elim fun w' hw =>
theorem CSim.envAt {k : Nat} {s : Nat} {y y' : Term} (h : CSim k y y') : forall (pre post : Env),¶ node
CSim k (.env (pre ++ (s, y) :: post)) (.env (pre ++ (s, y') :: post))
| [], post => .envCons s h (CSim.reflEnv post)
| (s', t) :: pre, post => .envCons s' (CSim.refl t) (CSim.envAt h pre post)
theorem CSim.plug {k : Nat} (c : Ctx) {t t' : Term} (h : CSim k t t') : CSim k (c.plug t) (c.plug t') := by¶ node
| envAt pre s c post ih => exact CSim.envAt ih pre post
| pairL c b ih => exact .pair ih (CSim.refl _)
| pairR a c ih => exact .pair (CSim.refl _) ih
| evalL c b ih => exact .eval ih (CSim.refl _)
| evalR a c ih => exact .eval (CSim.refl _) ih
(csim_steps hc hs h).elim fun u' hu => by
theorem capsule_opacity {k n : Nat} {v v' : Term} (c : Ctx) (hc : Clean k (c.plug (capsule k v))) :¶ plain English
exact Iff.intro (CSim.observe hc hs) (CSim.observe (Clean.csim hc hs) hs.symm)
refine And.intro (Steps.top (.deltaDecap k _)) (fun h => ?_)
Steps.top (.deltaDecap k _)
have := normal_unique h h6 (normal_dat 5) (normal_dat 6)