core.logic

Allow tying multiple noms in one binder

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:

Description

I think it may be useful to be able to tie multiple noms in one binder, with or without significant order.

A couple use cases I've thought of so far:

Lambdas in a non-currying language. Here order matters.

(== (list 'fn (ties [x y] (list '+ x y)))
    (list 'fn (ties [z w] (list '+ z w)))

My original use case, free/quantified variables in logical formulas. Order doesn't matter (note the second body has its noms swapped).

(== (list '∀ (ties #{x y} (list '= (list '+ x y) (list '+ y x))))
    (list '∀ (ties #{z w} (list '= (list '+ w z) (list '+ z w)))))

I have a draft implementation here: https://github.com/tomjack/core.logic/compare/ties

Possible issues with this implementation:

  • Is it OK to reextend IWalkTerm to IPersistentSet?
  • Should Tie and Ties present a uniform interface? (e.g. (tie? (ties #{x} x)))

Activity

Hide
David Nolen added a comment -

I really don't think the set bit is necessary, the vector syntax is fine. Also avoid needing to bring IWalkTerm back for sets. And yes, tie? should work in either case.

Show
David Nolen added a comment - I really don't think the set bit is necessary, the vector syntax is fine. Also avoid needing to bring IWalkTerm back for sets. And yes, tie? should work in either case.
Hide
Tom Jack added a comment - - edited

Hmm.. should:

(== (list 'fn (ties [x y] (list '- x y)))
    (list 'fn (ties [z w] (list '- w z)))

I'd think not.

Do you mean that order should always matter (take out the permutations stuff), or that it should never matter (don't use ties for cases like the above)?

Show
Tom Jack added a comment - - edited Hmm.. should:
(== (list 'fn (ties [x y] (list '- x y)))
    (list 'fn (ties [z w] (list '- w z)))
I'd think not. Do you mean that order should always matter (take out the permutations stuff), or that it should never matter (don't use ties for cases like the above)?
Tom Jack made changes -
Field Original Value New Value
Description I think it may be useful to be able to tie multiple noms in one binder, with or without significant order.

A few use cases I've thought of so far:

Lambdas in a non-currying language. Here order matters.
{code}
(== (list 'fn (ties [x y] (list '+ x y)))
    (list 'fn (ties [z w] (list '+ z w)))
{code}

Choice in CSP. Order matters.
{code}
(== (list 'choice (ties [x y] {x (p a) y (q b)})
    (list 'choice (ties [z w] {z (p z) w (q w)}))
{code}

My original use case, free/quantified variables in logical formulas. Order doesn't matter (note the second body has its noms swapped).
{code}
(== (list '∀ (ties #{x y} (list '= (list '+ x y) (list '+ y x))))
    (list '∀ (ties #{z w} (list '= (list '+ w z) (list '+ z w)))))
{code}


I have a draft implementation here: https://github.com/tomjack/core.logic/compare/ties

Possible issues with this implementation:
- Is it OK to reextend IWalkTerm to IPersistentSet?
- Should Tie and Ties present a uniform interface? (e.g. (tie? (ties #{x} x)))
I think it may be useful to be able to tie multiple noms in one binder, with or without significant order.

A couple use cases I've thought of so far:

Lambdas in a non-currying language. Here order matters.
{code}
(== (list 'fn (ties [x y] (list '+ x y)))
    (list 'fn (ties [z w] (list '+ z w)))
{code}

My original use case, free/quantified variables in logical formulas. Order doesn't matter (note the second body has its noms swapped).
{code}
(== (list '∀ (ties #{x y} (list '= (list '+ x y) (list '+ y x))))
    (list '∀ (ties #{z w} (list '= (list '+ w z) (list '+ z w)))))
{code}


I have a draft implementation here: https://github.com/tomjack/core.logic/compare/ties

Possible issues with this implementation:
- Is it OK to reextend IWalkTerm to IPersistentSet?
- Should Tie and Ties present a uniform interface? (e.g. (tie? (ties #{x} x)))
Hide
David Nolen added a comment -

Ah hm, good point. Will think on it some more.

Show
David Nolen added a comment - Ah hm, good point. Will think on it some more.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated: