# \[ANN\]: Abstract Logic Solver for Julia - AbstractLogic.jl

**URL:** <https://discourse.julialang.org/t/ann-abstract-logic-solver-for-julia-abstractlogic-jl/29134>\
**Category:** Package Announcements\
**Tags:** package, announcement\
**Created:** [September 24, 2019, 9:01pm UTC](https://discourse.julialang.org/t/ann-abstract-logic-solver-for-julia-abstractlogic-jl/29134 "2019-09-24T21:01:12Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![EconometricsBySimula](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/econometricsbysimula/32/1255_2.png) [@EconometricsBySimula](https://discourse.julialang.org/u/EconometricsBySimula)\
**Post date:** [September 24, 2019, 9:01pm UTC](https://discourse.julialang.org/t/ann-abstract-logic-solver-for-julia-abstractlogic-jl/29134/1 "2019-09-24T21:01:12Z")

</div>

I would love any feedback people might have. I have spent a lot of time refining the package and making it potentially useful. I see it as a ready tool for solving, validating, and providing the basis for generating abstract reasoning problems.

Find it at: [GitHub - EconometricsBySimulation/AbstractLogic.jl: An Abstract Reasoning Logic Interface](https://github.com/EconometricsBySimulation/AbstractLogic.jl)

From the README.md

## A Simple Example

A typical kind of problem which one might have encountered in an aptitude test  
at some point in ones life might look like the following.

```julia-auto
Peter is younger than Susan. Sam is younger than Susan but older than Ali.
Li is older than Ali younger than Peter.

Who must be the oldest?
a) Peter b) Susan c) Sam d) Li e) Ali f) Cannot Tell

Who must be the youngest?
a) Peter b) Susan c) Sam d) Li e) Ali f) Cannot Tell

Who could be the same age as Li?
a) Peter b) Susan c) Sam d) Ali e) Nobody f) Cannot Tell

```

The package AbstractLogic provides a tool for easily evaluating such problems.  
First lets load in the feasible matches. Because there are 5 people in the  
problem we can assign them 5 age categories which represent cardinal ordered  
ages.

```julia
julia> using AbstractLogic
Start the repl in command prompt by typing `=`.

abstractlogic> Peter, Susan, Sam, Li, Ali ∈ 1, 2, 3, 4, 5
Peter, Susan, Sam, Li, Ali ∈ 1, 2, 3, 4, 5 feasible outcomes 3125 ✓ :4 2 4 3 4

abstractlogic> Peter < Susan; Sam < Susan
Peter < Susan feasible outcomes 1250 ✓ :2 3 3 4 4
Sam < Susan feasible outcomes 750 ✓ :4 5 4 5 4

abstractlogic> Sam > Ali; Li > Ali; Li < Peter
Sam > Ali feasible outcomes 175 ✓ :1 3 2 3 1
Li > Ali feasible outcomes 121 ✓ :4 5 2 5 1
Li < Peter feasible outcomes 13 ✓ :4 5 4 3 2

abstractlogic> search {{i}} > {{!i}}
Checking: Peter > Susan
Checking: Peter > Sam
...
Checking: Ali > Sam
Checking: Ali > Li

:Peter is a not match with 0 feasible combinations out of 13.
:Susan is a match with 13 feasible combinations out of 13.
:Sam is a not match with 0 feasible combinations out of 13.
:Li is a not match with 0 feasible combinations out of 13.
:Ali is a not match with 0 feasible combinations out of 13.

```

## More Interesting Examples

The best way to see the functionality of `AbstractLogic` is to see it in action.

[_Snape’s_ potions problem in J.K. Rowling’s “Harry Potter”](https://github.com/EconometricsBySimulation/AbstractLogic.jl/blob/master/examples/repl/harrypotter.jl)

[June LSAC 2007 by the Law School Admission Council q1-5](https://github.com/EconometricsBySimulation/AbstractLogic.jl/blob/master/examples/repl/LSATlogicalQ1.jl)

[June LSAC 2007 by the Law School Admission Council q6-10](https://github.com/EconometricsBySimulation/AbstractLogic.jl/blob/master/examples/repl/LSATlogicalQ2.jl)

[June LSAC 2007 by the Law School Admission Council q11-17](https://github.com/EconometricsBySimulation/AbstractLogic.jl/blob/master/examples/repl/LSATlogicalQ3.jl)

---

<div class="post-metadata">

**Author:** ![StevenSiew](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevensiew/32/218393_2.png) [@StevenSiew](https://discourse.julialang.org/u/StevenSiew)\
**Post date:** [September 25, 2019, 6:53am UTC](https://discourse.julialang.org/t/ann-abstract-logic-solver-for-julia-abstractlogic-jl/29134/2 "2019-09-25T06:53:48Z")

</div>

> [@EconometricsBySimula](#):
>
> AbstractLogic

```julia
julia> 
$ julia
               _
   _ _ _(_)_ | Documentation: https://docs.julialang.org
  (_) | (_) (_) |
   _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _ | |
  | | |_| | | | (_| | | Version 1.2.0 (2019-08-20)
 _/ |\ ___|_|_|\__ _| | Official https://julialang.org/ release
|__/ |

(v1.2) pkg> add AbstractLogic
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
ERROR: The following package names could not be resolved:
 * AbstractLogic (not found in project, manifest or registry)
Please specify by known `name=uuid`.

```

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [September 25, 2019, 7:03am UTC](https://discourse.julialang.org/t/ann-abstract-logic-solver-for-julia-abstractlogic-jl/29134/3 "2019-09-25T07:03:38Z")

</div>

It is not registered.

```julia
pkg> add https://github.com/EconometricsBySimulation/AbstractLogic.jl

```

---

<div class="post-metadata">

**Author:** ![EconometricsBySimula](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/econometricsbysimula/32/1255_2.png) [@EconometricsBySimula](https://discourse.julialang.org/u/EconometricsBySimula)\
**Post date:** [September 25, 2019, 3:57pm UTC](https://discourse.julialang.org/t/ann-abstract-logic-solver-for-julia-abstractlogic-jl/29134/4 "2019-09-25T15:57:23Z")

</div>

I am not sure what the standards for publishing a registered package were or not. I would be happy to publish it. I have been holding off as I considered it in alpha testing mode.

Suggestions?

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [September 25, 2019, 5:30pm UTC](https://discourse.julialang.org/t/ann-abstract-logic-solver-for-julia-abstractlogic-jl/29134/5 "2019-09-25T17:30:31Z")

</div>

Alpha testing is a little early, you want to be confident that users will find it works, for the most part (so Beta). The quickest route is through writing tests that cover what you want to be sure works.

---

<div class="post-metadata">

**Author:** ![EconometricsBySimula](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/econometricsbysimula/32/1255_2.png) [@EconometricsBySimula](https://discourse.julialang.org/u/EconometricsBySimula)\
**Post date:** [September 25, 2019, 6:09pm UTC](https://discourse.julialang.org/t/ann-abstract-logic-solver-for-julia-abstractlogic-jl/29134/6 "2019-09-25T18:09:28Z")

</div>

I think I have pretty good coverage of core features with my [tests](https://github.com/EconometricsBySimulation/AbstractLogic.jl/tree/master/test). I probably need to expand them to cover more though.

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [September 25, 2019, 7:01pm UTC](https://discourse.julialang.org/t/ann-abstract-logic-solver-for-julia-abstractlogic-jl/29134/7 "2019-09-25T19:01:17Z")

</div>

I think this package is definitely at a point where it can be registered if it has automated testing enabled.

---

<div class="post-metadata">

**Author:** ![jonathanBieler](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jonathanBieler](https://discourse.julialang.org/u/jonathanBieler)\
**Post date:** [September 25, 2019, 7:46pm UTC](https://discourse.julialang.org/t/ann-abstract-logic-solver-for-julia-abstractlogic-jl/29134/8 "2019-09-25T19:46:04Z")

</div>

You want to setup automated testing, test coverage and doc building and add the badges in the readme.

For the doc iirc it will be automatically hosted on [https://pkg.julialang.org/docs/](https://pkg.julialang.org/docs/) once registered, e.g. this minimal config file is sufficient to get your doc to [work](https://github.com/JuliaIO/ConfParser.jl/blob/master/.travis.yml).

Otherwise this is up-to-date I think (there’s the commands for test coverage) : [https://github.com/JuliaLang/Example.jl/blob/master/.travis.yml](https://github.com/JuliaLang/Example.jl/blob/master/.travis.yml)

You’ll also need to create accounts on [travis-ci.org](http://travis-ci.org) and coveralls to activate your repo.

---

<div class="post-metadata">

**Author:** ![EconometricsBySimula](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/econometricsbysimula/32/1255_2.png) [@EconometricsBySimula](https://discourse.julialang.org/u/EconometricsBySimula)\
**Post date:** [September 25, 2019, 8:14pm UTC](https://discourse.julialang.org/t/ann-abstract-logic-solver-for-julia-abstractlogic-jl/29134/9 "2019-09-25T20:14:15Z")

</div>

Travis CI is giving me this error. Failed all builds. Not sure were to start looking to debug this.

```julia
The command "julia --color=yes -e "if VERSION < v\"0.7.0-DEV.5183\"; Pkg.clone(pwd()); Pkg.build(\"${JL_PKG}\"); else using Pkg; if VERSION >= v\"1.1.0-rc1\"; Pkg.build(verbose=true); else Pkg.build(); end; end"" failed and exited with 1 during .
Your build has been stopped.

```

---

<div class="post-metadata">

**Author:** ![jonathanBieler](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jonathanBieler](https://discourse.julialang.org/u/jonathanBieler)\
**Post date:** [September 26, 2019, 10:03am UTC](https://discourse.julialang.org/t/ann-abstract-logic-solver-for-julia-abstractlogic-jl/29134/10 "2019-09-26T10:03:47Z")

</div>

I think it’s because you have a Manifest.toml file in there, you can try to remove it.

---

<div class="post-metadata">

**Author:** ![EconometricsBySimula](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/econometricsbysimula/32/1255_2.png) [@EconometricsBySimula](https://discourse.julialang.org/u/EconometricsBySimula)\
**Post date:** [September 26, 2019, 1:41pm UTC](https://discourse.julialang.org/t/ann-abstract-logic-solver-for-julia-abstractlogic-jl/29134/11 "2019-09-26T13:41:32Z")

</div>

Darn, deleted Manifest.toml but still error

---

<div class="post-metadata">

**Author:** ![jonathanBieler](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jonathanBieler](https://discourse.julialang.org/u/jonathanBieler)\
**Post date:** [September 26, 2019, 1:44pm UTC](https://discourse.julialang.org/t/ann-abstract-logic-solver-for-julia-abstractlogic-jl/29134/12 "2019-09-26T13:44:22Z")

</div>

You deleted the one in the docs, I was talking about this [one](https://github.com/EconometricsBySimulation/AbstractLogic.jl/blob/master/Manifest.toml).

---

<div class="post-metadata">

**Author:** ![EconometricsBySimula](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/econometricsbysimula/32/1255_2.png) [@EconometricsBySimula](https://discourse.julialang.org/u/EconometricsBySimula)\
**Post date:** [September 26, 2019, 5:45pm UTC](https://discourse.julialang.org/t/ann-abstract-logic-solver-for-julia-abstractlogic-jl/29134/13 "2019-09-26T17:45:22Z")

</div>

Got Julia 1.1 passed and working on 1.2! Looks like it is passing! Thank you so much.

---

<div class="post-metadata">

**Author:** ![EconometricsBySimula](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/econometricsbysimula/32/1255_2.png) [@EconometricsBySimula](https://discourse.julialang.org/u/EconometricsBySimula)\
**Post date:** [September 26, 2019, 6:38pm UTC](https://discourse.julialang.org/t/ann-abstract-logic-solver-for-julia-abstractlogic-jl/29134/14 "2019-09-26T18:38:53Z")

</div>

Awesome `Travis CI` and `Coveralls` up and running!

---

<div class="post-metadata">

**Author:** ![StevenSiew](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevensiew/32/218393_2.png) [@StevenSiew](https://discourse.julialang.org/u/StevenSiew)\
**Post date:** [September 26, 2019, 11:44pm UTC](https://discourse.julialang.org/t/ann-abstract-logic-solver-for-julia-abstractlogic-jl/29134/15 "2019-09-26T23:44:31Z")

</div>

> [@EconometricsBySimula](#):
>
> search {{i}} \> {{!i}}

Can anyone reproduce this problem?

```julia
abstractlogic> clear
Clearing Activeset

abstractlogic> Peter, Susan, Sam, Li, Ali ∈ 1, 2, 3, 4, 5
Peter, Susan, Sam, Li, Ali ∈ 1, 2, 3, 4, 5 Feasible Outcomes: 3125 Perceived Outcomes: 3125 ✓ :5 5 5 3 5

abstractlogic> Peter < Susan; Sam < Susan
Peter < Susan Feasible Outcomes: 1250 Perceived Outcomes: 2000 ✓ :2 4 4 1 1
Sam < Susan Feasible Outcomes: 750 Perceived Outcomes: 1600 ✓ :2 4 3 2 4

abstractlogic> Sam > Ali; Li > Ali; Li < Peter
Sam > Ali Feasible Outcomes: 175 Perceived Outcomes: 540 ✓ :1 5 3 5 1
Li > Ali Feasible Outcomes: 121 Perceived Outcomes: 432 ✓ :3 5 3 3 2
Li < Peter Feasible Outcomes: 13 Perceived Outcomes: 48 ✓ :4 5 3 2 1

abstractlogic> search {{i}} > {{!i}}
Warning! Search Failed: UndefVarError(:replcmdverbose)

```

---

<div class="post-metadata">

**Author:** ![EconometricsBySimula](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/econometricsbysimula/32/1255_2.png) [@EconometricsBySimula](https://discourse.julialang.org/u/EconometricsBySimula)\
**Post date:** [September 27, 2019, 12:43am UTC](https://discourse.julialang.org/t/ann-abstract-logic-solver-for-julia-abstractlogic-jl/29134/16 "2019-09-27T00:43:05Z")

</div>

Fixed it! Sorry about that. Need to up my testing coverage.

---

<div class="post-metadata">

**Author:** ![EconometricsBySimula](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/econometricsbysimula/32/1255_2.png) [@EconometricsBySimula](https://discourse.julialang.org/u/EconometricsBySimula)\
**Post date:** [September 27, 2019, 5:40am UTC](https://discourse.julialang.org/t/ann-abstract-logic-solver-for-julia-abstractlogic-jl/29134/17 "2019-09-27T05:40:57Z")

</div>

Ok 88% coverage Travis CI building and testing properly. Now all i need is to figure out how to build my documentation. Seems Documenter won’t build on Windows.

---

<div class="post-metadata">

**Author:** ![StevenSiew](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevensiew/32/218393_2.png) [@StevenSiew](https://discourse.julialang.org/u/StevenSiew)\
**Post date:** [September 27, 2019, 6:41am UTC](https://discourse.julialang.org/t/ann-abstract-logic-solver-for-julia-abstractlogic-jl/29134/18 "2019-09-27T06:41:37Z")

</div>

> [@StevenSiew](#):
>
> search {{i}} \> {{!i}}

I am trying to make sense of your package. It seems to me that the number of feasible outcomes is n^n which in this case is 3^3 == 27

```julia-auto
abstractlogic> clear
Clearing Activeset

abstractlogic> a, b , c ∈ 1, 2, 3
a, b , c ∈ 1, 2, 3 Feasible Outcomes: 27 Perceived Outcomes: 27 ✓ :1 3 2

abstractlogic> a < c
a < c Feasible Outcomes: 9 Perceived Outcomes: 12 ✓ :1 1 3

abstractlogic> check a == 1
check: a == 1 ... a == 1 Feasible Outcomes: 6 Perceived Outcomes: 6 ✓ :1 1 2
possible, 6 out of 9 possible combinations 'true'.

abstractlogic> check a == 2
check: a == 2 ... a == 2 Feasible Outcomes: 3 Perceived Outcomes: 3 ✓ :2 2 3
possible, 3 out of 9 possible combinations 'true'.

```

Trying to figure out what search is

```julia-auto
abstractlogic> search == 1
  Checking: a == 1 Checking: b == 1 Checking: c == 1 

:a is a possible match with 6 feasible combinations out of 9.
:b is a possible match with 3 feasible combinations out of 9.
:c is a not match with 0 feasible combinations out of 9.

abstractlogic> search {{i}} == 1
  Checking: a == 1 Checking: b == 1 Checking: c == 1 

:a is a possible match with 6 feasible combinations out of 9.
:b is a possible match with 3 feasible combinations out of 9.
:c is a not match with 0 feasible combinations out of 9.

abstractlogic> search {{n}} == 1
Warning! Search Failed: ErrorException("type Nothing has no field match")

abstractlogic> search {{j}} == 1
  Checking: a == 1 Checking: b == 1 Checking: c == 1 

:a is a possible match with 6 feasible combinations out of 9.
:b is a possible match with 3 feasible combinations out of 9.
:c is a not match with 0 feasible combinations out of 9.

abstractlogic> search {{k}} == 1
Warning! Search Failed: ErrorException("type Nothing has no field match")

```

Okay, “search” likes {{i}} and like {{j}}  
but it does not like {{n}} and not like {{k}}  
I think search like character with a dot in it like i and j

Going through all 26 letters of the alphabet, search only likes {{i}} and {{j}} so that proves my hypothesis correct. What a mystic program.

Show is wonderful. It kinda shows the internal feasible states

```julia-auto
abstractlogic> help show
  REPL: show 

  variantes: show, s 

  Print a table of 10 feasible results (head and tail).
abstractlogic> show
a b c
– – –
1 1 2
1 1 3
1 2 2
1 2 3
1 3 2
1 3 3
2 1 3
2 2 3
2 3 3

```

Showall is even more wonderful, I think I broke the internet running it.

```julia-auto
abstractlogic> showall
ERROR: function showall does not accept keyword arguments
Stacktrace:
 [1] kwfunc(::Any) at ./boot.jl:332
 [2] (::getfield(AbstractLogic, Symbol("##abstractlogic#253#255")){getfield(AbstractLogic, Symbol("#keys#254"))})(::Bool, ::Bool, ::typeof(abstractlogic), ::String) at /Users/ssiew/.julia/packages/AbstractLogic/Rpe7G/src/repl/repl.jl:61
 [3] abstractlogic at /Users/ssiew/.julia/packages/AbstractLogic/Rpe7G/src/repl/repl.jl:33 [inlined]
 [4] parse_to_expr(::String) at /Users/ssiew/.julia/packages/AbstractLogic/Rpe7G/src/repl/replmaker.jl:4
 [5] #invokelatest#1 at ./essentials.jl:790 [inlined]
 [6] invokelatest at ./essentials.jl:789 [inlined]
 [7] (::getfield(REPL, Symbol("#do_respond#38")){Bool,typeof(AbstractLogic.parse_to_expr),REPL.LineEditREPL,REPL.LineEdit.Prompt})(::Any, ::Any, ::Any) at /Users/sabae/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.2/REPL/src/REPL.jl:713

```

You can use check to do searches too

```julia-auto
abstractlogic> check {{i}} == 1
check: {{i}} == 1 ... {{i}} == 1 >>> a == 1 >>> b == 1 >>> c == 1 
 		 Feasible Outcomes: 0 Perceived Outcomes: 0 X [empty set]
false, 0 out of 9 possible combinations 'true'.

abstractlogic> check {{i}} >= 1
check: {{i}} >= 1 ... {{i}} >= 1 >>> a >= 1 >>> b >= 1 >>> c >= 1 
 		 Feasible Outcomes: 9 Perceived Outcomes: 12 ✓ :1 2 2
true, 9 out of 9 possible combinations 'true'.

```

---

<div class="post-metadata">

**Author:** ![EconometricsBySimula](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/econometricsbysimula/32/1255_2.png) [@EconometricsBySimula](https://discourse.julialang.org/u/EconometricsBySimula)\
**Post date:** [September 27, 2019, 4:01pm UTC](https://discourse.julialang.org/t/ann-abstract-logic-solver-for-julia-abstractlogic-jl/29134/19 "2019-09-27T16:01:54Z")

</div>

{{i}} and {{j}} are similar but different wildcards. i fills in for any variable name while j only grabs the stem for variables with attributes

```julia
abstractlogic> bob.age, sue.age, stephen.age, peggy.age in 40, 50, 60
abstractlogic> bob.sex, stephen.sex in m
abstractlogic> sue.sex, peggy.sex in f
abstractlogic> {{j}}.sex == 'm' ==> {{j}}.age > 40 

abstractlogic> {{j}}.sex == 'm' ==> {{j}}.age > 40
{{j}}.sex == 'm' ==> {{j}}.age > 40 >>> bob.sex == 'm' ==> bob.age > 40 >>> sue.sex == 'm' ==> sue.age > 40 >>> stephen.sex == 'm' ==> stephen.age > 40 >>> peggy.sex == 'm' ==> peggy.age > 40
         Feasible Outcomes: 36 Perceived Outcomes: 36 ✓ :50 60 60 40 m m f f

```

Thanks for playing around with it. I’ll look into getting showall working.

---

<div class="post-metadata">

**Author:** ![EconometricsBySimula](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/econometricsbysimula/32/1255_2.png) [@EconometricsBySimula](https://discourse.julialang.org/u/EconometricsBySimula)\
**Post date:** [September 27, 2019, 4:07pm UTC](https://discourse.julialang.org/t/ann-abstract-logic-solver-for-julia-abstractlogic-jl/29134/20 "2019-09-27T16:07:28Z")

</div>

Until showall is up in working. You can always swtich back to `julia> replset[:,:,true]` will collect all of the feasible values, `julia> replset[:,:]` returns all values of the domain, while `julia> collect(replset)` will return all values including their key values (`true` or `false`).

[Next page](https://discourse.julialang.org/t/ann-abstract-logic-solver-for-julia-abstractlogic-jl/29134.md?page=2)
