This is the multi-page printable view of this section. Click here to print.
Logic
- 1: Declarative Logic
- 2: Value Condition
- 3: Select condition
- 4: Meta condition
- 5: Preconditions
1 - Declarative Logic
What is declarative logic?
Declarative logic is the kind of logic we are most familiar with as human beings - it is reasoning about states of affairs.
Jim is 17 years old
Driving is permitted from 18 years of age
Jim cannot drive yet
These are three declarative statements.
Statements are things which can be evaluated to be true or false.
If the first two statements are true, we can conclude the third statement is true.
Declarative Logic in Logiak
If the above is easy to understand (which of course it is), that is good because, as you will see, Logiak lets you do a huge amount of computation simply by creating declarative statements like this.
The separation between declarative and procedural thinking is one of the core selling points of Logiak
We call these statements: conditions
We refer to these statements are Conditions, because of one primary role they play in Logiak Processes, and that is as pre-conditions for Process steps.
But definitions would also have been a good name for them, as would statements.
There are three kinds of Conditions you can define
2 - Value Condition
Value Conditions
A Value Condition is a statement which can be true or false.
Suppose we have a value called age-in-years.
A Value Condition is something like this:
This is true if the value of age-in-years is less than 5, false otherwise.
Condition names
Conditions in Logiak have names.
It is good practice, because these conditions are statements which can evaluate to true or false, to give them statement-like names.
That is, sentences or sentence-like texts which make clear what state of affairs the condition describes.
So, for example, you might use the name “Child is an infant” could be an appropriate name for the condition :
Child is an infant
age-in-years < 5
3 - Select condition
Select Conditions
A Select Condition is a statement which can be true or false.
Its truth depends on how the user has responded to a question which required a selection: either a Yes/No question, or a Select question. .
Example yes/no
Here we create a yes/no question for the user
Does the child have any known allergies?
Then we define a condition Child has no allergies by simulating a possible user response (in this case user selects “no”) and giving a name to the state of affairs described by that response.
4 - Meta condition
Meta Conditions
A Meta Condition is a statement which can be true or false.
Its truth depends on the truth of the sub-conditions it contains.
Example: Defining child is an infant with fever
Suppose we have a value condition “Child is an infant”;
Child is an infant
age-in-years < 5And suppose we had a second value condition “Child has fever”;
Child has fever
temperature > 37.5We could define a meta-condition with both of these conditions as sub-conditions, and choosing to require ALL sub-conditions to be true.
We might name this meta-condition: “Child is an infant AND child has fever” or “Child is an infant with fever”
Child is an infant with fever
Child is an infant (age-in-years < 5) AND Child has fever (temperature > 37.5)
Note that named condition which are defined but nowhere used are in a light font.
When conditions are in use (e.g. as subconditions of a meta condition), their names are presented with a regular font weight.
Meta Conditions can be sub-conditions
Meta conditions are conditions like any other, so they can be used as sub-conditions in defining other meta-conditions.
Once you have defined “Child is an infant with fever”, you can simply select that as a sub-condition in defining a further meta-condition
Paracetamol should be prescribed
Child is an infant with fever (age-in-years < 5 AND temperature > 37.5) AND Child has no known allergy (..)5 - Preconditions
How to use the logic defined
When we have defined conditions, we can use them to affect the execution of the Process.
We can set any condition to be a precondition for a step.
If a step has a precondition, it is only executed if the precondition evaluates to true.
Example: “prescribe paracetamol”