tidied up reduction example

This commit is contained in:
wadler 2018-05-01 11:59:25 -03:00
parent 49bc02d39a
commit 25cd81b35d

View file

@ -286,6 +286,35 @@ _ =
ƛ ⌊ Z ⌋
_ : plus {ε} · two · two ⟶* four
_ =
plus · two · two
⟶⟨ ξ-⇒₁ (ξ-⇒₁ β-μ) ⟩
(ƛ (ƛ `case ⌊ S Z ⌋ ⌊ Z ⌋ (`suc (plus · ⌊ Z ⌋ · ⌊ S Z ⌋)))) · two · two
⟶⟨ ξ-⇒₁ (β-⇒ (Suc (Suc Zero))) ⟩
(ƛ `case two ⌊ Z ⌋ (`suc (plus · ⌊ Z ⌋ · ⌊ S Z ⌋))) · two
⟶⟨ β-⇒ (Suc (Suc Zero)) ⟩
`case two two (`suc (plus · ⌊ Z ⌋ · two))
⟶⟨ β-ℕ₂ (Suc Zero) ⟩
`suc (plus · `suc `zero · two)
⟶⟨ ξ- (ξ-⇒₁ (ξ-⇒₁ β-μ)) ⟩
`suc ((ƛ (ƛ `case ⌊ S Z ⌋ ⌊ Z ⌋ (`suc (plus · ⌊ Z ⌋ · ⌊ S Z ⌋)))) · `suc `zero · two)
⟶⟨ ξ- (ξ-⇒₁ (β-⇒ (Suc Zero))) ⟩
`suc ((ƛ `case (`suc `zero) ⌊ Z ⌋ (`suc (plus · ⌊ Z ⌋ · ⌊ S Z ⌋))) · two)
⟶⟨ ξ- (β-⇒ (Suc (Suc Zero))) ⟩
`suc (`case (`suc `zero) (two) (`suc (plus · ⌊ Z ⌋ · two)))
⟶⟨ ξ- (β-ℕ₂ Zero) ⟩
`suc (`suc (plus · `zero · two))
⟶⟨ ξ- (ξ- (ξ-⇒₁ (ξ-⇒₁ β-μ))) ⟩
`suc (`suc ((ƛ (ƛ `case ⌊ S Z ⌋ ⌊ Z ⌋ (`suc (plus · ⌊ Z ⌋ · ⌊ S Z ⌋)))) · `zero · two))
⟶⟨ ξ- (ξ- (ξ-⇒₁ (β-⇒ Zero))) ⟩
`suc (`suc ((ƛ `case `zero ⌊ Z ⌋ (`suc (plus · ⌊ Z ⌋ · ⌊ S Z ⌋))) · two))
⟶⟨ ξ- (ξ- (β-⇒ (Suc (Suc Zero)))) ⟩
`suc (`suc (`case `zero (two) (`suc (plus · ⌊ Z ⌋ · two))))
⟶⟨ ξ- (ξ- β-ℕ₁) ⟩
`suc (`suc (`suc (`suc `zero)))
_ : fromCh · (plusCh · twoCh · twoCh) ⟶* four
_ =
begin
@ -317,141 +346,6 @@ _ =
⟶⟨ β-⇒ (Suc (Suc (Suc Zero))) ⟩
`suc (`suc (`suc (`suc `zero)))
_ : plus {ε} · two · two ⟶* four
_ =
((μ
`case ⌊ S Z ⌋ ⌊ Z ⌋ (`suc (⌊ S (S (S Z)) ⌋ · ⌊ Z ⌋ · ⌊ S Z ⌋)))))
· `suc (`suc `zero)
· `suc (`suc `zero)
⟶⟨ ξ-⇒₁ (ξ-⇒₁ β-μ) ⟩
`case ⌊ S Z ⌋ ⌊ Z ⌋
(`suc
((μ
`case ⌊ S Z ⌋ ⌊ Z ⌋ (`suc (⌊ S (S (S Z)) ⌋ · ⌊ Z ⌋ · ⌊ S Z ⌋)))))
· ⌊ Z ⌋
· ⌊ S Z ⌋))))
· `suc (`suc `zero)
· `suc (`suc `zero)
⟶⟨ ξ-⇒₁ (β-⇒ (Suc (Suc Zero))) ⟩
`case (`suc (`suc `zero)) ⌊ Z ⌋
(`suc
((μ
`case ⌊ S Z ⌋ ⌊ Z ⌋ (`suc (⌊ S (S (S Z)) ⌋ · ⌊ Z ⌋ · ⌊ S Z ⌋)))))
· ⌊ Z ⌋
· ⌊ S Z ⌋)))
· `suc (`suc `zero)
⟶⟨ β-⇒ (Suc (Suc Zero)) ⟩
`case (`suc (`suc `zero)) (`suc (`suc `zero))
(`suc
((μ
`case ⌊ S Z ⌋ ⌊ Z ⌋ (`suc (⌊ S (S (S Z)) ⌋ · ⌊ Z ⌋ · ⌊ S Z ⌋)))))
· ⌊ Z ⌋
· `suc (`suc `zero)))
⟶⟨ β-ℕ₂ (Suc Zero) ⟩
`suc
((μ
`case ⌊ S Z ⌋ ⌊ Z ⌋ (`suc (⌊ S (S (S Z)) ⌋ · ⌊ Z ⌋ · ⌊ S Z ⌋)))))
· `suc `zero
· `suc (`suc `zero))
⟶⟨ ξ- (ξ-⇒₁ (ξ-⇒₁ β-μ)) ⟩
`suc
((ƛ
`case ⌊ S Z ⌋ ⌊ Z ⌋
(`suc
((μ
`case ⌊ S Z ⌋ ⌊ Z ⌋ (`suc (⌊ S (S (S Z)) ⌋ · ⌊ Z ⌋ · ⌊ S Z ⌋)))))
· ⌊ Z ⌋
· ⌊ S Z ⌋))))
· `suc `zero
· `suc (`suc `zero))
⟶⟨ ξ- (ξ-⇒₁ (β-⇒ (Suc Zero))) ⟩
`suc
((ƛ
`case (`suc `zero) ⌊ Z ⌋
(`suc
((μ
`case ⌊ S Z ⌋ ⌊ Z ⌋ (`suc (⌊ S (S (S Z)) ⌋ · ⌊ Z ⌋ · ⌊ S Z ⌋)))))
· ⌊ Z ⌋
· ⌊ S Z ⌋)))
· `suc (`suc `zero))
⟶⟨ ξ- (β-⇒ (Suc (Suc Zero))) ⟩
`suc
(`case (`suc `zero) (`suc (`suc `zero))
(`suc
((μ
`case ⌊ S Z ⌋ ⌊ Z ⌋ (`suc (⌊ S (S (S Z)) ⌋ · ⌊ Z ⌋ · ⌊ S Z ⌋)))))
· ⌊ Z ⌋
· `suc (`suc `zero))))
⟶⟨ ξ- (β-ℕ₂ Zero) ⟩
`suc
(`suc
((μ
`case ⌊ S Z ⌋ ⌊ Z ⌋ (`suc (⌊ S (S (S Z)) ⌋ · ⌊ Z ⌋ · ⌊ S Z ⌋)))))
· `zero
· `suc (`suc `zero)))
⟶⟨ ξ- (ξ- (ξ-⇒₁ (ξ-⇒₁ β-μ))) ⟩
`suc
(`suc
((ƛ
`case ⌊ S Z ⌋ ⌊ Z ⌋
(`suc
((μ
`case ⌊ S Z ⌋ ⌊ Z ⌋ (`suc (⌊ S (S (S Z)) ⌋ · ⌊ Z ⌋ · ⌊ S Z ⌋)))))
· ⌊ Z ⌋
· ⌊ S Z ⌋))))
· `zero
· `suc (`suc `zero)))
⟶⟨ ξ- (ξ- (ξ-⇒₁ (β-⇒ Zero))) ⟩
`suc
(`suc
((ƛ
`case `zero ⌊ Z ⌋
(`suc
((μ
`case ⌊ S Z ⌋ ⌊ Z ⌋ (`suc (⌊ S (S (S Z)) ⌋ · ⌊ Z ⌋ · ⌊ S Z ⌋)))))
· ⌊ Z ⌋
· ⌊ S Z ⌋)))
· `suc (`suc `zero)))
⟶⟨ ξ- (ξ- (β-⇒ (Suc (Suc Zero)))) ⟩
`suc
(`suc
(`case `zero (`suc (`suc `zero))
(`suc
((μ
`case ⌊ S Z ⌋ ⌊ Z ⌋ (`suc (⌊ S (S (S Z)) ⌋ · ⌊ Z ⌋ · ⌊ S Z ⌋)))))
· ⌊ Z ⌋
· `suc (`suc `zero)))))
⟶⟨ ξ- (ξ- β-ℕ₁) ⟩ `suc (`suc (`suc (`suc `zero))) ∎)
\end{code}