Created
July 19, 2024 22:53
-
-
Save freddi301/8df643092016284492e52db0e53400c3 to your computer and use it in GitHub Desktop.
Example of idempotent function and related proof
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Idempotent (action : stateType -> stateType) where | |
law : (state : stateType) -> let u = action state in action u = u | |
IncFrom : Nat -> Nat -> Nat | |
IncFrom original state = case decEq state original of | |
Yes _ => S state | |
No _ => state | |
{o : Nat} -> Idempotent (IncFrom o) where | |
law s with (decEq s o) | |
_ | Yes p with (decEq (S s) o) | (p) | |
_ | No _ | Refl = Refl | |
_ | (No p) = rewrite snd $ decEqContraIsNo p in Refl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment