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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python eDSL #217

Open
munro opened this issue Jul 14, 2022 · 1 comment
Open

Python eDSL #217

munro opened this issue Jul 14, 2022 · 1 comment

Comments

@munro
Copy link

munro commented Jul 14, 2022

It would be really nice if there was a Python eDSL so that I could write queries in Python, which I have much better tooling for. 馃槃

@munro
Copy link
Author

munro commented Sep 8, 2022

perhaps something like this 馃ゲ

import logica as lg
from logica import var, rule

# Define natural numbers from 1 to 29.
N = rule("N", var.x).body(
    var.x.in_(lg.range(30))
)

# Define primes.
Prime = rule("Prime", prime=var.x).body(
    N(var.x),
    var.x > 1,
    lg.not_(
        N(var.y),
        var.y > 1,
        var.y != var.x,
        var.x % var.y == 0
    )
)
# Define natural numbers from 1 to 29.
N(x) :- x in Range(30);
# Define primes.
Prime(prime: x) :-
  N(x),
  x > 1,
  ~(
    N(y),
    y > 1,
    y != x,
    x % y == 0
  );

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

No branches or pull requests

1 participant