[julia-users] Re: Representation of a material conditional (implication)

2016-10-08 Thread Kevin Liu
Thanks Fengyang On Saturday, October 8, 2016 at 12:39:42 AM UTC-3, Fengyang Wang wrote: > > As Jussi Piitulainen noted, the ^ operator is backwards, so you need to > wrap it around a function. > > On Friday, October 7, 2016 at 10:05:34 AM UTC-4, Kevin Liu wrote: >> >> *julia> **@code_native(b^a)*

[julia-users] Re: Representation of a material conditional (implication)

2016-10-07 Thread Fengyang Wang
As Jussi Piitulainen noted, the ^ operator is backwards, so you need to wrap it around a function. On Friday, October 7, 2016 at 10:05:34 AM UTC-4, Kevin Liu wrote: > > *julia> **@code_native(b^a)* > >.section__TEXT,__text,regular,pure_instructions > > Filename: bool.jl > > Source

[julia-users] Re: Representation of a material conditional (implication)

2016-10-07 Thread Kevin Liu
*julia> **@code_native(b^a)* .section__TEXT,__text,regular,pure_instructions Filename: bool.jl Source line: 39 pushq %rbp movq%rsp, %rbp Source line: 39 xorb$1, %sil orb %dil, %sil movb%sil, %al popq%rbp

[julia-users] Re: Representation of a material conditional (implication)

2016-10-07 Thread Kevin Liu
*julia> **@code_llvm(b^a)* define i1 @"julia_^_21646"(i1, i1) { top: %2 = xor i1 %1, true %3 = or i1 %0, %2 ret i1 %3 } On Friday, October 7, 2016 at 10:56:26 AM UTC-3, Kevin Liu wrote: > > Sorry, no need, I got this > > *julia> **@code_llvm(a<=b)* > > > define i1 @"julia_<=_21637"

[julia-users] Re: Representation of a material conditional (implication)

2016-10-07 Thread Kevin Liu
Sorry, no need, I got this *julia> **@code_llvm(a<=b)* define i1 @"julia_<=_21637"(i1, i1) { top: %2 = xor i1 %0, true %3 = or i1 %1, %2 ret i1 %3 } *julia> **@code_llvm(ifelse(a,b,true))* define i1 @julia_ifelse_21636(i1, i1, i1) { top: %3 = select i1 %0, i1 %1, i1 %2 ret

[julia-users] Re: Representation of a material conditional (implication)

2016-10-07 Thread Kevin Liu
Jeffrey, can you show the expression you put inside @code_llvm() and @code_native() for evaluation? On Friday, October 7, 2016 at 2:26:56 AM UTC-3, Jeffrey Sarnoff wrote: > > Hi Jussi, > > Your version compiles down more neatly than the ifelse version. On my > system, BenchmarkTools gives nearl

[julia-users] Re: Representation of a material conditional (implication)

2016-10-07 Thread Jussi Piitulainen
Indeed. implies(p::Bool, q::Bool) = q^p perjantai 7. lokakuuta 2016 10.25.06 UTC+3 Fengyang Wang kirjoitti: > > The ^ operator can be used for implication. Due to Curry-Howard, > implication is isomorphic to function abstraction, which combinatorially > can be counted using the exponentiatio

[julia-users] Re: Representation of a material conditional (implication)

2016-10-07 Thread Fengyang Wang
The ^ operator can be used for implication. Due to Curry-Howard, implication is isomorphic to function abstraction, which combinatorially can be counted using the exponentiation function. On Thursday, October 6, 2016 at 12:10:51 PM UTC-4, Kevin Liu wrote: > > How is an implication represented in

[julia-users] Re: Representation of a material conditional (implication)

2016-10-06 Thread Jeffrey Sarnoff
Hi Jussi, Your version compiles down more neatly than the ifelse version. On my system, BenchmarkTools gives nearly identical results; I don't know why, but the ifelse version is consistently a smidge faster (~%2, relative speed). Here is the llvm code and local native code for each, your versi

[julia-users] Re: Representation of a material conditional (implication)

2016-10-06 Thread Jussi Piitulainen
implies(p::Bool, q::Bool) = p <= q torstai 6. lokakuuta 2016 19.10.51 UTC+3 Kevin Liu kirjoitti: > > How is an implication represented in Julia? > > > https://en.wikipedia.org/wiki/Material_conditional#Definitions_of_the_material_conditional >

Re: [julia-users] Re: Representation of a material conditional (implication)

2016-10-06 Thread Kevin Liu
That's awesome, thank you. > On Oct 6, 2016, at 17:54, Jeffrey Sarnoff wrote: > > Peter Norvig's book+site is a very good learning tool. > > by the way: if you are using OSX or Linux and have your terminal using a font > with decent unicode coverage, > `\Rightarrow` followed by TAB turns i

[julia-users] Re: Representation of a material conditional (implication)

2016-10-06 Thread Jeffrey Sarnoff
Peter Norvig's book+site is a very good learning tool. by the way: if you are using OSX or Linux and have your terminal using a font with decent unicode coverage, `\Rightarrow` followed by TAB turns into `⇒`, which is the generally accepted symbol for material implication. ⇒(p::Bool, q::Bool

[julia-users] Re: Representation of a material conditional (implication)

2016-10-06 Thread Kevin Liu
Thanks for the distinction, Jeffrey. Also, look what I found https://github.com/aimacode. Julia is empty :-). Can we hire some Martians to fill it up as we have ran out of Julians on Earth? I'm happy I found this though. On Thursday, October 6, 2016 at 5:26:43 PM UTC-3, Jeffrey Sarnoff wrote:

[julia-users] Re: Representation of a material conditional (implication)

2016-10-06 Thread Jeffrey Sarnoff
you are welcome to use implies(p::Bool, q::Bool) = !p | q { !p, ~p likely compile to the same instructions -- they do for me; you might prefer to use of !p here as that means 'logical_not(p)' where ~p means 'flip_the_bits_of(p)' } I find that this form is also 40% slower than the ifelse form

[julia-users] Re: Representation of a material conditional (implication)

2016-10-06 Thread Kevin Liu
Sorry, julia> ~p|q true On Thursday, October 6, 2016 at 5:11:55 PM UTC-3, Kevin Liu wrote: > > Is this why I couldn't find implication in Julia? > > Maybe it was considered redundant because (1) it is less primitive than >> "^", "v", "~", (2) it saves very little typing since "A => B" is eq

[julia-users] Re: Representation of a material conditional (implication)

2016-10-06 Thread Kevin Liu
Is this why I couldn't find implication in Julia? Maybe it was considered redundant because (1) it is less primitive than > "^", "v", "~", (2) it saves very little typing since "A => B" is equivalent > to "~A v B". – Giorgio > Jan 18 '

[julia-users] Re: Representation of a material conditional (implication)

2016-10-06 Thread Jeffrey Sarnoff
(the version using ifelse benchmarks faster on my system) On Thursday, October 6, 2016 at 3:05:50 PM UTC-4, Jeffrey Sarnoff wrote: > > here are two ways > > implies(p::Bool, q::Bool) = !(p & !q) > > implies(p::Bool, q::Bool) = ifelse(p, q, true) > > > > > On Thursday, October 6, 2016 at 12:10:51 P

[julia-users] Re: Representation of a material conditional (implication)

2016-10-06 Thread Jeffrey Sarnoff
here are two ways implies(p::Bool, q::Bool) = !(p & !q) implies(p::Bool, q::Bool) = ifelse(p, q, true) On Thursday, October 6, 2016 at 12:10:51 PM UTC-4, Kevin Liu wrote: > > How is an implication represented in Julia? > > > https://en.wikipedia.org/wiki/Material_conditional#Definitions_of_t