Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is ∀? #12

Open
daveloyall opened this issue Jun 30, 2015 · 6 comments
Open

What is ∀? #12

daveloyall opened this issue Jun 30, 2015 · 6 comments
Labels

Comments

@daveloyall
Copy link

...And other symbols found in http://enigma.media.mit.edu/enigma_full.pdf ?

@LOZORD
Copy link

LOZORD commented Jun 30, 2015

It usually means for all. A backwards 'E' means for some or there exists.
For a set S = { s1, s2, s3 ..., sn }:
For all <stmt> in S can be represented as stmt(s1) AND stmt(s2) AND stmt(s3) AND ... AND stmt(sn)
For some <stmt> in S can be represented as stmt(s1) OR stmt(s2) OR stmt(s3) OR ... OR stmt(sn)
Here's the code I would propose:

/* 
elements: a set (Array) of things
predicate: a function that takes one or more things from elements and returns true or false
*/
function forAll (elements, predicate) {
  return elements.every(predicate);
}

//And for backwards 'E' (existence)
function forSome (elements, predicate) {
  return elements.some(predicate);
}

It's nice that we can simply use functions already provided by JS! (Although it might be easier to do others in Haskell 😎)

Any other specific ones you want explained?

@pirate
Copy link

pirate commented Jun 30, 2015

You should pull-request this so it's included in the main list.

@StoneCypher
Copy link

Programmers will generally think of the existential quantifier ∃ &exist; as "functional any."

Because JavaScript is required by law to get nothing right ever, JavaScript calls this some.

var isOdd = function(X) { return (x%2); },
    Example = [2,4,6,7];

window.alert(Example.some(isOdd));

@LOZORD
Copy link

LOZORD commented Jul 1, 2015

Working on a PR now... plan to push in the next few days. I hope to include Set notation/theory as well.

@daveloyall I saw some statistical distribution notation in that article you shared. Would you like that explained as well?

@daveloyall
Copy link
Author

@LOZORD sure, though I don't suggest prioritizing it on my behalf. That paper was just something I had on my screen at the moment I discovered this math-as-code project. ...There was some other paper that I care more about, I'll try to find it. Something like "Category Theory for Computer Scientists". Using this project, perhaps we can turn that paper into "Category Theory for Industry Programmers". :)

@allo-
Copy link

allo- commented Jul 1, 2015

\Forall i \in X: Y(i) can be seen as

for i in X:
    assert Y(i)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants