math. programming. fancy types. https://xitter.cf/t.co/nKsFcMkMhO https://xitter.cf/t.co/SGl0uvAoGb
- Tweets2.7K
- Following414
- Followers62
- Likes4.1K
![-- type Decision :: * -> * -- data Decision a = Proved a | Disproved (Refuted a) -- type Refuted :: * -> * -- type Refuted a = a -> Void -- A term of this type proves that a is empty. decideIsElem' :: (SDecide k) => Sing (x :: k) -> Sing (xs :: [k]) -> Decision (IsElem x xs) decideIsElem' x = \case SNil -> Disproved $ \i -> case i of -- There can of course be no proof of x being in [], so the empty -- case expression serves to define a(n empty) function from an -- empty type to Void. (SCons y ys) -> case x %~ y of Disproved d -> case decideIsElem' x ys of Disproved d' -> Disproved $ f d d' Proved i -> Proved $ IsElemTail i Proved i -> Proved $ IsElemHead i where -- This his how we merge a proof that x is not y and x is not in ys -- into a proof that x is not in (y : ys). f :: Refuted (x :~: y)](https://pbs.twimg.com/media/FglUrQyWQAM7ipa.png?name=small&format=webp)
ALT -- type Decision :: * -> * -- data Decision a = Proved a | Disproved (Refuted a) -- type Refuted :: * -> * -- type Refuted a = a -> Void -- A term of this type proves that a is empty. decideIsElem' :: (SDecide k) => Sing (x :: k) -> Sing (xs :: [k]) -> Decision (IsElem x xs) decideIsElem' x = \case SNil -> Disproved $ \i -> case i of -- There can of course be no proof of x being in [], so the empty -- case expression serves to define a(n empty) function from an -- empty type to Void. (SCons y ys) -> case x %~ y of Disproved d -> case decideIsElem' x ys of Disproved d' -> Disproved $ f d d' Proved i -> Proved $ IsElemTail i Proved i -> Proved $ IsElemHead i where -- This his how we merge a proof that x is not y and x is not in ys -- into a proof that x is not in (y : ys). f :: Refuted (x :~: y)

ALT disjAssoc :: Sing a -> Sing b -> Sing c -> ((a || b) || c) :~: (a || (b || c)) disjAssoc STrue STrue STrue = Refl disjAssoc SFalse STrue STrue = Refl disjAssoc STrue SFalse STrue = Refl disjAssoc SFalse SFalse STrue = Refl disjAssoc STrue SFalse SFalse = Refl disjAssoc SFalse SFalse SFalse = Refl disjAssoc STrue STrue SFalse = Refl disjAssoc SFalse STrue SFalse = Refl







