ASSUME
Declares a variable or function with a specified type, without providing a definition. Used for external values or assumptions about inputs.
Syntax
ASSUME name IS A Type
ASSUME name IS A FUNCTION FROM Type1 TO Type2
Purpose
ASSUME is used to:
- Declare input variables for decision logic
- Declare external functions whose implementation is provided elsewhere
- State assumptions about values that will be provided at runtime
Examples
Example file:
-- ASSUME keyword examples
-- Basic Variable Assumptions
-- Assume primitive types
ASSUME `is employed` IS A BOOLEAN
ASSUME `annual income` IS A NUMBER
ASSUME `applicant name` IS A STRING
-- Function Assumptions
-- Single parameter function
ASSUME `calculate tax` IS A FUNCTION FROM NUMBER TO NUMBER
-- The assumed function can be used in expressions
DECIDE `tax on income` IS `calculate tax` `annual income`
-- Using Assumed Values in Decisions
ASSUME age IS A NUMBER
ASSUME `has valid license` IS A BOOLEAN
-- Combine assumed values in logic
DECIDE `can drive` IS
age >= 16 AND `has valid license`
-- Evaluating with Assumed Values
-- The expression uses assumed values
#CHECK `can drive`
-- Complex Example: Eligibility Check
ASSUME `applicant age` IS A NUMBER
ASSUME `years of residence` IS A NUMBER
ASSUME `has criminal record` IS A BOOLEAN
DECIDE `is eligible for benefit` IS
`applicant age` >= 21
AND `years of residence` >= 5
AND NOT `has criminal record`
#CHECK `is eligible for benefit`
Basic Variable Assumptions
-- Assume a boolean input
ASSUME isEmployed IS A BOOLEAN
-- Assume a numeric value
ASSUME income IS A NUMBER
-- Assume a string
ASSUME applicantName IS A STRING
Function Assumptions
-- Assume an external function
ASSUME calculateTax IS A FUNCTION FROM NUMBER TO NUMBER
-- Multi-parameter function (using AND)
ASSUME addNumbers IS A FUNCTION FROM NUMBER AND NUMBER TO NUMBER
Using Assumed Values
ASSUME age IS A NUMBER
ASSUME income IS A NUMBER
DECIDE isEligible IS
age >= 18 AND income > 50000
Behavior
- Assumed values can be used in expressions but have no defined value
- When evaluated directly, assumed values remain symbolic
- Assumed values are typically bound via
#CHECK ... WITHor#TRACE ... WITH
Binding Assumed Values
ASSUME age IS A NUMBER
DECIDE isAdult IS age >= 18
-- Bind the assumed value for checking
#CHECK isAdult WITH age IS 25
Related Keywords
- DECIDE - Define a value or function with a body
- GIVEN - Introduce function parameters
- TYPE-KEYWORDS - Type syntax (IS, FUNCTION, etc.)
See Also
- Types Reference - Type syntax