Philip Wadler
2018-05-03 11:49:03 UTC
Here is a proof that reduction is deterministic:
-- Values do not reduce
det : â {M Mâ² Mâ³}
https://wenkokke.github.io/sf/Typed
Almost half the lines in the above proof are redundant, for example
det (Ο-·â Lâ¶Lâ²) (Ο-·â VL _) = â¥-elim (Val-ⶠVL Lâ¶Lâ²)
What I would like to do is delete the redundant lines and add
det Mâ¶Mâ² Mâ¶Mâ³ = sym (det Mâ¶Mâ³ Mâ¶Mâ²)
to the bottom of the proof. But, of course, the termination checker
complains.
How can I rewrite the proof to exploit symmetry? Cheers, -- P
. \ Philip Wadler, Professor of Theoretical Computer Science,
. /\ School of Informatics, University of Edinburgh
. / \ and Senior Research Fellow, IOHK
. http://homepages.inf.ed.ac.uk/wadler/
-- Values do not reduce
Val-ⶠ: â {M N} â Value M â ¬ (M ⶠN)
Val-ⶠFun ()
Val-ⶠZero ()
Val-ⶠ(Suc VM) (Ο-suc Mâ¶N) = Val-ⶠVM Mâ¶N
-- Reduction is deterministicVal-ⶠFun ()
Val-ⶠZero ()
Val-ⶠ(Suc VM) (Ο-suc Mâ¶N) = Val-ⶠVM Mâ¶N
det : â {M Mâ² Mâ³}
â (M ⶠMâ²)
â (M ⶠMâ³)
----------
â Mâ² â¡ Mâ³
det (Ο-·â Lâ¶Lâ²) (Ο-·â Lâ¶Lâ³) = congâ _·_ (det Lâ¶Lâ² Lâ¶Lâ³) refl
det (Ο-·â Lâ¶Lâ²) (Ο-·â VL _) = â¥-elim (Val-ⶠVL Lâ¶Lâ²)
det (Ο-·â Lâ¶Lâ²) (β-â _) = â¥-elim (Val-ⶠFun Lâ¶Lâ²)
det (Ο-·â VL _) (Ο-·â Lâ¶Lâ³) = â¥-elim (Val-ⶠVL Lâ¶Lâ³)
det (Ο-·â _ Mâ¶Mâ²) (Ο-·â _ Mâ¶Mâ³) = congâ _·_ refl (det Mâ¶Mâ² Mâ¶Mâ³)
det (Ο-·â _ Mâ¶Mâ²) (β-â VM) = â¥-elim (Val-ⶠVM Mâ¶Mâ²)
det (β-â VM) (Ο-·â Lâ¶Lâ³) = â¥-elim (Val-ⶠFun Lâ¶Lâ³)
det (β-â VM) (Ο-·â _ Mâ¶Mâ³) = â¥-elim (Val-ⶠVM Mâ¶Mâ³)
det (β-â _) (β-â _) = refl
det (Ο-suc Mâ¶Mâ²) (Ο-suc Mâ¶Mâ³) = cong `suc_ (det Mâ¶Mâ² Mâ¶Mâ³)
det (Ο-pred Mâ¶Mâ²) (Ο-pred Mâ¶Mâ³) = cong `pred_ (det Mâ¶Mâ² Mâ¶Mâ³)
det (Ο-pred Mâ¶Mâ²) β-pred-zero = â¥-elim (Val-ⶠZero Mâ¶Mâ²)
det (Ο-pred Mâ¶Mâ²) (β-pred-suc VM) = â¥-elim (Val-ⶠ(Suc VM) Mâ¶Mâ²)
det β-pred-zero (Ο-pred Mâ¶Mâ²) = â¥-elim (Val-ⶠZero Mâ¶Mâ²)
det β-pred-zero β-pred-zero = refl
det (β-pred-suc VM) (Ο-pred Mâ¶Mâ²) = â¥-elim (Val-ⶠ(Suc VM) Mâ¶Mâ²)
det (β-pred-suc _) (β-pred-suc _) = refl
det (Ο-if0 Lâ¶Lâ²) (Ο-if0 Lâ¶Lâ³) = congâ `if0_then_else_ (det Lâ¶Lâ² Lâ¶Lâ³) refl
refl
det (Ο-if0 Lâ¶Lâ²) β-if0-zero = â¥-elim (Val-ⶠZero Lâ¶Lâ²)
det (Ο-if0 Lâ¶Lâ²) (β-if0-suc VL) = â¥-elim (Val-ⶠ(Suc VL) Lâ¶Lâ²)
det β-if0-zero (Ο-if0 Lâ¶Lâ³) = â¥-elim (Val-ⶠZero Lâ¶Lâ³)
det β-if0-zero β-if0-zero = refl
det (β-if0-suc VL) (Ο-if0 Lâ¶Lâ³) = â¥-elim (Val-ⶠ(Suc VL) Lâ¶Lâ³)
det (β-if0-suc _) (β-if0-suc _) = refl
det (Ο-Y Mâ¶Mâ²) (Ο-Y Mâ¶Mâ³) = cong `Y_ (det Mâ¶Mâ² Mâ¶Mâ³)
det (Ο-Y Mâ¶Mâ²) (β-Y refl) = â¥-elim (Val-ⶠFun Mâ¶Mâ²)
det (β-Y refl) (Ο-Y Mâ¶Mâ³) = â¥-elim (Val-ⶠFun Mâ¶Mâ³)
det (β-Y refl) (β-Y refl) = refl
The proof and all relevant definitions are here:â (M ⶠMâ³)
----------
â Mâ² â¡ Mâ³
det (Ο-·â Lâ¶Lâ²) (Ο-·â Lâ¶Lâ³) = congâ _·_ (det Lâ¶Lâ² Lâ¶Lâ³) refl
det (Ο-·â Lâ¶Lâ²) (Ο-·â VL _) = â¥-elim (Val-ⶠVL Lâ¶Lâ²)
det (Ο-·â Lâ¶Lâ²) (β-â _) = â¥-elim (Val-ⶠFun Lâ¶Lâ²)
det (Ο-·â VL _) (Ο-·â Lâ¶Lâ³) = â¥-elim (Val-ⶠVL Lâ¶Lâ³)
det (Ο-·â _ Mâ¶Mâ²) (Ο-·â _ Mâ¶Mâ³) = congâ _·_ refl (det Mâ¶Mâ² Mâ¶Mâ³)
det (Ο-·â _ Mâ¶Mâ²) (β-â VM) = â¥-elim (Val-ⶠVM Mâ¶Mâ²)
det (β-â VM) (Ο-·â Lâ¶Lâ³) = â¥-elim (Val-ⶠFun Lâ¶Lâ³)
det (β-â VM) (Ο-·â _ Mâ¶Mâ³) = â¥-elim (Val-ⶠVM Mâ¶Mâ³)
det (β-â _) (β-â _) = refl
det (Ο-suc Mâ¶Mâ²) (Ο-suc Mâ¶Mâ³) = cong `suc_ (det Mâ¶Mâ² Mâ¶Mâ³)
det (Ο-pred Mâ¶Mâ²) (Ο-pred Mâ¶Mâ³) = cong `pred_ (det Mâ¶Mâ² Mâ¶Mâ³)
det (Ο-pred Mâ¶Mâ²) β-pred-zero = â¥-elim (Val-ⶠZero Mâ¶Mâ²)
det (Ο-pred Mâ¶Mâ²) (β-pred-suc VM) = â¥-elim (Val-ⶠ(Suc VM) Mâ¶Mâ²)
det β-pred-zero (Ο-pred Mâ¶Mâ²) = â¥-elim (Val-ⶠZero Mâ¶Mâ²)
det β-pred-zero β-pred-zero = refl
det (β-pred-suc VM) (Ο-pred Mâ¶Mâ²) = â¥-elim (Val-ⶠ(Suc VM) Mâ¶Mâ²)
det (β-pred-suc _) (β-pred-suc _) = refl
det (Ο-if0 Lâ¶Lâ²) (Ο-if0 Lâ¶Lâ³) = congâ `if0_then_else_ (det Lâ¶Lâ² Lâ¶Lâ³) refl
refl
det (Ο-if0 Lâ¶Lâ²) β-if0-zero = â¥-elim (Val-ⶠZero Lâ¶Lâ²)
det (Ο-if0 Lâ¶Lâ²) (β-if0-suc VL) = â¥-elim (Val-ⶠ(Suc VL) Lâ¶Lâ²)
det β-if0-zero (Ο-if0 Lâ¶Lâ³) = â¥-elim (Val-ⶠZero Lâ¶Lâ³)
det β-if0-zero β-if0-zero = refl
det (β-if0-suc VL) (Ο-if0 Lâ¶Lâ³) = â¥-elim (Val-ⶠ(Suc VL) Lâ¶Lâ³)
det (β-if0-suc _) (β-if0-suc _) = refl
det (Ο-Y Mâ¶Mâ²) (Ο-Y Mâ¶Mâ³) = cong `Y_ (det Mâ¶Mâ² Mâ¶Mâ³)
det (Ο-Y Mâ¶Mâ²) (β-Y refl) = â¥-elim (Val-ⶠFun Mâ¶Mâ²)
det (β-Y refl) (Ο-Y Mâ¶Mâ³) = â¥-elim (Val-ⶠFun Mâ¶Mâ³)
det (β-Y refl) (β-Y refl) = refl
https://wenkokke.github.io/sf/Typed
Almost half the lines in the above proof are redundant, for example
det (Ο-·â Lâ¶Lâ²) (Ο-·â VL _) = â¥-elim (Val-ⶠVL Lâ¶Lâ²)
det (Ο-·â VL _) (Ο-·â Lâ¶Lâ³) = â¥-elim (Val-ⶠVL Lâ¶Lâ³)
are essentially identical.What I would like to do is delete the redundant lines and add
det Mâ¶Mâ² Mâ¶Mâ³ = sym (det Mâ¶Mâ³ Mâ¶Mâ²)
to the bottom of the proof. But, of course, the termination checker
complains.
How can I rewrite the proof to exploit symmetry? Cheers, -- P
. \ Philip Wadler, Professor of Theoretical Computer Science,
. /\ School of Informatics, University of Edinburgh
. / \ and Senior Research Fellow, IOHK
. http://homepages.inf.ed.ac.uk/wadler/