Functions

Functions

General Functions

checkfeasible(command::String, logicset::LogicalCombo; verbose=true, all=false, countany=false)

Is called when the user would like to check if a command produces a valid result, possible result, or invalid result. The result is returned as a decimal from 0.0 to 1.0. With 0.0 being no matches and 1.0 being all matches.

Arguments

  • verbose : controls print
  • countall : all sets have to be feasible or return 0
  • countany : any set can be non-zero to return 1

Examples

julia> myset = logicalparse("a, b, c ∈ red, blue, green")
a, b, c ∈ red, blue, green       feasible outcomes 27 ✓          :red blue blue

julia> myset = logicalparse("a != b,c; b = c ==> a = 'blue'", myset)
a != b,c                 feasible outcomes 12 ✓          :green blue blue
b = c ==> a = 'blue'     feasible outcomes 8 ✓           :blue green green

julia> checkfeasible("a = 'green' ==> b = 'red'", myset)
Check: a = 'green' ==> b = 'red' ... a = 'green' ==> b = 'red'   feasible outcomes 17 ✓          :blue red green
possible,  17 out of 21 possible combinations 'true'.
source

dependenton(command::String, logicset::LogicalCombo; verbose=true)

Checks whether variables on the left of the infix operator (⊥) depend for their distribution on variables on the right of the operator.

Operators

  • x ⊥ y: checks if the distribution of potential values of x does not change when y changes.

Alternatively: x independentof y

  • x !⊥ y: checks if the distribution of potential values of x changes when y changes.

Alternatively: x dependenton y

Examples - API

julia> logicset = logicalparse("a, b, c ∈ 1:4; a > b", verbose=false)

julia> dependenton("a ⊥ c", logicset)
True: a is independent of c
true

julia> dependenton("a ⊥ b", logicset)
False: a is dependent on b
range( a | b == b ) =   {}
––––––––––––––––––– – –––––––
range( a | b == 1 ) = {2,3,4}
range( a | b == 2 ) =  {3,4}
range( a | b == 3 ) =   {4}
false

julia> dependenton("a !⊥ b", logicset)
a is dependent on b
true

Examples - REPL

abstractlogic> a, b, c ∈ 1:4; a > b [clear]
Activeset Already Empty

a, b, c ∈ 1:4            Feasible Outcomes: 64   Perceived Outcomes: 64 ✓        :1 4 2
a > b                    Feasible Outcomes: 24   Perceived Outcomes: 36 ✓        :4 2 1

abstractlogic> a ⊥ c
True: a is independent of c

abstractlogic> a ⊥ b
False: a is dependent on b
range( a | b == b ) =   {}
––––––––––––––––––– – –––––––
range( a | b == 1 ) = {2,3,4}
range( a | b == 2 ) =  {3,4}
range( a | b == 3 ) =   {4}

abstractlogic> a !⊥ b
True: a is dependent on b
source

Prints a list of logical combos, variables defined, number of feasible outcomes, number of commands, as well as the last command.

discover(x::LogicalCombo) discover()

source
AbstractLogic.helpFunction.
help(x)

A lookup related to AbstractLogic operators, commands, and wildcards.

Example

julia> help("")
`` not found. Search any of the following:

REPL Commands: ?, b, back, check, clear, clearall, dash, dashboard, f, h, help, history, k, keys, logicset, ls, n, next, preserve, restore, s, search, show, showall

Generators: in, ||, ∈

Operators: !, &, ,, <, <<, <=, =, ==, >, >=, >>, ^, {, |

Superoperators: !==, &&&, <==, <=>, ===, ==>, ^^^, and, if, if...then, iff, or, then, xor, |||

Metaoperators: !===, &&&&, <===, <==>, ====, ===>, AND, IF, IF...THEN, IFF, OR, THEN, XOR, ^^^^, ||||

Wildcards: !i, ,n2, <<i, <i, >>i, >i, N, i, i+n, i+n!, i-n, i-n!, j, n1,, n1,n2, {{!i}}, {{<<i}}, {{<i}}, {{>>i}}, {{>i}}, {{N}}, {{i+n!}}, {{i+n}}, {{i-n!}}, {{i-n}}, {{i}}, {{j}}, {{n1,n2}}

julia> help("i")

Wildcard: i

variantes: {{i}}, i

•    {{i}} the most basic wildcard reference is {{i}}. It can take any variable name from the set of variables so far defined.

Example
---------

abstractlogic> a,b,c ∈ 1:3

a,b,c ∈ 1:3 feasible outcomes 27 ✓ :1 1 3

abstractlogic> {{i}} > 1

{{i}} > 1 >>> a > 1 >>> b > 1 >>> c > 1

            Feasible Outcomes: 8    Perceived Outcomes: 8 ✓         :3 3 3
source
logicalparse

Takes a command and parses it into logical calls that either assigning additional feasible variable ranges or constrain the relationship between variables.

logicalparse(command::String; logicset::LogicalCombo = LogicalCombo(), verbose=true)
logicalparse(command::String, logicset::LogicalCombo; ...)
logicalparse(commands::Array{String,1}, logicset::LogicalCombo; ...)
logicalparse(commands::Array{String,1}; ...)

Arguments

  • verbose : specifies to print to screen or not

Operators

There are numerous operators available to be used in the logical parse command.

Examples

julia> myset = logicalparse("a, b, c in 1:3")
a,b,c in 1:3             feasible outcomes 27 ✓          :3 3 3

julia> myset = logicalparse("a == b", myset)
a == b                   feasible outcomes 9 ✓           :1 1 2

julia> myset = logicalparse("a > c", myset)
a > c                    feasible outcomes 3 ✓           :3 3 1

julia> myset = logicalparse("c != 1", myset)
c != 1                   feasible outcomes 1 ✓✓          :3 3 2
source
nfeasible(x::LogicalCombo; feasible=true)

Returns a count of the number of feasible outcomes in x.
  • feasible:

Example

julia> nfeasible(logicalparse("a,b in 1:3; a!=b", verbose = false))
6
julia> nfeasible(logicalparse("a,b in 1:3; a!=b", verbose = false), feasible=false)
3
source
percievedfeasible(x::LogicalCombo)

Returns a count of the number of feasible outcomes that could be infered if
one were just looking at the number of possible values each variable can take.
  • feasible:

Example

julia> percievedfeasible(logicalparse("a,b in 1:3; a=b", verbose = false))
9
julia> percievedfeasible(logicalparse("a,b in 1:3; a=1", verbose = false))
3
source
AbstractLogic.searchFunction.
search(command::String, logicset::LogicalCombo; verbose=true)

Searches for a possible match among a LogicalCombo in which the wildcard term is true. Search requires the use of a wildcard. In the event that a wildcard is missing, search will insert a {{i}} to the left of the command.{{i+1}} can be used to search for relationships between the ith column and another column.

Examples

julia> myset = logicalparse("v1, v2, v3 ∈ 1:10")
v1, v2, v3 ∈ 1:10        feasible outcomes 1000 ✓        :6 6 10

julia> myset = logicalparse("{{i}} >> {{i+1}}", myset)
{{i}} >> {{i+1}}
>>> v1 >> v2
>>> v2 >> v3
         feasible outcomes 56 ✓          :10 7 3

julia> search("{{i}} == 4", myset)
Checking: v1 == 4
Checking: v2 == 4
Checking: v3 == 4

:v1 is a not match with 0 feasible combinations out of 56.
:v2 is a possible match with 10 feasible combinations out of 56.
:v3 is a possible match with 6 feasible combinations out of 56.

julia> search("== 4", myset, verbose=false) == search("{{i}} == 4", myset, verbose=false)
true

julia> search("{{i}} > {{!i}}", myset)
Checking: v1 > v2
Checking: v1 > v3
Checking: v2 > v1
Checking: v2 > v3
Checking: v3 > v1
Checking: v3 > v2

:v1 is a match with 56 feasible combinations out of 56.
:v2 is a not match with 0 feasible combinations out of 56.
:v3 is a not match with 0 feasible combinations out of 56.
source
setcompare(command::String, logicset::LogicalCombo; verbose=true)

Provides a mechanism for checking if a set made up of possible values a variable can take is a subset of another set.

Operatators

In the repl this function is called by the use of set operators.

  • x ⊂ y: checks if the values x can take are all contained within the set y

Alternatively: x subset y

  • x !⊂ y: checks if one or more of the values x can take are not within the set y

Alternatively: x notsubset y

  • x ⊃ y: checks if the values y can take are all contained within the set x

Alternatively: x superset y

  • x !⊃ y: checks if one or more of the values y can take are not within the set x

Alternatively: x notsuperset y

  • x ⋂ y: checks if set x intersects set y, that is if any values of x are in y

Alternatively: x intersect y

  • x ⋔ y: checks if set x is disjoint from set y, that is no values of x are in y

Alternatively: x notintersect y, x !⋂ y, x disjoint y

Set Unions and Intersections

The left and right hand side of the set operator can also be constructed from multiple sets joined together with either the | (or ,) operator or using the intersetion of the set using the & operator.

Examples - API

julia> logicset = logicalparse("a, b, c ∈ 1:4; a > b", verbose=false)

julia> setcompare("a ⊂ c", logicset)
  a   ⊂    c    result
––––– – ––––––– ––––––
2,3,4 ⊂ 1,2,3,4  true
true

julia> setcompare("a !⊃ c", logicset)
  a   !⊃    c    result
––––– –– ––––––– ––––––
2,3,4 !⊃ 1,2,3,4  true
true

Examples - REPL

abstractlogic> a, b, c ∈ 1:4
a, b, c ∈ 1:4            Feasible Outcomes: 64   Perceived Outcomes: 64 ✓        :1 1 4

abstractlogic> a > b
a > b                    Feasible Outcomes: 24   Perceived Outcomes: 36 ✓        :3 2 2

abstractlogic> a ⊂ c
  a   ⊂    c    result
––––– – ––––––– ––––––
2,3,4 ⊂ 1,2,3,4  true

abstractlogic> a !⊃ c
  a   !⊃    c    result
––––– –– ––––––– ––––––
2,3,4 !⊃ 1,2,3,4  true

abstractlogic> a ⋂ b
  a   ⋂   b   result
––––– – ––––– ––––––
2,3,4 ⋂ 1,2,3  true

abstractlogic> a | b superset c
 a | b  superset    c    result
––––––– –––––––– ––––––– ––––––
2,3,4,1 superset 1,2,3,4  true

abstractlogic> a & b ⊃ c
a & b ⊃    c    result
––––– – ––––––– ––––––
 2,3  ⊃ 1,2,3,4 false
source
showfeasible

Collects a matrix of only feasible outcomes given the parameter space and the constraints. Use collect to output a matrix of all possible matches for parameter space.

Examples

julia> myset = logicalparse("a, b, c in 1:3")
a,b,c in 1:3             feasible outcomes 27 ✓          :3 3 3

julia> myset = logicalparse("a == b; c > b", myset)
a == b                   feasible outcomes 9 ✓           :1 1 3
c > b                    feasible outcomes 3 ✓           :2 2 3

julia> showfeasible(myset)
3×3 Array{Int64,2}:
 1  1  2
 1  1  3
 2  2  3
source