-
Notifications
You must be signed in to change notification settings - Fork 24
/
Lec_2_25.hs
74 lines (54 loc) · 1.84 KB
/
Lec_2_25.hs
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
67
68
69
70
71
72
73
74
{-@ LIQUID "--reflection" @-}
{-@ LIQUID "--diff" @-}
{-@ LIQUID "--ple" @-}
{-@ LIQUID "--short-names" @-}
{-@ infixr ++ @-} -- TODO: Silly to have to rewrite this annotation!
{-# LANGUAGE GADTs #-}
module Lec_2_25 where
import Prelude hiding ((++))
import ProofCombinators
import qualified State as S
import qualified Data.Set as S
import Expressions hiding (And)
import Imp
import BigStep
-------------------------------------------------------------------------------
{- | Here are various other fun equivalences you can try to prove
-------------------------------------------------------------------------------
x := x ~ SKIP
x := n; ~ y := n
y := n y := n
x := a; ~ x := a if x not in a
y := a y := x
IF true c1 c2 ~ c1
IF false c1 c2 ~ c2
WHILE false c ~ SKIP
SKIP; c ~ c
-}
{-@ thm_bigstep_det
:: s:_ -> t1:_ -> t2:_ -> c:_
-> Prop (BStep c s t1)
-> Prop (BStep c s t2)
-> { t1 == t2 }
@-}
thm_bigstep_det :: State -> State -> State -> Com -> BStep -> BStep -> Proof
thm_bigstep_det s t1 t2 Skip (BSkip {}) (BSkip {})
= () -- t1 == t2 == s
thm_bigstep_det s t1 t2 (Assign x a) (BAssign {}) (BAssign {})
= () -- t1 == t2 == asgn x a s
thm_bigstep_det s t1 t2 (Seq cA cB)
(BSeq _ _ _ sA1 _ cA_s_sA1 cB_sA1_t1)
(BSeq _ _ _ sA2 _ cA_s_sA2 cB_sA2_t2)
= thm_bigstep_det sAB1 t1 t2 cB cB_sA1_t1 cB_sA2_t2
where
sAB1 = sA1 ? thm_bigstep_det s sA1 sA2 cA cA_s_sA1 cA_s_sA2
thm_bigstep_det s t1 t2 (If b c _)
(BIfT _ _ _ _ _ c_s_t1)
(BIfT _ _ _ _ _ c_s_t2)
= thm_bigstep_det s t1 t2 c c_s_t1 c_s_t2
thm_bigstep_det s t1 t2 (If b _ c)
(BIfF _ _ _ _ _ c_s_t1)
(BIfF _ _ _ _ _ c_s_t2)
= thm_bigstep_det s t1 t2 c c_s_t1 c_s_t2
thm_bigstep_det s t1 t2 (While b c) c_s_t1 c_s_t2
= undefined