@@ -201,6 +201,8 @@ Right-hand sides of sums can take a step only when the
201
201
> (C (0 + 3 )))
202
202
> test_step_2 = ? test_step_2_rhs
203
203
204
+ $\ square$
205
+
204
206
== Relations
205
207
206
208
We will be working with several different single- step relations,
@@ -391,6 +393,7 @@ Most of this proof is the same as the one above. But to get
391
393
> step_deterministic' = ?step_deterministic_rhs
392
394
>
393
395
396
+ $\square$
394
397
395
398
=== Strong Progress and Normal Forms
396
399
@@ -529,6 +532,8 @@ We might, for example, mistakenly define `value` so that it
529
532
> value_not_same_as_normal_form : (v : Tm ** (Value' v, Not (normal_form Step'' v)))
530
533
> value_not_same_as_normal_form = ?value_not_same_as_normal_form_rhs
531
534
535
+ $\square$
536
+
532
537
==== Exercise: 2 stars, optional (value_not_same_as_normal_form2)
533
538
534
539
Alternatively, we might mistakenly define `step` so that it
@@ -553,6 +558,8 @@ Alternatively, we might mistakenly define `step` so that it
553
558
> value_not_same_as_normal_form''' : (v : Tm ** (Value v, Not (normal_form Step''' v)))
554
559
> value_not_same_as_normal_form''' = ?value_not_same_as_normal_form_rhs'''
555
560
561
+ $\square$
562
+
556
563
==== Exercise: 3 stars, optional (value_not_same_as_normal_form3)
557
564
558
565
Finally, we might define `value` and `step` so that there is some
@@ -578,6 +585,8 @@ Finally, we might define `value` and `step` so that there is some
578
585
> value_not_same_as_normal_form'''' : (t : Tm ** (Not (Value t), normal_form Step'''' t))
579
586
> value_not_same_as_normal_form'''' = ?value_not_same_as_normal_form_rhs''''
580
587
588
+ $\square$
589
+
581
590
582
591
=== Additional Exercises
583
592
@@ -636,6 +645,8 @@ Which of the following propositions are provable? (This is just a
636
645
> Tfalse
637
646
> bool_step_prop3 = ?bool_step_prop3_rhs
638
647
648
+ $\square$
649
+
639
650
640
651
==== Exercise: 3 stars, optional (progress_bool)
641
652
@@ -693,6 +704,8 @@ Write an extra clause for the step relation that achieves this
693
704
> bool_step_prop4_holds : bool_step_prop4
694
705
> bool_step_prop4_holds = ?bool_step_prop4_holds_rhs
695
706
707
+ $\square$
708
+
696
709
697
710
==== Exercise: 3 stars, optional (properties_of_altered_step)
698
711
It can be shown that the determinism and strong progress theorems
@@ -711,9 +724,11 @@ Optional: prove your answer correct in Idris.
711
724
Optional: prove your answer correct in Idris.
712
725
713
726
In general, is there any way we could cause strong progress to
714
- fail if we took away one or more constructors from the original
715
- step relation? Write yes or no and briefly (1 sentence) explain
716
- your answer.
727
+ fail if we took away one or more constructors from the original
728
+ step relation? Write yes or no and briefly (1 sentence) explain
729
+ your answer.
730
+
731
+ $\square$
717
732
718
733
== Multi-Step Reduction
719
734
@@ -823,6 +838,8 @@ Here's a specific instance of the `multi step` relation:
823
838
> test_multistep_2: C 3 ->>* C 3
824
839
> test_multistep_2 = ?test_multistep_2_rhs
825
840
841
+ $\square$
842
+
826
843
==== Exercise: 1 star, optional (test_multistep_3)
827
844
828
845
> test_multistep_3:
@@ -831,6 +848,8 @@ Here's a specific instance of the `multi step` relation:
831
848
> P (C 0) (C 3)
832
849
> test_multistep_3 = ?test_multistep_3_rhs
833
850
851
+ $\square$
852
+
834
853
==== Exercise: 2 stars (test_multistep_4)
835
854
836
855
> test_multistep_4:
@@ -845,6 +864,8 @@ Here's a specific instance of the `multi step` relation:
845
864
> (C (2 + (0 + 3)))
846
865
> test_multistep_4 = ?test_multistep_4_rhs
847
866
867
+ $\square$
868
+
848
869
=== Normal Forms Again
849
870
850
871
If `t` reduces to `t'` in zero or more steps and `t'` is a
@@ -868,6 +889,7 @@ We have already seen that, for our language, single-step reduction is
868
889
> normal_forms_unique : deterministic Smallstep.normal_form_of
869
890
> normal_forms_unique (l,r) (l2,r2) = ?normal_forms_unique_rhs
870
891
892
+ $\square$
871
893
872
894
Indeed, something stronger is true for this language (though not
873
895
for all languages): the reduction of _any_ term `t` will
@@ -900,6 +922,8 @@ node whose left-hand child is a value.
900
922
> multistep_congr_2 : {v:Value t1} -> (t2 ->>* t2') -> ((P t1 t2) ->>* P t1 t2')
901
923
> multistep_congr_2 {v=V_const i} mult = ?multistep_congr_2_rhs
902
924
925
+ $\square$
926
+
903
927
With these lemmas in hand, the main proof is a straightforward
904
928
induction.
905
929
@@ -978,6 +1002,8 @@ Having defined the operational semantics of our tiny programming
978
1002
> eval__multistep: {t: Tm} -> {n: Nat} -> t >>> n -> t ->>* C n
979
1003
> eval__multistep hyp = ?eval__multistep_rhs
980
1004
1005
+ $\square$
1006
+
981
1007
The key ideas in the proof can be seen in the following picture:
982
1008
983
1009
```
@@ -1016,7 +1042,7 @@ To formalize this intuition, you'll need to use the congruence
1016
1042
1017
1043
Write a detailed informal version of the proof of `eval__multistep`
1018
1044
1019
- (* FILL IN HERE *)
1045
+ $\square$
1020
1046
1021
1047
For the other direction, we need one lemma, which establishes a
1022
1048
relation between single-step reduction and big-step evaluation.
@@ -1029,39 +1055,44 @@ For the other direction, we need one lemma, which establishes a
1029
1055
> t >>> n
1030
1056
> step__eval h1 h2 = ?step__eval_rhs
1031
1057
1058
+ $\square$
1059
+
1032
1060
The fact that small-step reduction implies big-step evaluation is
1033
- now straightforward to prove, once it is stated correctly.
1061
+ now straightforward to prove, once it is stated correctly.
1034
1062
1035
1063
The proof proceeds by induction on the multi-step reduction
1036
- sequence that is buried in the hypothesis `normal_form_of t t'`.
1064
+ sequence that is buried in the hypothesis `normal_form_of t t'`.
1037
1065
1038
1066
Make sure you understand the statement before you start to
1039
- work on the proof.
1067
+ work on the proof.
1040
1068
1041
1069
==== Exercise: 3 stars (multistep__eval)
1042
1070
1043
1071
> multistep__eval : {t, t': Tm} ->
1044
1072
> normal_form_of t t' -> (n : Nat ** (t' = C n, t >>> n))
1045
1073
> multistep__eval hyp = ?multistep__eval_rhs
1046
1074
1075
+ $\square$
1047
1076
1048
1077
=== Additional Exercises
1049
1078
1050
1079
==== Exercise: 3 stars, optional (interp_tm)
1051
1080
1052
1081
Remember that we also defined big-step evaluation of terms as a
1053
- function `evalF`. Prove that it is equivalent to the existing
1054
- semantics. (Hint: we just proved that `eval` and `multistep` are
1055
- equivalent, so logically it doesn't matter which you choose.
1056
- One will be easier than the other, though!)
1082
+ function `evalF`. Prove that it is equivalent to the existing
1083
+ semantics. (Hint: we just proved that `eval` and `multistep` are
1084
+ equivalent, so logically it doesn't matter which you choose.
1085
+ One will be easier than the other, though!)
1057
1086
1058
1087
> evalF_eval : {t: Tm} -> {n: Nat} -> ((evalF t = n) <-> (t >>> n))
1088
+ > evalF_eval = ?evalF_eval_rhs
1089
+
1090
+ $\square$
1059
1091
1060
1092
==== Exercise: 4 stars (combined_properties)
1061
1093
1062
1094
We've considered arithmetic and conditional expressions
1063
- separately. This exercise explores how the two interact.
1064
-
1095
+ separately. This exercise explores how the two interact.
1065
1096
1066
1097
> data TmC : Type where
1067
1098
> CC : Nat -> TmC
@@ -1075,7 +1106,6 @@ We've considered arithmetic and conditional expressions
1075
1106
> V_trueC : ValueC TtrueC
1076
1107
> V_falseC : ValueC TfalseC
1077
1108
1078
-
1079
1109
> mutual
1080
1110
> infixl 6 >>->
1081
1111
> (>>->) : TmC -> TmC -> Type
@@ -1101,7 +1131,7 @@ Formally prove or disprove these two properties for the combined
1101
1131
language. (That is, state a theorem saying that the property
1102
1132
holds or does not hold, and prove your theorem.)
1103
1133
1104
- (* FILL IN HERE *)
1134
+ $\square$
1105
1135
1106
1136
<!--
1107
1137
@@ -1510,6 +1540,4 @@ Proof.
1510
1540
(* FILL IN HERE *) Admitted.
1511
1541
(** [] *)
1512
1542
1513
- (** $Date$ *)
1514
-
1515
1543
-->
0 commit comments