@@ -55,51 +55,40 @@ add_aesop_rules safe tactic [
55
55
-- SmallStep のための見やすい記法を用意する
56
56
@[inherit_doc] notation :55 "(" c1:55 "," s1:55 ")" " =>ₛ " "(" c2:55 "," s2:55 ")" => SmallStep c1 s1 c2 s2
57
57
58
-
59
58
/-- コマンドと状態を組にしたもの。configuration -/
60
59
abbrev Config := Stmt × State
61
60
62
- -- /-- SmallStep の二項関係バージョン -/
63
- -- abbrev smallStepBin (conf₁ conf₂ : Config) : Prop := SmallStep conf₁.1 conf₁.2 conf₂.1 conf₂.2
61
+ /-- SmallStep の二項関係バージョン -/
62
+ abbrev smallStepBin (conf₁ conf₂ : Config) : Prop := SmallStep conf₁.1 conf₁.2 conf₂.1 conf₂.2
63
+
64
+ @[inherit_doc] infix :30 " ⇒ " => smallStepBin
64
65
65
66
-- add_aesop_rules safe tactic [(by dsimp [ smallStepBin ] ) (rule_sets := [ SmallStepRules ] )]
66
67
67
68
open Relation
68
69
69
70
/-- `smallStepBin` という二項関係の反射的推移的閉包 -/
70
71
@[reducible] def smallStepStar : Config → Config → Prop :=
71
- ReflTransGen ( fun conf₁ conf₂ => SmallStep conf₁. 1 conf₁. 2 conf₂. 1 conf₂. 2 )
72
+ ReflTransGen smallStepBin
72
73
73
74
@[inherit_doc] infix :30 " ⇒* " => smallStepStar
74
75
76
+ instance : Trans smallStepBin smallStepBin smallStepStar where
77
+ trans a_b b_c := ReflTransGen.head a_b (ReflTransGen.head b_c .refl)
78
+ instance : Trans smallStepBin smallStepStar smallStepStar where
79
+ trans a_b b__c := ReflTransGen.head a_b b__c
80
+ instance : Trans smallStepStar smallStepBin smallStepStar where
81
+ trans a__b b_c := ReflTransGen.tail a__b b_c
82
+
75
83
#check sillyLoop
76
84
77
85
example : (sillyLoop, (fun _ => 0 )["x" ↦ 1 ]) ⇒* (skip, (fun _ => 0 )) := by
78
86
dsimp [sillyLoop]
79
-
80
- generalize hB : (fun s : State ↦ s "x" > s "y" ) = B0
81
- generalize hS : (skip;; assign "x" (fun s ↦ s "x" - 1 )) = S0
82
- generalize hs : (fun v ↦ (if v = "x" then 1 else 0 )) = s0
83
-
84
- have : (whileDo B0 S0, s0) ⇒* (skip, fun x ↦ 0 ) := calc
85
- _ ⇒* (ifThenElse B0 (S0 ;; whileDo B0 S0) skip, s0) := ?step1
86
- _ ⇒* (S0 ;; whileDo B0 S0, s0) := ?step2
87
- _ ⇒* (whileDo B0 S0, fun _ ↦ 0 ) := ?step3
88
- _ ⇒* (skip, fun x ↦ 0 ) := by sorry
89
-
90
- case step1 =>
91
- apply ReflTransGen.head (a := (whileDo B0 S0, s0)) (hbc := ReflTransGen.refl)
92
- apply SmallStep.whileDo
93
-
94
- case step2 =>
95
- apply ReflTransGen.head (a := (ifThenElse B0 (S0 ;; whileDo B0 S0) skip, s0)) (hbc := ReflTransGen.refl)
96
- apply SmallStep.if_true
97
- rw [← hB, ← hs]
98
- simp
99
-
100
- case step3 =>
101
- have : (S0,s0) =>ₛ (skip, fun x ↦ 0 ) := by sorry
102
- have := @SmallStep.seq_step (S := S0) (s := s0) (S' := skip) (s' := fun _ ↦ 0 )
103
- sorry
104
-
105
- sorry
87
+ calc
88
+ _ ⇒ (_, _) := by dsimp [smallStepBin]; small_step
89
+ _ ⇒ (_, _) := by dsimp [smallStepBin]; apply SmallStep.if_true; simp
90
+ _ ⇒ (_, _) := by dsimp [smallStepBin]; small_step
91
+ _ ⇒ (_, _) := by dsimp [smallStepBin]; small_step
92
+ _ ⇒ (_, _) := by dsimp [smallStepBin]; small_step
93
+ _ ⇒ (_, _) := by dsimp [smallStepBin]; small_step
94
+ _ ⇒ (_, _) := by dsimp [smallStepBin]; apply SmallStep.if_false; simp
0 commit comments