Skip to content

Commit 6d3de9e

Browse files
authored
Merge pull request #2 from spinylobster/main
2 parents e717033 + c397056 commit 6d3de9e

File tree

1 file changed

+20
-31
lines changed

1 file changed

+20
-31
lines changed

ConcreteSemantics/SmallStep.lean

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -55,51 +55,40 @@ add_aesop_rules safe tactic [
5555
-- SmallStep のための見やすい記法を用意する
5656
@[inherit_doc] notation:55 "(" c1:55 "," s1:55 ")" " =>ₛ " "(" c2:55 "," s2:55 ")" => SmallStep c1 s1 c2 s2
5757

58-
5958
/-- コマンドと状態を組にしたもの。configuration -/
6059
abbrev Config := Stmt × State
6160

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
6465

6566
-- add_aesop_rules safe tactic [(by dsimp [smallStepBin]) (rule_sets := [SmallStepRules])]
6667

6768
open Relation
6869

6970
/-- `smallStepBin` という二項関係の反射的推移的閉包 -/
7071
@[reducible] def smallStepStar : Config → Config → Prop :=
71-
ReflTransGen (fun conf₁ conf₂ => SmallStep conf₁.1 conf₁.2 conf₂.1 conf₂.2)
72+
ReflTransGen smallStepBin
7273

7374
@[inherit_doc] infix:30 " ⇒* " => smallStepStar
7475

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+
7583
#check sillyLoop
7684

7785
example : (sillyLoop, (fun _ => 0)["x"1]) ⇒* (skip, (fun _ => 0)) := by
7886
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

Comments
 (0)