Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any connection between `a :~: b` and `(a :== b) :~: True`?

Is there any connection implemented between propositional and promoted equality?

Let's say I have

prf :: x :~: y

in scope for some Symbols; by pattern matching on it being Refl, I can transform that into

prf' :: (x :== y) :~: True

like this:

fromProp :: (KnownSymbol x, KnownSymbol y) => x :~: y -> (x :== y) :~: True
fromProp Refl = Refl

But what about the other direction? If I try

toProp :: (KnownSymbol x, KnownSymbol y) => (x :== y) :~: True -> x :~: y
toProp Refl = Refl

then all I get is

• Could not deduce: x ~ y
  from the context: 'True ~ (x :== y)
like image 942
Cactus Avatar asked Jun 20 '16 13:06

Cactus


People also ask

What does a B testing stand for?

In A/B testing, A refers to 'control' or the original testing variable. Whereas B refers to 'variation' or a new version of the original testing variable. The version that moves your business metric(s) in the positive direction is known as the 'winner.

What is an a B test in marketing?

A/B testing, also known as split testing, is a marketing experiment wherein you split your audience to test a number of variations of a campaign and determine which performs better. In other words, you can show version A of a piece of marketing content to one half of your audience, and version B to another.

What is an example of a B testing?

For example, you might send two versions of an email to your customer list (randomizing the list first, of course) and figure out which one generates more sales. Then you can just send out the winning version next time. Or you might test two versions of ad copy and see which one converts visitors more often.

What are a B tests on Facebook?

One of the most popular tools Facebook offers is A/B testing. A/B testing, or split testing, is a term used to describe the process of running marketing experiments to see which version connects better with your audience.


1 Answers

Yes, going between the two representations is possible (assuming the implementation of :== is correct), but it requires computation.

The information you need is not present in the Boolean itself (it's been erased to a single bit); you have to recover it. This involves interrogating the two participants of the original Boolean equality test (which means you have to keep them around at runtime), and using your knowledge of the result to eliminate the impossible cases. It's rather tedious to re-perform a computation for which you already know the answer!

Working in Agda, and using naturals instead of strings (because they're simpler):

open import Data.Nat
open import Relation.Binary.PropositionalEquality
open import Data.Bool

_==_ : ℕ -> ℕ -> Bool
zero == zero = true
suc n == suc m = n == m
_ == _ = false

==-refl : forall n -> (n == n) ≡ true
==-refl zero = refl
==-refl (suc n) = ==-refl n


fromProp : forall {n m} -> n ≡ m -> (n == m) ≡ true
fromProp {n} refl = ==-refl n

-- we have ways of making you talk
toProp : forall {n m} -> (n == m) ≡ true -> n ≡ m
toProp {zero} {zero} refl = refl
toProp {zero} {suc m} ()
toProp {suc n} {zero} ()
toProp {suc n} {suc m} p = cong suc (toProp {n}{m} p)

In principle I think you could make this work in Haskell using singletons, but why bother? Don't use Booleans!

like image 61
Benjamin Hodgson Avatar answered Oct 14 '22 12:10

Benjamin Hodgson