Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment 08_04 #133

Open
alkaza opened this issue May 27, 2015 · 18 comments
Open

Assignment 08_04 #133

alkaza opened this issue May 27, 2015 · 18 comments

Comments

@alkaza
Copy link

alkaza commented May 27, 2015

I did not find any issues describing my problem. I gave up on solving this assignment, because i got stuck on a seemingly simple case which I couldn't prove.

3 subgoal
c1 : com
c2 : com
NOWHL : no_whiles (c1;; c2) = true
IHc1 : no_whiles c1 = true ->
       forall st : state, exists st' : state, c1 / st || st'
IHc2 : no_whiles c2 = true ->
       forall st : state, exists st' : state, c2 / st || st'
st : state
H0 : no_whiles c1 && no_whiles c2 = true
H : exists st' : state, c1 / st || st'
H1 : exists st'' : state, c2 / st || st''
x : state
H2 : c1 / st || x
x0 : state
H3 : c2 / st || x0
(1/3)
c2 / x || x0
______________________________________(2/3)
forall st : state, exists st' : state, (IFB b THEN c1 ELSE c2 FI) / st || st'
______________________________________(3/3)
forall st : state, exists st' : state, (WHILE b DO c END) / st || st'

I tried proving the theorem in the other way but it always comes to this case. What should I do or what am I doing wrong?

@alkaza
Copy link
Author

alkaza commented May 27, 2015

I start by:

  intros. generalize dependent st.
  induction c.

and then get stuck on the third case:

3 subgoal
c1 : com
c2 : com
NOWHL : no_whiles (c1;; c2) = true
IHc1 : no_whiles c1 = true ->
       forall st : state, exists st' : state, c1 / st || st'
IHc2 : no_whiles c2 = true ->
       forall st : state, exists st' : state, c2 / st || st'
st : state
H0 : no_whiles c1 && no_whiles c2 = true
______________________________________(1/3)
exists st' : state, (c1;; c2) / st || st'
______________________________________(2/3)
forall st : state, exists st' : state, (IFB b THEN c1 ELSE c2 FI) / st || st'
______________________________________(3/3)
forall st : state, exists st' : state, (WHILE b DO c END) / st || st'

and doing:

  intros. inversion NOWHL. apply andb_true_iff in H0. inversion H0.
    assert (exists st', c1 / st || st'). apply IHc1. apply H.
    assert (exists st'', c2 / st || st''). apply IHc2. apply H1.
    inversion H2. inversion H3. exists x0. apply E_Seq with x. apply H4.

leads to nowhere.

@jeehoonkang
Copy link
Contributor

You have to exploit IHc1 and IHc2. For this, you have to know no_whiles c1 and no_whiles c2. I believe the context has enough information to proceed in this way.

@alkaza
Copy link
Author

alkaza commented May 28, 2015

But how? Since subgoal is like this:

______________________________________(1/3)
exists st' : state, (c1;; c2) / st || st'

And it should match

c1 / st ⇓ st' 
c2 / st' ⇓ st''   (E_Seq)  
c1;;c2 / st ⇓ st''

But it doesn't...

@alkaza
Copy link
Author

alkaza commented May 28, 2015

When I do this

  intros. inversion NOWHL. apply andb_true_iff in H0. inversion H0.
    assert (exists st', c1 / st || st'). apply IHc1. apply H.
    assert (exists st'', c2 / st || st''). apply IHc2. apply H1.
    inversion H2. inversion H3. exists x0. apply E_Seq with x. apply H4.

I get unsolvable subgoal:

3 subgoal
c1 : com
c2 : com
NOWHL : no_whiles (c1;; c2) = true
IHc1 : no_whiles c1 = true ->
       forall st : state, exists st' : state, c1 / st || st'
IHc2 : no_whiles c2 = true ->
       forall st : state, exists st' : state, c2 / st || st'
st : state
H0 : no_whiles c1 = true /\ no_whiles c2 = true
H : no_whiles c1 = true
H1 : no_whiles c2 = true
H2 : exists st' : state, c1 / st || st'
H3 : exists st'' : state, c2 / st || st''
x : state
H4 : c1 / st || x
x0 : state
H5 : c2 / st || x0
______________________________________(1/3)
c2 / x || x0
______________________________________(2/3)
forall st : state, exists st' : state, (IFB b THEN c1 ELSE c2 FI) / st || st'
______________________________________(3/3)
forall st : state, exists st' : state, (WHILE b DO c END) / st || st'

@AdamBJ
Copy link

AdamBJ commented May 28, 2015

@alkaza You don't want to unfold the definition of hoare_triple for the questions in this assignment (with the exception of one questions where they tell you to). Instead of leading with inversion like we've done before, you want to use the hoare rules introduced in the two Hoare chapters in the text.

For this question, you should start with something like eapply hoare_seq.. Break down the program until you can apply rules like hoare_asgn to solve the subgoals.

@alkaza
Copy link
Author

alkaza commented May 28, 2015

@AdamBJ but this is HW8, not 9

@AdamBJ
Copy link

AdamBJ commented May 28, 2015

Oh, woops:p

@alkaza
Copy link
Author

alkaza commented May 28, 2015

@AdamBJ any tips on this one? :)

@AdamBJ
Copy link

AdamBJ commented May 28, 2015

@alkaza Assignment 8 seems like years ago now! If I manage to finish assignment 9 before the deadline I'll see if I even got that one when I did A8.

@alkaza
Copy link
Author

alkaza commented May 28, 2015

Thnx

@jeehoonkang
Copy link
Contributor

Sorry I am late. Try assert (exists st'', c2 / st' || st''). apply IHc2. apply H1.. instead.

@alkaza
Copy link
Author

alkaza commented May 28, 2015

@jeehoonkang yeah i tried that before, it says:

Error: The reference st' was not found in the current environment.

@alkaza
Copy link
Author

alkaza commented May 28, 2015

Seemed to me

    assert (exists st', c1 / st || st'). apply IHc1. apply H.
    assert (exists st'', c2 / st || st''). apply IHc2. apply H1.

was the only way, but then I get stuck

@AdamBJ
Copy link

AdamBJ commented May 28, 2015

@alkaza I didn't get 08_04 either

@jeehoonkang
Copy link
Contributor

assert (ST': exists st', c1 / st || st'). apply IHc1. apply H.
destruct ST' as [st' ST'].
assert (ST'': exists st'', c2 / st || st''). apply IHc2. apply H1.
destruct ST'' as [st'' ST''].

@alkaza
Copy link
Author

alkaza commented May 28, 2015

Stuck on the last case in a same way:

3 subgoal
c1 : com
c2 : com
NOWHL : no_whiles (c1;; c2) = true
IHc1 : no_whiles c1 = true ->
       forall st : state, exists st' : state, c1 / st || st'
IHc2 : no_whiles c2 = true ->
       forall st : state, exists st' : state, c2 / st || st'
st : state
H0 : no_whiles c1 = true /\ no_whiles c2 = true
H : no_whiles c1 = true
H1 : no_whiles c2 = true
st' : state
ST' : c1 / st || st'
st'' : state
ST'' : c2 / st || st''
______________________________________(1/3)
c2 / st' || st''

@jeehoonkang
Copy link
Contributor

Ah sorry; replace assert (ST'': exists st'', c2 / st || st''). apply IHc2. apply H1. by assert (ST'': exists st'', c2 / st' || st''). apply IHc2. apply H1.

@alkaza
Copy link
Author

alkaza commented May 28, 2015

Yaaay, thank you so much! Solved it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants