Skip to content

Instantly share code, notes, and snippets.

@mukeshtiwari
Created October 21, 2016 00:00
Show Gist options
  • Select an option

  • Save mukeshtiwari/86d63bf2efb5db89cb7fceeddcedd772 to your computer and use it in GitHub Desktop.

Select an option

Save mukeshtiwari/86d63bf2efb5db89cb7fceeddcedd772 to your computer and use it in GitHub Desktop.
Theorem s_concat_program :
forall (st : state) (prog1 prog2 : list sinstr) (l : list nat),
s_execute st l (prog1 ++ prog2) = s_execute st (s_execute st l prog1) prog2.
Proof.
intros st. induction prog1.
auto.
simpl. intros.
destruct (s_eval st l a); apply IHprog1.
Qed.
Theorem s_compile_correct : forall (st : state) (e : aexp),
s_execute st [] (s_compile e) = [ aeval st e ].
Proof.
intros st. induction e.
auto. auto. simpl.
try ( repeat (rewrite s_concat_program)).
rewrite IHe1.
st : state
e1, e2 : aexp
IHe1 : s_execute st [] (s_compile e1) = [aeval st e1]
IHe2 : s_execute st [] (s_compile e2) = [aeval st e2]
============================
s_execute st (s_execute st [aeval st e1] (s_compile e2)) [SPlus] = [aeval st e1 + aeval st e2]
subgoal 2 (ID 176) is:
s_execute st [] (s_compile (AMinus e1 e2)) = [aeval st (AMinus e1 e2)]
subgoal 3 (ID 181) is:
s_execute st [] (s_compile (AMult e1 e2)) = [aeval st (AMult e1 e2)]
@mukeshtiwari
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment