GithubHelp home page GithubHelp logo

datalog's Issues

Add data to an existing database

The tests demonstrate how to make a database from scratch and query it. But what if you wanted to add a relationship to an existing database, or assert that a relationship holds for a new tuple?

Multiple Inference Predicates

where 
    q = do
      use <- relationPredicateFromName "use" 
      def <- relationPredicateFromName "def" 
      succ <- relationPredicateFromName "succ" 
      live <- inferencePredicate "live"
      live2 <- inferencePredicate "live2"
      let l  = LogicVar "l"
          l' = LogicVar "l'"
          t  = LogicVar "t"
          t' = LogicVar "t'"
      (live, [l,t]) |- [ lit use [l,t] ]
      (live, [l,t]) |- [ lit live [l',t]
                       , lit succ [l, l']
                       , negLit def [l, t] ]
      (live2, [l,t]) |- [ lit live [l,t] ]
      issueQuery live2 [l,t]

Hi there, I seem to be having some trouble with inference predicates that require other inference predicates. In the above code, if I issue the query for live instead of live2 everything works fine, and it actually generates liveness. If, however, I query for live2, the database produces nothing. Any idea as why this might be?

Hackage?

Are you intending to put this on hackage?

Can the same variable not appear twice in a literal?

I ask because the README says "Rewrite literals like f(X,X) into f(X,Y), X=Y. A few internals assume that the same variable doesn't appear twice in a literal" -- but it says that under "Planned Enhancements", as opposed to (a hypothetical section called) "instructions to the user".

RangeRestrictionViolation for literal in head

The following code generates a RangeRestrictionViolation in the MagicSets transformation

db2 :: Maybe (Database Text)
db2 = makeDatabase $ do
      stateRel <- addRelation "state" 2
      let facts :: [[Text]]
          facts = [ [ "b", "z" ]
                  ]
      mapM_ (assertFact stateRel) facts

tq3 :: IO ()
tq3 = do
  let Just db = db2
      q = do
        stateRel <- relationPredicateFromName "state"
        toggle <- inferencePredicate "toggle"
        let x = LogicVar "x"
            y = LogicVar "y"
        (toggle, [Atom "a", y]) |- [ lit stateRel [Atom "b", y] ]
        (toggle, [Atom "b", y]) |- [ lit stateRel [Atom "a", y] ]
        issueQuery toggle [x, y ]

  res <- queryDatabase db q
  putStrLn ("res=" ++ (show res))

FYI, I am trying to capture the following rules

toggle(1, T) :- state(0, T). toggle(0, T) :- state(1, T).

Querying data?

How do you query with the REPL?

chris@retina:~/Projects/datalog$ datalog-repl 
% human(chris).
% :facts
human(chris).
% ?human(X).
Query result:
datalog-repl: No rules for pattern

@pchiusano does your version support this?

Needs old libraries? [solution: delete bounds in Cabal file, then use Stack as normal]

I built it with Stack instead of Cabal. Stack seems to think it needs a really old resolver:

jeff@jbb-lenovo:~/code/datalog$ stack init
Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- datalog.cabal

Selecting the best among 11 snapshots...

* Partially matches lts-9.9
    transformers version 0.5.2.0 found
        - datalog requires >=0.3 && <0.5
    vector version 0.12.0.1 found
        - datalog requires >=0.9 && <0.11

* Partially matches nightly-2017-10-21
    transformers version 0.5.2.0 found
        - datalog requires >=0.3 && <0.5
    vector version 0.12.0.1 found
        - datalog requires >=0.9 && <0.11

* Partially matches lts-8.24
    transformers version 0.5.2.0 found
        - datalog requires >=0.3 && <0.5
    vector version 0.11.0.0 found
        - datalog requires >=0.9 && <0.11

* Partially matches lts-7.24
    transformers version 0.5.2.0 found
        - datalog requires >=0.3 && <0.5
    vector version 0.11.0.0 found
        - datalog requires >=0.9 && <0.11

* Partially matches lts-6.35
    vector version 0.11.0.0 found
        - datalog requires >=0.9 && <0.11

* Partially matches lts-5.18
    vector version 0.11.0.0 found
        - datalog requires >=0.9 && <0.11

* Partially matches lts-4.2
    vector version 0.11.0.0 found
        - datalog requires >=0.9 && <0.11

* Matches lts-3.22

Selected resolver: lts-3.22
Initialising configuration using resolver: lts-3.22
Total number of user packages considered: 1
Writing configuration to file: stack.yaml
All done.
jeff@jbb-lenovo:~/code/datalog$ 

I would like to use it in a project with more recent dependencies. Is there a way?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.