echo "Hello World" > index.html
Welcome to the Pop 'n' Fresh language specification!
This page provides a detailed overview of the language's syntax, semantics, and supported data types.
If you're new to the language, start with the Syntax section to understand the basic structure and rules.
For more information on the language, check out the Semantics section, which covers the operations and commands supported by the language.
The Data Types section provides an overview of the supported data types and structures in the language.
If you're ready to dive into the language, check out the Built-in Functions section, which lists the built-in functions available in the language.
The syntax of Pop 'n' Fresh follows a clear structure defined by strict formatting and rule sets. Each statement in the language adheres to the following general format:
// Single-line comment
{
operation: "add"; // Block start
num1: 3;
num2: 5;
result: 0;
// Call operation
result = add(num1, num2);
}
Operations in Pop 'n' Fresh are built on a functional paradigm with state transformations being explicit. All operations consist of a source, a command, and an optional result. The language ensures that side effects are minimized by default, making state changes explicit within blocks.
{
input: 4;
factor: 3;
output: 0;
output = multiply(input, factor); // Semantically pure operation
}
add()
, subtract()
, multiply()
, and divide()
follow traditional semantics.x = y;
assign the value of y
to x
.The language supports the following primitive data types and composite structures:
int
: Represents integer numbers.float
: Represents floating-point numbers.string
: A sequence of characters.bool
: Represents boolean values (true
or false
).[ ]
, and can hold multiple values of any type.{}
, these are key-value pairs where the key is a string and the value can be any type.{
arr: [1, 2, 3, 4];
obj: {
"key1": "value1",
"key2": true,
"key3": 3.14
};
}
The language provides a set of built-in functions that can be used to perform common operations. These functions are:
add(int, int)
: Adds two integers.subtract(int, int)
: Subtracts two integers.multiply(int, int)
: Multiplies two integers.divide(int, int)
: Divides two integers.concat(string, string)
: Concatenates two strings.length(string)
: Returns the length of a string.substring(string, int, int)
: Extracts a substring from a string.{
arr: [1, 2, 3, 4];
obj: {
"key1": "value1",
"key2": true,
"key3": 3.14
};
}
The syntax of Pop 'n' Fresh follows a clear structure defined by strict formatting and rule sets. Each statement in the language adheres to the following general format:
;
).{}
.//
, while multi-line comments are enclosed in /* */
.// Single-line comment
{
operation: "add"; // Block start
num1: 3;
num2: 5;
result: 0;
// Call operation
result = add(num1, num2);
}
Operations in toaster.Json are built on a functional paradigm with state transformations being explicit. All operations consist of a source, a command, and an optional result. The language ensures that side effects are minimized by default, making state changes explicit within blocks.
{
input: 4;
factor: 3;
output: 0;
output = multiply(input, factor); // Semantically pure operation
}
add()
, subtract()
, multiply()
, and divide()
follow traditional semantics.x = y;
assign the value of y
to x
.The language supports the following primitive data types and composite structures:
int
: Represents integer numbers.float
: Represents floating-point numbers.string
: A sequence of characters.bool
: Represents boolean values (true
or false
).[]
and can hold elements of the same type.{}
and consist of key-value pairs, where the key is a string and the value can be of any type.{
arr: [1, 2, 3, 4];
obj: {
"key1": "value1",
"key2": true,
"key3": 3.14
};
}
The language provides a set of built-in functions that can be used to perform common operations. These functions are:
The syntax of microwave.Json follows a clear structure defined by strict formatting and rule sets. Each statement in the language adheres to the following general format:
;
).{}
.//
, while multi-line comments are enclosed in /* */
.// Single-line comment
{
operation: "add"; // Block start
num1: 3;
num2: 5;
result: 0;
// Call operation
result = add(num1, num2);
}
Operations in toaster.Json are built on a functional paradigm with state transformations being explicit. All operations consist of a source, a command, and an optional result. The language ensures that side effects are minimized by default, making state changes explicit within blocks.
{
input: 4;
factor: 3;
output: 0;
output = multiply(input, factor); // Semantically pure operation
}
The syntax of Pop 'n' Fresh follows a clear structure defined by strict formatting and rule sets. Each statement in the language adheres to the following general format:
;
).{}
.//
, while multi-line comments are enclosed in /* */
.// Single-line comment
{
operation: "add"; // Block start
num1: 3;
num2: 5;
result: 0;
// Call operation
result = add(num1, num2);
}
Operations in toaster.Json are built on a functional paradigm with state transformations being explicit. All operations consist of a source, a command, and an optional result. The language ensures that side effects are minimized by default, making state changes explicit within blocks.
{
input: 4;
factor: 3;
output: 0;
output = multiply(input, factor); // Semantically pure operation
}
The syntax of toaster.Json follows a clear structure defined by strict formatting and rule sets. Each statement in the language adheres to the following general format:
;
).{}
.//
, while multi-line comments are enclosed in /* */
.// Single-line comment
{
operation: "add"; // Block start
num1: 3;
num2: 5;
result: 0;
// Call operation
result = add(num1, num2);
}
Operations in toaster.Json are built on a functional paradigm with state transformations being explicit. All operations consist of a source, a command, and an optional result. The language ensures that side effects are minimized by default, making state changes explicit within blocks.
{
input: 4;
factor: 3;
output: 0;
output = multiply(input, factor); // Semantically pure operation
}
add()
, subtract()
, multiply()
, and divide()
follow traditional semantics.x = y;
assign the value of y
to x
.The language supports the following primitive data types and composite structures:
int
: Represents integer numbers.float
: Represents floating-point numbers.string
: A sequence of characters.bool
: Represents boolean values (true
or false
).[ ]
, and can hold multiple values of any type.{}
, these are key-value pairs where the key is a string and the value can be of any type.{
arr: [1, 2, 3, 4];
obj: { name: "Bob", age: 25 };
x: 5;
y: "Alice";
boolFlag: true;
}
Operations are predefined commands that manipulate data and return results.
add(x, y)
: Adds two numbers.subtract(x, y)
: Subtracts y
from x
.multiply(x, y)
: Multiplies two numbers.divide(x, y)
: Divides x
by y
(raises an error if y
is 0).Functions are user-defined commands that take input parameters, perform operations, and return results. Functions must be explicitly defined and invoked.
function addTwoNumbers(a, b) {
return add(a, b);
}
result = addTwoNumbers(2, 3);
Constants are fixed values that cannot be altered once declared. They are denoted by the const
keyword.
const PI = 3.14159;
Modifiers alter the behavior or scope of variables and operations. toaster.Json includes the following modifiers:
mutable
: Indicates that a variable can be changed.immutable
: Forces a variable to remain constant after its initial assignment.Variables in toaster.Json are categorized based on scope:
global x = 10;
function example() {
local y = 5;
return add(x, y);
}
Errors in toaster.Json are managed using the try-catch
mechanism. Whenever a potential error might occur, the try
block is used to attempt execution, and any errors are caught in the catch
block.
try {
result = divide(10, 0);
} catch (error) {
log("Error occurred: ", error);
}
()
containing arguments.=
and the type is inferred from the value.if
, else
) and loops (while
, for
) follow the traditional C-like grammar.{
x: 5;
y: 10;
if (x < y) {
z = add(x, y);
} else {
z = subtract(y, x);
}
}
toaster.Json comes with a set of standard utilities and libraries to perform common tasks, such as math operations, string manipulations, and array operations.
sqrt(x)
, pow(base, exponent)
length(string)
, concat(string1, string2)
push(array, element)
, pop(array)
The toaster.Json compiler interprets and translates source code into executable bytecode. The compiler includes the following steps:
The toaster.Json compiler automatically manages memory and handles garbage collection.
add(x, y)
subtract(x, y)
multiply(x, y)
divide(x, y)
sqrt(x)
pow(base, exponent)
+
, -
, *
, /
&&
, ||
, !
==
, !=
, >
, <
, >=
, <=
mutable
immutable
global
local
{
// Bob calculates his total balance
bobBalance: 100;
addAmount: 50;
bobBalance = add(bobBalance, addAmount);
// Alice checks if her balance is enough
aliceBalance: 75;
if (aliceBalance >= 100) {
log("Alice has enough balance.");
} else {
log("Alice needs more funds.");
}
}
A + B = C
can be formally represented as Pop A B add -> C
.[a-zA-Z_][a-zA-Z0-9_]*
[0-9]+(\.[0-9]+)?
"[^"]*"
+
, -
, *
, /
, %
, ^
==
, !=
, <
, >
, <=
, >=
&&
, ||
, !
:=
()
{}
[]
<>
DEF
, IF
, ELSE
, LOOP
, BREAK
, CONTINUE
, RETURN
, TRY
, CATCH
, THROW
, ASSERT
// comment
/* comment */
T
K
and value type V
T
FUNC_NAME(param1:TYPE, param2:TYPE) -> RETURN_TYPE {
// function body
}
IF (condition) {
// code
} ELSE {
// code
}
LOOP {
// code
IF (condition) BREAK
}
TRY {
// code
} CATCH (error_type) {
// error handling
}
HASH(data:VEC<INT>) -> H256
SIGN(sk:SK, msg:VEC<INT>) -> SIG
VERIFY(pk:PK, msg:VEC<INT>, sig:SIG) -> BOOL
ENC(pk:PK, msg:VEC<INT>) -> VEC<INT>
DEC(sk:SK, cipher:VEC<INT>) -> VEC<INT>
ZKP_GEN(circuit:VEC<CONSTRAINT>, witness:VEC<FLD>) -> PROOF
ZKP_VERIFY(circuit:VEC<CONSTRAINT>, proof:PROOF, public_input:VEC<FLD>) -> BOOL
COMM_GEN(value:FLD, randomness:FLD) -> COMM
COMM_OPEN(comm:COMM, value:FLD, randomness:FLD) -> BOOL
LWE_SAMPLE(s:VEC<FLD>, e:VEC<FLD>) -> VEC<FLD>
LWE_DECODE(c:VEC<FLD>, s:VEC<FLD>) -> FLD
WE_ENC(stmt:STR, msg:VEC<INT>) -> VEC<INT>
WE_DEC(ct:VEC<INT>, witness:VEC<FLD>) -> OPT<VEC<INT>>
VDF_SETUP(security_parameter:INT) -> VDF_PP
VDF_EVAL(pp:VDF_PP, input:VEC<INT>, time:INT) -> (VEC<INT>, PROOF)
VDF_VERIFY(pp:VDF_PP, input:VEC<INT>, output:VEC<INT>, proof:PROOF) -> BOOL
CIRCUIT_NEW() -> CIRCUIT
CIRCUIT_ADD_GATE(circuit:CIRCUIT, gate:GATE) -> CIRCUIT
CIRCUIT_CONNECT(circuit:CIRCUIT, wire1:WIRE, wire2:WIRE) -> CIRCUIT
CS_NEW() -> CS
CS_ADD_CONSTRAINT(cs:CS, constraint:CONSTRAINT) -> CS
GROTH16_SETUP(cs:CS) -> GROTH16_PP
GROTH16_PROVE(pp:GROTH16_PP, witness:VEC<FLD>) -> PROOF
GROTH16_VERIFY(pp:GROTH16_PP, proof:PROOF, public_input:VEC<FLD>) -> BOOL
PLONK_SETUP(cs:CS) -> PLONK_PP
PLONK_PROVE(pp:PLONK_PP, witness:VEC<FLD>) -> PROOF
PLONK_VERIFY(pp:PLONK_PP, proof:PROOF, public_input:VEC<FLD>) -> BOOL
MPC_INIT(parties:VEC<PK>) -> MPC_SESSION
MPC_CONTRIBUTE(session:MPC_SESSION, input:VEC<FLD>) -> MPC_STATE
MPC_COMPUTE(session:MPC_SESSION, function:FUNC) -> VEC<FLD>
TSS_KEYGEN(t:INT, n:INT) -> (VEC<SK>, PK)
TSS_SIGN(keys:VEC<SK>, msg:VEC<INT>) -> SIG
TSS_COMBINE(sigs:VEC<SIG>) -> SIG
PQ_KEYGEN(security_parameter:INT) -> (PK, SK)
PQ_ENC(pk:PK, msg:VEC<INT>) -> VEC<INT>
PQ_DEC(sk:SK, cipher:VEC<INT>) -> VEC<INT>
RING_SIGN(sk:SK, msg:VEC<INT>, ring:VEC<PK>) -> RING_SIG
RING_VERIFY(msg:VEC<INT>, sig:RING_SIG, ring:VEC<PK>) -> BOOL
BLIND_SIGN(sk:SK, blinded_msg:VEC<INT>) -> BLIND_SIG
BLIND_VERIFY(pk:PK, msg:VEC<INT>, sig:BLIND_SIG) -> BOOL
HE_KEYGEN(security_parameter:INT) -> (HE_PK, HE_SK)
HE_ENC(pk:HE_PK, msg:FLD) -> HE_CIPHER
HE_ADD(pk:HE_PK, c1:HE_CIPHER, c2:HE_CIPHER) -> HE_CIPHER
HE_MULT(pk:HE_PK, c1:HE_CIPHER, c2:HE_CIPHER) -> HE_CIPHER
HE_DEC(sk:HE_SK, c:HE_CIPHER) -> FLD
MT_NEW() -> MT
MT_INSERT(mt:MT, leaf:H256) -> MT
MT_PROOF(mt:MT, leaf:H256) -> MT_PROOF
MT_VERIFY(root:H256, leaf:H256, proof:MT_PROOF) -> BOOL
SC_OPEN(participants:VEC<PK>, initial_state:VEC<INT>) -> SC
SC_UPDATE(sc:SC, new_state:VEC<INT>, sigs:VEC<SIG>) -> SC
SC_CLOSE(sc:SC, final_state:VEC<INT>, sigs:VEC<SIG>) -> BOOL
SNARK_SETUP(circuit:
CS) -> SNARK_PP
SNARK_PROVE(pp:SNARK_PP, witness:VEC<FLD>) -> SNARK_PROOF
SNARK_VERIFY(pp:SNARK_PP, proof:SNARK_PROOF, public_input:VEC<FLD>) -> BOOL
PAR_EXEC(tasks:VEC<FUNC>) -> VEC<RESULT>
LAZY(expr:EXPR) -> LAZY_EXPR
FORCE(expr:LAZY_EXPR) -> RESULT
MEMO(func:FUNC) -> MEMO_FUNC
INVARIANT(condition:BOOL, msg:STR)
PRE(condition:BOOL, msg:STR)
POST(condition:BOOL, msg:STR)
PROVE(theorem:EXPR) -> PROOF
CHECK_PROOF(theorem:EXPR, proof:PROOF) -> BOOL
FFI_IMPORT(language:STR, func:STR) -> FUNC
FFI_EXPORT(func:FUNC, language:STR) -> STR
SERIALIZE(obj:T) -> VEC<INT>
DESERIALIZE(data:VEC<INT>, type:TYPE) -> T
ERROR_TYPE(name:STR, fields:VEC<(STR, TYPE)>)
DEBUG_PRINT(expr:EXPR)
STACK_TRACE() -> STR
DEBUG_PRINT(expr:EXPR)
DEBUG_PRINT(x) // Outputs the value of x
STACK_TRACE() -> STR
STR trace = STACK_TRACE();
DEBUG_PRINT(trace);
TRY {
// Block of code that might throw an error
} CATCH (error_type) {
// Code to handle the error
}
TRY
block executes the enclosed code. If an error occurs, control is transferred to the CATCH
block, where the error is handled based on the error type.TRY {
x := divide(10, 0); // May cause a divide-by-zero error
} CATCH (DivideByZeroError) {
DEBUG_PRINT("Error: Division by zero");
}
THROW(error_type)
CATCH
block.THROW(FileNotFoundError);
ASSERT(condition:BOOL, msg:STR)
ASSERT(x > 0, "x must be greater than 0");
FFI_IMPORT(language:STR, func:STR) -> FUNC
FUNC sqrt = FFI_IMPORT("C", "sqrt");
FFI_EXPORT(func:FUNC, language:STR) -> STR
FFI_EXPORT(myFunc, "Python");
SERIALIZE(obj:T) -> VEC<INT>
T
into a serialized vector of integers.VEC<INT> serialized_obj = SERIALIZE(myObject);
DESERIALIZE(data:VEC<INT>, type:TYPE) -> T
T
.MyType obj = DESERIALIZE(serialized_data, MyType);
ASYNC(func:FUNC) -> FUTURE<T>
FUTURE<INT> result = ASYNC(myAsyncFunction);
AWAIT(fut:FUTURE<T>) -> T
INT value = AWAIT(result);
PAR_EXEC(tasks:VEC<FUNC>) -> VEC<RESULT>
VEC<FUNC> tasks = [task1, task2, task3];
VEC<RESULT> results = PAR_EXEC(tasks);
LAZY(expr:EXPR) -> LAZY_EXPR
LAZY_EXPR delayed_expr = LAZY(expensive_computation());
FORCE(expr:LAZY_EXPR) -> RESULT
RESULT computed_value = FORCE(delayed_expr);
MEMO(func:FUNC) -> MEMO_FUNC
MEMO_FUNC memoized_function = MEMO(expensive_function);
INVARIANT(condition:BOOL, msg:STR)
INVARIANT(balance >= 0, "Balance must not be negative");
PRE(condition:BOOL, msg:STR)
PRE(x > 0, "x must be positive");
POST(condition:BOOL, msg:STR)
POST(result != NULL, "Result cannot be null");
PROVE(theorem:EXPR) -> PROOF
PROOF proof = PROVE(x + y == y + x);
CHECK_PROOF(theorem:EXPR, proof:PROOF) -> BOOL
BOOL valid = CHECK_PROOF(theorem, proof);
⚡:BUILD
⚙:COMPUTE
⧉:PARALLEL
⧫:CONDITIONAL
IF-ELSE
). This symbol highlights sections of code where different paths may be taken based on evaluation results.↻:LOOP
🕒:DELAYED
REC_SNARK(circuit:CS) -> PROOF
PROOF recursive_proof = REC_SNARK(circuit);
BP_PROVE(v:FLD, gamma:FLD) -> PROOF
PROOF bp_proof = BP_PROVE(v, gamma);
BP_VERIFY(proof:PROOF, comm:COMM) -> BOOL
BOOL valid = BP_VERIFY(bp_proof, commitment);
MPC_PROTOCOL(parties:VEC<PK>, inputs:VEC<FLD>) -> VEC<FLD>
VEC<FLD> result = MPC_PROTOCOL([party1, party2], [input1, input2]);
OT_SEND(m0:VEC<INT>, m1:VEC<INT>) -> OT_MESSAGE
OT_MESSAGE message = OT_SEND(msg0, msg1);
OT_RECEIVE(b:BOOL) -> VEC<INT>
b
.VEC<INT> received_message = OT_RECEIVE(true);
LWE_ENC(pk:PK, msg:FLD) -> CIPHER
CIPHER cipher = LWE_ENC(public_key, message);
LWE_DEC(sk:SK, cipher:CIPHER) -> FLD
FLD message = LWE_DEC(secret_key, cipher);
SPHINCS_SIGN(sk:SK, msg:VEC<INT>) -> SIG
SIG signature = SPHINCS_SIGN(secret_key, message);
SPHINCS_VERIFY(pk:PK, msg:VEC<INT>, sig:SIG) -> BOOL
BOOL valid = SPHINCS_VERIFY(public_key, message, signature);
MIX_NET(participants:VEC<PK>, msgs:VEC<INT>) -> VEC<INT>
VEC<INT> mixed_msgs = MIX_NET([pk1, pk2, pk3], [msg1, msg2, msg3]);
GARBLED_CIRCUIT(input_labels:VEC<INT>, gates:VEC<GATE>) -> CIRCUIT
CIRCUIT gc = GARBLED_CIRCUIT(input_labels, circuit_gates);
EVALUATE_GARBLED(circuit:CIRCUIT, input:VEC<INT>) -> VEC<INT>
VEC<INT> output = EVALUATE_GARBLED(gc, inputs);
SC_CALL(contract:SC, method:STR, args:VEC<INT>) -> RESULT
RESULT res = SC_CALL(my_contract, "transfer", [amount, recipient]);
SC_DEPLOY(code:VEC<INT>, init_state:VEC<INT>) -> SC
SC contract = SC_DEPLOY(contract_code, initial_state);
L2_BATCH(txns:VEC<INT>) -> BATCH
BATCH batch = L2_BATCH([txn1, txn2, txn3]);
L2_COMMIT(batch:BATCH) -> RESULT
RESULT commit_result = L2_COMMIT(batch);
SC_ZK_VERIFY(proof:SNARK_PROOF, public_input:VEC<FLD>, contract:SC) -> BOOL
BOOL verified = SC_ZK_VERIFY(proof, public_input, my_contract);
SC_MT_INSERT(contract:SC, leaf:H256) -> SC
SC updated_contract = SC_MT_INSERT(my_contract, new_leaf);
SC_MT_VERIFY(contract:SC, root:H256, leaf:H256, proof:MT_PROOF) -> BOOL
BOOL valid = SC_MT_VERIFY(my_contract, root_hash, leaf_hash, proof);
OT_PROTOCOL(participants:VEC<PK>, choices:VEC<BOOL>, msgs:VEC<VEC<INT>>) -> VEC<INT>
VEC<INT> received_msgs = OT_PROTOCOL([pk1, pk2], [true, false], [[msg1a, msg1b], [msg2a, msg2b]]);
MPC_GARBLED_CIRCUIT(inputs:VEC<INT>, circuit:CIRCUIT) -> VEC<INT>
VEC<INT> result = MPC_GARBLED_CIRCUIT([input1, input2], secure_circuit);
FORMAL_PROOF(steps:VEC<EXPR>) -> PROOF
PROOF proof = FORMAL_PROOF([step1, step2, step3]);
MODEL_CHECK(model:EXPR, property:EXPR) -> BOOL
BOOL result = MODEL_CHECK(system_model, safety_property);
LWE_KEY_EXCHANGE(participant1:PK, participant2:PK) -> (SK, PK)
(SK, PK) keys = LWE_KEY_EXCHANGE(pk1, pk2);
HKDF(input_key:FLD, salt:FLD, info:STR) -> FLD
FLD derived_key = HKDF(input_key, salt, "key derivation info");
PQ_SIGN(sk:SK, msg:VEC<INT>) -> SIG
SIG pq_signature = PQ_SIGN(secret_key, message);
PQ_VERIFY(pk:PK, msg:VEC<INT>, sig:SIG) -> BOOL
BOOL is_valid = PQ_VERIFY(public_key, message, pq_signature);
ERROR_TYPE(CryptoError, [(message:STR), (code:INT)])
THROW(CryptoError("Invalid key length", 1001));
FUNC safe_decrypt(sk:SK, cipher:VEC<INT>) -> OPT<VEC<INT>> {
TRY {
RETURN DEC(sk, cipher);
} CATCH (CryptoError) {
RETURN OPT<>; // Return empty if decryption fails
}
}
TRY-CATCH
block to handle cryptographic errors during decryption. If decryption fails, the function returns an empty optional value.OPT<VEC<INT>> plaintext = safe_decrypt(secret_key, ciphertext);
FFI_IMPORT("C", "openssl_encrypt") -> FUNC
FUNC encrypt = FFI_IMPORT("C", "openssl_encrypt");
VEC<INT> cipher = encrypt(message, key);
FFI_EXPORT(hash_function, "Rust")
FFI_EXPORT(PQ_HASH, "Rust");
SEC_ANALYZE(code:STR) -> REPORT
REPORT security_report = SEC_ANALYZE(contract_code);
SEC_PROVE(theorem:EXPR) -> PROOF
PROOF security_proof = SEC_PROVE(security_theorem);
ECC_MUL(k:FLD, P:POINT) -> POINT
P
by a scalar k
using an energy-optimized algorithm.POINT result = ECC_MUL(scalar, base_point);
LP_HASH(data:VEC<INT>) -> H256
H256 hash_result = LP_HASH(sensor_data);
ENERGY_PROVE(func:FUNC) -> PROOF
PROOF energy_proof = ENERGY_PROVE(ECC_MUL);
ENERGY_PROFILE(func:FUNC) -> REPORT
REPORT energy_report = ENERGY_PROFILE(LP_HASH);
SET_ENERGY_LIMIT(func:FUNC, limit:INT)
SET_ENERGY_LIMIT(ECC_MUL, 1000); // Sets a maximum energy usage of 1000 units
LWE_ENC_EFFICIENT(pk:PK, msg:FLD) -> CIPHER
CIPHER cipher = LWE_ENC_EFFICIENT(public_key, message);
PQ_SIGN_EFFICIENT(sk:SK, msg:VEC<INT>) -> SIG
SIG pq_signature = PQ_SIGN_EFFICIENT(secret_key, message);
ZK_VERIFY_EFFICIENT(proof:SNARK_PROOF, public_input:VEC<FLD>) -> BOOL
BOOL verified = ZK_VERIFY_EFFICIENT(proof, public_input);
SC_SET_ENERGY_LIMIT(contract:SC, limit:INT)
SC_SET_ENERGY_LIMIT(my_contract, 5000);
TX_TRACK_ENERGY(tx:TX) -> REPORT
REPORT energy_usage = TX_TRACK_ENERGY(my_transaction);
ENERGY_ANALYZE(code:STR) -> REPORT
REPORT energy_analysis = ENERGY_ANALYZE(contract_code);
DYNAMIC_ENERGY_PROFILE(func:FUNC) -> REPORT
REPORT dynamic_profile = DYNAMIC_ENERGY_PROFILE(PQ_SIGN_EFFICIENT);
AUDIT_ENERGY_USAGE(contract:SC) -> REPORT
REPORT audit = AUDIT_ENERGY_USAGE(my_contract);
ENERGY_OPTIMIZE_REPORT(report:REPORT) -> VEC<RECOMMENDATION>
VEC<RECOMMENDATION> optimizations = ENERGY_OPTIMIZE_REPORT(audit);
REALTIME_ENERGY_MONITOR(contract:SC) -> REPORT
REPORT real_time_monitor = REALTIME_ENERGY_MONITOR(my_contract);
SC_THROTTLE_ON_ENERGY(contract:SC, threshold:INT)
SC_THROTTLE_ON_ENERGY(my_contract, 10000);
ZK_CIRCUIT_GEN_EFFICIENT(constraints:VEC<CONSTRAINT>, inputs:VEC<FLD>) -> CIRCUIT
CIRCUIT energy_efficient_circuit = ZK_CIRCUIT_GEN_EFFICIENT(constraints, public_inputs);
ZK_PROOF_GEN_EFFICIENT(circuit:CIRCUIT, witness:VEC<FLD>) -> PROOF
PROOF optimized_proof = ZK_PROOF_GEN_EFFICIENT(energy_efficient_circuit, witness);
POW_ENERGY_LIMIT(mining_func:FUNC, max_energy:INT) -> BLOCK
BLOCK new_block = POW_ENERGY_LIMIT(mine_block, 5000);
CONSENSUS_ENERGY_AWARE(nodes:VEC<NODE>, energy_limits:VEC<INT>) -> NODE
NODE leader = CONSENSUS_ENERGY_AWARE(node_list, energy_limits);
POS_ENERGY_AWARE(stakeholders:VEC<NODE>, energy_threshold:INT) -> NODE
NODE validator = POS_ENERGY_AWARE(stakeholder_list, 3000);
BLOCK_VALIDATE_ENERGY(block:BLOCK, energy_limit:INT) -> BOOL
false
.BOOL is_valid = BLOCK_VALIDATE_ENERGY(new_block, 5000);
TX_PROCESS_ENERGY_AWARE(tx:TX, max_energy:INT) -> RESULT
RESULT tx_result = TX_PROCESS_ENERGY_AWARE(my_transaction, 2000);
VOTE_ENERGY_AWARE(voters:VEC<NODE>, proposals:VEC<STR>, max_energy:INT) -> STR
STR winning_proposal = VOTE_ENERGY_AWARE(node_list, proposal_list, 1000);
ANALYZE_PROPOSAL_ENERGY(proposal:STR) -> REPORT
REPORT proposal_analysis = ANALYZE_PROPOSAL_ENERGY("Upgrade block size");
L2_BATCH_ENERGY(txns:VEC<TX>, energy_limit:INT) -> BATCH
BATCH tx_batch = L2_BATCH_ENERGY(transaction_list, 3000);
ROLLUP_EXEC_ENERGY(rollup:ROLLUP, energy_limit:INT) -> RESULT
RESULT rollup_result = ROLLUP_EXEC_ENERGY(layer2_rollup, 4000);
SC_UPDATE_ENERGY_AWARE(sc:SC, new_state:VEC<INT>, sigs:VEC<SIG>, energy_limit:INT) -> SC
SC updated_channel = SC_UPDATE_ENERGY_AWARE(my_state_channel, new_state, signatures, 2500);
BLOCKCHAIN_ENERGY_AUDIT(blockchain:BC, time_period:INT) -> REPORT
REPORT energy_audit = BLOCKCHAIN_ENERGY_AUDIT(my_blockchain, 30); // Audit over 30 days
TX_ENERGY_COST_PREDICT(tx:TX) -> INT
INT predicted_cost = TX_ENERGY_COST_PREDICT(my_transaction);
CONSENSUS_ENERGY_COMPARE(algo1:FUNC, algo2:FUNC) -> REPORT
REPORT energy_comparison = CONSENSUS_ENERGY_COMPARE(ProofOfWork, ProofOfStake);
ENERGY_ALERT(contract:SC, threshold:INT) -> BOOL
BOOL alert_triggered = ENERGY_ALERT(my_contract, 5000);
TX_FEE_ENERGY_AWARE(tx:TX, energy_usage:INT) -> INT
INT tx_fee = TX_FEE_ENERGY_AWARE(my_transaction, predicted_energy_usage);
GAS_ENERGY_ANALYZE(contract:SC) -> REPORT
REPORT gas_energy_report = GAS_ENERGY_ANALYZE(my_contract);
CONTRACT_OPTIMIZE_ENERGY(code:STR) -> STR
STR optimized_code = CONTRACT_OPTIMIZE_ENERGY(original_contract_code);
SC_BENCHMARK_ENERGY(contract:SC) -> REPORT
REPORT benchmark_report = SC_BENCHMARK_ENERGY(my_contract);
SC_DEPLOY_ENERGY_AWARE(code:STR, init_state:VEC<INT>, max_energy:INT) -> SC
SC new_contract = SC_DEPLOY_ENERGY_AWARE(optimized_code, initial_state, 5000);
SC_EXECUTE_ENERGY_AWARE(contract:SC, method:STR, args:VEC<INT>, max_energy:INT) -> RESULT
RESULT execution_result = SC_EXECUTE_ENERGY_AWARE(my_contract, "transfer", [recipient, amount], 3000);
SC_UPGRADE_ENERGY_AWARE(contract:SC, new_code:STR, max_energy:INT) -> SC
SC upgraded_contract = SC_UPGRADE_ENERGY_AWARE(my_contract, updated_code, 4000);
NETWORK_ENERGY_MONITOR(nodes:VEC<NODE>) -> REPORT
REPORT network_energy_report = NETWORK_ENERGY_MONITOR(blockchain_nodes);
NODE_SELECT_ENERGY_AWARE(nodes:VEC<NODE>, energy_threshold:INT) -> NODE
NODE selected_node = NODE_SELECT_ENERGY_AWARE(network_nodes, 2000);
CONSENSUS_OPTIMIZE_ENERGY(protocol:STR, max_energy:INT) -> STR
STR optimized_protocol = CONSENSUS_OPTIMIZE_ENERGY("ProofOfStake", 10000);
FUNC_NAME(param1:TYPE) -> RETURN_TYPE
FUNC_NAME(param1:TYPE, param2:TYPE) -> RETURN_TYPE
FUNC add(x:INT) -> INT {
RETURN x + 1;
}
FUNC add(x:INT, y:INT) -> INT {
RETURN x + y;
}
local_var := value; // Local scope
global_var := value; // Global scope
global x := 5;
FUNC example() {
local y := 10;
RETURN x + y;
}
FUNC_NAME(param1:TYPE, param2:TYPE = default_value) -> RETURN_TYPE
FUNC greet(name:STR, message:STR = "Hello") -> STR {
RETURN message + " " + name;
}
FUNC_NAME(param1:TYPE, param2:OPT<INT>) -> RETURN_TYPE
FUNC multiply(x:INT, y:OPT<INT>) -> INT {
RETURN IF y != NULL THEN x * y ELSE x;
}
lambda := (param1:TYPE, param2:TYPE) -> RETURN_TYPE {
// Body
}
lambda := (x:INT, y:INT) -> INT {
RETURN x + y;
};
result := lambda(3, 4); // Outputs 7
closure := FUNC_NAME(param1:TYPE) -> FUNC
FUNC make_multiplier(factor:INT) -> FUNC {
RETURN (x:INT) -> INT {
RETURN x * factor;
};
}
double := make_multiplier(2);
result := double(5); // Outputs 10
MATCH expression {
CASE pattern1: // code
CASE pattern2: // code
DEFAULT: // code
}
FUNC process(value:VEC<INT>) -> STR {
MATCH value {
CASE [1, 2, 3]: RETURN "Sequence matched!";
CASE [_, _, _]: RETURN "Three elements!";
DEFAULT: RETURN "No match!";
}
}
macro MACRO_NAME(params) {
// Body
}
macro LOG(expr:EXPR) {
DEBUG_PRINT(expr);
RETURN expr;
}
result := LOG(x + y); // Prints x + y, then returns the result
var_name := value;
x := 42; // Inferred as INT
name := "Alice"; // Inferred as STR
COROUTINE func_name() -> YIELD_TYPE {
// Body
}
COROUTINE producer() -> INT {
FOR i := 0 TO 10 {
YIELD i;
}
}
result := producer(); // Yields values 0 to 10 incrementally
ERROR_TYPE(name:STR, fields:VEC<(STR, TYPE)>)
ERROR_TYPE(InvalidInputError, [(message:STR), (code:INT)]);
THROW(InvalidInputError("Invalid input provided", 101));
TRY {
// Code
} CATCH (error1:ErrorType1) {
// Handle error1
} CATCH (error2:ErrorType2) {
// Handle error2
}
CATCH
blocks to handle different types of errors, chaining error handling mechanisms for robustness.TRY {
result := divide(10, 0);
} CATCH (DivideByZeroError) {
DEBUG_PRINT("Cannot divide by zero!");
} CATCH (InvalidInputError) {
DEBUG_PRINT("Invalid input!");
}
enum ENUM_NAME {
VALUE1,
VALUE2,
VALUE3
}
enum Color {
RED,
GREEN,
BLUE
}
color := Color.RED;
tuple_name := (value1, value2, value3);
tuple := (42, "Alice", true);
x, name, flag := tuple;
record RECORD_NAME {
field1: TYPE;
field2: TYPE;
// More fields
}
record Person {
name: STR;
age: INT;
}
p := Person {name: "Bob", age: 30};
PAR_EXEC(tasks:VEC<FUNC>) -> VEC<RESULT>
tasks := [task1, task2, task3];
results := PAR_EXEC(tasks);
LOCK(mutex:MUTEX) {
// Critical section
}
LOCK(resource_mutex) {
shared_resource := shared_resource + 1;
}
THREAD_START(func:FUNC) -> THREAD
THREAD_JOIN(thread:THREAD) -> RESULT
thread := THREAD_START(worker_function);
result := THREAD_JOIN(thread);
Visual representation of programming components such as functions, variables, and expressions:
╔═════════════════════════════════════╗
║ Component Name ║
╚═════════════════════════════════════╝
╔══════════════════════╗
║ add(5, 10) ║
╚══════════════════════╝
The visual representation of how data flows between components.
──▶
╔══════════════════════╗ ──▶ ╔══════════════════════╗
║ add(5, 10) ║ ║ result: 15 ║
╚══════════════════════╝ ╚══════════════════════╝
A visual output for assignment operations.
:=
╔════════════════════════╗
║ x := 5 ║
╚════════════════════════╝
Each data type will be encapsulated in a separate box:
╔══════════════════════╗
║ INT ║
╚══════════════════════╝
╔══════════════════════╗
║ STR ║
╚══════════════════════╝
╔═════════════╗ ╔═════════════╗
║ x: INT ║ ──▶ ║ y: STR ║
╚═════════════╝ ╚═════════════╝
Visual output for structures like VEC and MAP.
╔════════════════════════════╗
║ VEC<INT> ║
║ ──────────── ║
║ [1, 2, 3] ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ MAP<STR, INT> ║ ║ VEC<INT> ║
║ ──────────── ║ ║ ──────────── ║
║ { "age" : 30 } ║ ║ [1, 2, 3] ║
╚════════════════════════════╝ ╚════════════════════════════╝
Each function is represented visually with input/output flows.
╔══════════════════════╗
║ FUNC add(x, y) ║
║ ─────────────── ║
║ RETURN x + y ║
╚══════════════════════╝
╔══════════════════════╗ ──▶ ╔══════════════════════╗
║ FUNC add(x, y) ║ ║ RETURN x + y ║
║ ─────────────── ║ ║ result := 15 ║
╚══════════════════════╝ ╚══════════════════════╝
Visual output for IF-ELSE
structures.
╔══════════════════════╗
║ IF condition ║
╚══════════════════════╝
│
┌────┴────┐
▼ ▼
╔══════════╗ ╔══════════╗
║ True ║ ║ False ║
╚══════════╝ ╚══════════╝
╔══════════════════════╗
║ IF x > 10 ║
╚══════════════════════╝
│
┌────┴────┐
▼ ▼
╔════════════╗ ╔════════════╗
║ x := x + 1 ║ ║ x := x - 1 ║
╚════════════╝ ╚════════════╝
Loops such as FOR
, WHILE
, and LOOP
visualized as recurring operations.
╔══════════════════════╗
║ LOOP ║
║ ─────────────── ║
║ (i := 0 TO n) ║
╚══════════════════════╝
│
▼
╔══════════════════════╗
║ body of loop ║
╚══════════════════════╝
│
└──▶ back to condition
╔══════════════════════╗
║ LOOP (i := 0 TO 5) ║
╚══════════════════════╝
│
▼
╔══════════════════════╗
║ x := x + i ║
╚══════════════════════╝
│
└──▶ Repeat
Visualizing cryptographic operations like hashing.
╔══════════════════════╗
║ HASH(input) ║
╚══════════════════════╝
│
▼
╔══════════════════════╗
║ H256: hash_output ║
╚══════════════════════╝
╔══════════════════════╗ ──▶ ╔══════════════════════╗
║ HASH("message") ║ ║ H256: 123abc ║
╚══════════════════════╝ ╚══════════════════════╝
╔══════════════════════╗
║ SIGN(sk, msg) ║
╚══════════════════════╝
│
▼
╔══════════════════════╗
║ SIG: signature ║
╚══════════════════════╝
╔══════════════════════╗ ──▶ ╔══════════════════════╗
║ SIGN(sk, "data") ║ ║ SIG: abc123 ║
╚══════════════════════╝ ╚══════════════════════╝
Error handling is shown with catch paths and error outputs.
╔══════════════════════╗
║ TRY { ║
║ operation ║
╚══════════════════════╝
│
▼
╔══════════════════════╗
║ CATCH error_type ║
╚══════════════════════╝
╔══════════════════════╗
║ TRY { x / 0 } ║
╚══════════════════════╝
│
▼
╔══════════════════════╗
║ CATCH(DivideByZero) ║
╚══════════════════════╝
Visualizing parallel task execution with task flows.
╔══════════════════════╗
║ PAR_EXEC(task_list) ║
╚══════════════════════╝
│
▼
╔══════════════════════╗
║ [task1, task2, task3]║
╚══════════════════════╝
╔══════════════════════╗ ──▶ ╔══════════════════════╗
║ PAR_EXEC([t1, t2]) ║ ║ results: [r1, r2] ║
╚══════════════════════╝ ╚══════════════════════╝
╔══════════════════════╗
║ LOCK(mutex) ║
╚══════════════════════╝
│
▼
╔══════════════════════╗
║ critical_section ║
╚══════════════════════╝
╔══════════════════════╗ ──▶ ╔══════════════════════╗
║ LOCK(mutex) ║ ║ shared_resource += 1 ║
╚══════════════════════╝ ╚══════════════════════╝
Visual representation of enumerations (enums), showing the options available:
╔══════════════════════╗
║ ENUM Color ║
║ ─────────────── ║
║ RED ║
║ GREEN ║
║ BLUE ║
╚══════════════════════╝
╔══════════════════════╗ ──▶ ╔══════════════════════╗
║ ENUM Color ║ ║ current_color := RED ║
╚══════════════════════╝ ╚══════════════════════╝
Tuples visualized as structured collections:
╔══════════════════════╗
║ TUPLE ║
║ ─────────────── ║
║ (INT, STR, BOOL) ║
╚══════════════════════╝
╔═════════════════════════╗ ──▶ ╔═════════════════════════╗
║ TUPLE (42, "Alice", T) ║ ║ x := (42, "Alice", true)║
╚═════════════════════════╝ ╚═════════════════════════╝
Records (similar to structs) visually represented with fields and their values:
╔══════════════════════╗
║ RECORD Person ║
║ ─────────────── ║
║ name: STR ║
║ age: INT ║
╚══════════════════════╝
╔══════════════════════╗ ──▶ ╔══════════════════════╗
║ Person { ║ ║ p := { "Bob", 30 } ║
║ name: "Bob", ║ ║ name := "Bob", age := 30 ║
║ age: 30 ║ ║ ║
╚══════════════════════╝ ╚══════════════════════╝
Visualizing multiple functions with the same name but different parameters.
╔══════════════════════╗
║ FUNC add(x:INT) ║
╚══════════════════════╝
╔══════════════════════╗
║ FUNC add(x:INT, y:INT)║
╚══════════════════════╝
╔══════════════════════╗ ──▶ ╔══════════════════════╗
║ add(5) ║ ║ result := 6 ║
╚══════════════════════╝ ╚══════════════════════╝
╔══════════════════════╗ ──▶ ╔══════════════════════╗
║ add(5, 3) ║ ║ result := 8 ║
╚══════════════════════╝ ╚══════════════════════╝
Visualizing anonymous and closure functions:
╔══════════════════════╗
║ CLOSURE make_adder ║
║ ─────────────── ║
║ factor: INT ║
║ RETURN FUNC ║
╚══════════════════════╝
╔════════════════════════╗ ──▶ ╔════════════════════════╗
║ CLOSURE multiplier(2) ║ ║ double := FUNC (x) {x*2}║
╚════════════════════════╝ ╚════════════════════════╝
Flow for MATCH
statements represented visually:
╔══════════════════════╗
║ MATCH expr ║
╚══════════════════════╝
│
┌────┴────┐
▼ ▼
╔══════════╗ ╔══════════╗
║ CASE 1 ║ ║ CASE 2 ║
╚══════════╝ ╚══════════╝
│
└────┴────┐
▼
╔══════════════════════╗
║ DEFAULT ║
╚══════════════════════╝
╔══════════════════════╗
║ MATCH [1, 2, 3] ║
╚══════════════════════╝
│
┌────┴────┐
▼ ▼
╔══════════╗ ╔══════════╗
║ CASE [1,2,3] MATCHED! ║
╚══════════╝
Flow for catching multiple error types:
╔══════════════════════╗
║ TRY { operation } ║
╚══════════════════════╝
│
┌────┴─────┐
▼ ▼
╔════════════╗ ╔════════════╗
║ CATCH 1 ║ ║ CATCH 2 ║
╚════════════╝ ╚════════════╝
╔══════════════════════╗
║ TRY { divide(10, 0) }║
╚══════════════════════╝
│
┌────┴─────┐
▼ ▼
╔════════════╗ ╔════════════╗
║ CATCH(DivBy0) ║ DEBUG PRINT ║
╚════════════╝
Flow for threads:
╔══════════════════════╗
║ THREAD_START(func) ║
╚══════════════════════╝
│
▼
╔══════════════════════╗
║ THREAD: thread_id ║
╚══════════════════════╝
╔══════════════════════╗ ──▶ ╔══════════════════════╗
║ THREAD_START(worker) ║ ║ THREAD_ID: 1001 ║
╚══════════════════════╝ ╚══════════════════════╝
Visual flow for using locks:
╔══════════════════════╗
║ LOCK(mutex) ║
╚══════════════════════╝
│
▼
╔══════════════════════╗
║ Critical Section ║
╚══════════════════════╝
╔══════════════════════╗ ──▶ ╔══════════════════════╗
║ LOCK(resource_mutex) ║ ║ shared += 1 ║
╚══════════════════════╝ ╚══════════════════════╝
Flow for coroutine yield and resumption:
╔══════════════════════╗
║ COROUTINE(func) ║
╚══════════════════════╝
│
▼
╔══════════════════════╗
║ YIELD value ║
╚══════════════════════╝
│
└──▶ Resume
╔══════════════════════╗
║ COROUTINE producer() ║
╚══════════════════════╝
│
▼
╔══════════════════════╗ ──▶ ╔══════════════════════╗
║ YIELD i (i:=0 to 5) ║ ║ resumption returns 2 ║
╚══════════════════════╝ ╚══════════════════════╝
Vectors are visualized as ordered collections.
╔════════════════════════════╗
║ VEC<INT> ║
║ ──────────── ║
║ [1, 2, 3, 4] ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ VEC<STR> ║ ║ VEC: ["apple", "banana"] ║
║ ──────────── ║ ║ ║
║ ["apple", "banana"] ║ ╚════════════════════════════╝
╚════════════════════════════╝
Maps show key-value pairs with keys pointing to their corresponding values.
╔════════════════════════════╗
║ MAP<STR, INT> ║
║ ──────────── ║
║ {"age": 30, "year": 2024} ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ MAP<STR, INT> ║ ║ MAP: {"age": 30, "year": 24}║
║ ──────────── ║ ║ ║
║ {"age": 30, "year": 24} ║ ╚════════════════════════════╝
╚════════════════════════════╝
Optionals are displayed visually as boxed values that can be present or absent (null).
╔════════════════════════════╗
║ OPT<INT> ║
║ ──────────── ║
║ Present: 5 ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ OPT<INT> ║ ║ OPT<INT>: None ║
║ ──────────── ║ ╚════════════════════════════╝
║ Value: 5 ║
╚════════════════════════════╝
Hashing operations visually demonstrate the transformation of data to hash.
╔════════════════════════════╗
║ HASH(data) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ H256: 0xabc123 ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ HASH("message") ║ ║ H256: 123abc ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing cryptographic signatures.
╔════════════════════════════╗
║ SIGN(sk, msg) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ SIG: abc123 ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ SIGN(private_key, "data") ║ ║ SIG: 0x45abc ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing encryption and decryption flows.
╔════════════════════════════╗
║ ENC(pk, msg) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ CIPHER: 0xdef456 ║
╚════════════════════════════╝
╔════════════════════════════╗
║ DEC(sk, cipher) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ PLAINTEXT: "message" ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ ENC(public_key, "secret") ║ ║ CIPHER: 0x789xyz ║
╚════════════════════════════╝ ╚════════════════════════════╝
Zero-knowledge proofs visually demonstrate the verification of a proof without revealing details.
╔════════════════════════════╗
║ ZKP_GEN(circuit, witness) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ PROOF: zk_snark_proof ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ ZKP_GEN(circuit, inputs) ║ ║ PROOF: zk_abc123 ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing error handling using TRY
and CATCH
.
╔════════════════════════════╗
║ TRY { operation } ║
╚════════════════════════════╝
│
┌────┴─────┐
▼ ▼
╔════════════╗ ╔════════════╗
║ Success ║ ║ CATCH error║
╚════════════╝ ╚════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ TRY { x := divide(10, 0) } ║ ║ CATCH(DivByZero) ║
╚════════════════════════════╝ ╚════════════════════════════╝
Assertions are visually represented as checks that must hold true.
╔════════════════════════════╗
║ ASSERT(condition, msg) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ If true: Continue ║
║ If false: Error ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ ASSERT(x > 0, "x must > 0")║ ║ TRUE: Continue execution ║
╚════════════════════════════╝ ╚════════════════════════════╝
Parallel execution flows show tasks running simultaneously and collecting results.
╔════════════════════════════╗
║ PAR_EXEC(task_list) ║
╚════════════════════════════╝
│
┌────┴─────┐
▼ ▼
╔════════════╗ ╔════════════╗
║ Task 1 ║ ║ Task 2 ║
╚════════════╝ ╚════════════╝
│ │
▼ ▼
╔════════════════════════════╗
║ Results: [res1, res2] ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ PAR_EXEC([t1, t2]) ║ ║ Results: [output1, output2]║
╚════════════════════════════╝ ╚════════════════════════════╝
Threads are visualized with a start and join process.
╔════════════════════════════╗
║ THREAD_START(func) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ THREAD: thread_id ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ THREAD_JOIN(thread_id) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Result: output ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ THREAD_START(worker) ║ ║ THREAD_ID: 1001 ║
╚════════════════════════════╝ ╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ THREAD_JOIN(1001) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Result: output_value ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ THREAD_START(task_worker) ║ ║ THREAD_ID: 1012 ║
╚════════════════════════════╝ ╚════════════════════════════╝
│ │
▼ ▼
╔════════════════════════════╗ ╔════════════════════════════╗
║ THREAD_JOIN(1012) ║ ║ Result: completed_task ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing a mutex locking mechanism to control concurrent access.
╔════════════════════════════╗
║ LOCK(mutex) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Critical Section ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ UNLOCK(mutex) ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ LOCK(resource_mutex) ║ ║ shared_resource += 1 ║
╚════════════════════════════╝ ╚════════════════════════════╝
│ │
▼ ▼
╔════════════════════════════╗ ╔════════════════════════════╗
║ UNLOCK(resource_mutex) ║ ║ Continue execution ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visual representation of a coroutine yielding and resuming.
╔════════════════════════════╗
║ COROUTINE(func) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ YIELD value ║
╚════════════════════════════╝
│
└──▶ Resume
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ COROUTINE producer() ║ ║ YIELD i (i:=0 to 5) ║
╚════════════════════════════╝ ╚════════════════════════════╝
│ │
▼ ▼
╔════════════════════════════╗ ╔════════════════════════════╗
║ Resume coroutine ║ ║ YIELD next value: i=3 ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing asynchronous function calls and awaiting results.
╔════════════════════════════╗
║ ASYNC(func) -> FUTURE<T> ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ AWAIT(future) -> RESULT ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ ASYNC(fetch_data) ║ ║ FUTURE<INT>: pending ║
╚════════════════════════════╝ ╚════════════════════════════╝
│ │
▼ ▼
╔════════════════════════════╗ ╔════════════════════════════╗
║ AWAIT(fetch_future) ║ ║ RESULT: 100 ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visual output for MATCH
statements with multiple cases.
╔════════════════════════════╗
║ MATCH expression ║
╚════════════════════════════╝
│
┌────┴────┐
▼ ▼
╔════════════╗ ╔════════════╗
║ CASE 1 ║ ║ CASE 2 ║
╚════════════╝ ╚════════════╝
│
└────┴────┐
▼
╔══════════════════════╗
║ DEFAULT ║
╚══════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ MATCH value ║ ║ CASE [1, 2, 3]: Matched! ║
╚════════════════════════════╝ ╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ DEFAULT: No match found! ║
╚════════════════════════════╝
IF-ELSE
statements visually demonstrate conditional branching.
╔════════════════════════════╗
║ IF condition ║
╚════════════════════════════╝
│
┌────┴────┐
▼ ▼
╔════════════╗ ╔════════════╗
║ True ║ ║ False ║
╚════════════╝ ╚════════════╝
│
└────┴────┐
▼
╔══════════════════════╗
║ CONTINUE execution ║
╚══════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ IF (x > 10) ║ ║ x := x + 1 ║
╚════════════════════════════╝ ╚════════════════════════════╝
│
▼
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ ELSE x := x - 1 ║ ║ Result: x = 9 ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visually representing function calls with optional or default parameters.
╔════════════════════════════╗
║ FUNC greet(name, msg="Hi") ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ CALL: greet("Alice") ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Result: "Hi Alice" ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ FUNC add(x, y=10) ║ ║ CALL: add(5) ║
╚════════════════════════════╝ ╚════════════════════════════╝
│ │
▼ ▼
╔════════════════════════════╗ ╔════════════════════════════╗
║ Result: 15 ║ ║ x + y = 15 ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visually representing lambdas and closures.
╔════════════════════════════╗
║ LAMBDA (x, y) -> x + y ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ CALL: lambda(3, 4) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Result: 7 ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ LAMBDA (x) -> x * factor ║ ║ Result of closure: 20 ║
╚════════════════════════════╝ ╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ LAMBDA (x) -> x * factor ║ ║ CALL: closure(10) ║
╚════════════════════════════╝ ╚════════════════════════════╝
│ │
▼ ▼
╔════════════════════════════╗ ╔════════════════════════════╗
║ factor := 2 ║ ║ Result of closure: 20 ║
╚════════════════════════════╝ ╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ FUNC make_multiplier(f) ║ ║ Result: LAMBDA (x) -> x * f║
╚════════════════════════════╝ ╚════════════════════════════╝
│ │
▼ ▼
╔════════════════════════════╗ ╔════════════════════════════╗
║ LAMBDA := make_multiplier(2) ║ CALL: LAMBDA(10) ║
╚════════════════════════════╝ ╚════════════════════════════╝
│ │
▼ ▼
╔════════════════════════════╗ ╔════════════════════════════╗
║ LAMBDA (x) -> x * 2 ║ ║ Result: 20 ║
╚════════════════════════════╝ ╚════════════════════════════╝
This matches the lambda and closure concept by showing how the closure captures the factor
from the outer scope, and then it visually demonstrates how calling the lambda works with captured values. The flow proceeds through the creation of the lambda, calling it, and returning the computed result.
Visual representation of defining and throwing custom errors.
╔════════════════════════════╗
║ ERROR_TYPE(name, fields) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ THROW(ErrorType) ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ ERROR_TYPE(InvalidInput, ║ ║ THROW(InvalidInput("Wrong")║
║ [(msg: STR)]) ║ ╚════════════════════════════╝
╚════════════════════════════╝
Handling multiple error types with chained TRY-CATCH
.
╔════════════════════════════╗
║ TRY { operation } ║
╚════════════════════════════╝
│
┌────┴─────┐
▼ ▼
╔════════════╗ ╔════════════╗
║ CATCH 1 ║ ║ CATCH 2 ║
╚════════════╝ ╚════════════╝
│
└────┴────┐
▼
╔══════════════════════╗
║ FINAL: Continue ║
╚══════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ TRY { operation() } ║ ║ CATCH(DivideByZero) ║
╚════════════════════════════╝ ╚════════════════════════════╝
│
▼
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ CATCH(InvalidInput) ║ ║ FINAL: Handle gracefully ║
╚════════════════════════════╝ ╚════════════════════════════╝
Macros visually generate code, simplifying repeated operations.
╔════════════════════════════╗
║ macro MACRO_NAME(params) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Code generated by macro ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ macro LOG(expr) ║ ║ LOG(x + y) expands to: ║
╚════════════════════════════╝ ║ DEBUG_PRINT(x + y) ║
║ RETURN (x + y) ║
╚════════════════════════════╝
Visual output showing how type inference works.
╔════════════════════════════╗
║ var_name := value ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Type inferred: INT ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ x := 42 ║ ║ Type inferred: INT ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visual representation of parallel task execution and result aggregation.
╔════════════════════════════╗
║ PAR_EXEC(tasks) ║
╚════════════════════════════╝
│
┌────┴─────┐
▼ ▼
╔════════════╗ ╔════════════╗
║ Task 1 ║ ║ Task 2 ║
╚════════════╝ ╚════════════╝
│ │
▼ ▼
╔════════════════════════════╗
║ Aggregated Results ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ PAR_EXEC([download1, ║ ║ Results: [file1, file2] ║
║ download2]) ║ ╚════════════════════════════╝
╚════════════════════════════╝
Visualizing the locking and unlocking of shared resources.
╔════════════════════════════╗
║ LOCK(mutex) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Critical Section ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ UNLOCK(mutex) ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ LOCK(shared_mutex) ║ ║ Critical Section ║
╚════════════════════════════╝ ╚════════════════════════════╝
│
▼
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ UNLOCK(shared_mutex) ║ ║ Continue execution ║
╚════════════════════════════╝ ╚════════════════════════════╝
Enums visually represent the predefined choices.
╔════════════════════════════╗
║ ENUM Color ║
╚════════════════════════════╝
│
┌────┴─────┐
▼ ▼
╔════════════╗ ╔════════════╗
║ RED ║ ║ BLUE ║
╚════════════╝ ╚════════════╝
│
▼
╔══════════════════════╗
║ Enum Value: GREEN ║
╚══════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ ENUM Color: RED, GREEN, ║ ║ Enum Value: GREEN ║
║ BLUE ║ ╚════════════════════════════╝
╚════════════════════════════╝
Visualizing tuples as a collection of multiple data types.
╔════════════════════════════╗
║ TUPLE (INT, STR, BOOL) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ (42, "Alice", true) ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ TUPLE (42, "Alice", true) ║ ║ Elements: INT, STR, BOOL ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visual representation of record (struct) fields and values.
╔════════════════════════════╗
║ RECORD Person ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ name: "Alice" ║
║ age: 30 ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ RECORD {name: "Alice", ║ ║ Person {name: "Alice", age:30}║
║ age: 30} ║ ╚════════════════════════════╝
╚════════════════════════════╝
Visual representation of Lattice-based operations such as sampling and decoding.
╔════════════════════════════╗
║ LWE_SAMPLE(s, e) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ VEC<FLD>: Sample Output ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ LWE_SAMPLE(secret, error) ║ ║ VEC: [0x32, 0x45, 0x78] ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing witness encryption and decryption.
╔════════════════════════════╗
║ WE_ENC(stmt, msg) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ CIPHER: Encrypted Data ║
╚════════════════════════════╝
╔════════════════════════════╗
║ WE_DEC(cipher, witness) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ RESULT: Decrypted Message ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ WE_ENC("statement", msg) ║ ║ CIPHER: 0xabc456 ║
╚════════════════════════════╝ ╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ WE_DEC(cipher, witness) ║ ║ RESULT: "Decrypted Data" ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing Merkle Tree creation, insertion, and proof verification.
╔════════════════════════════╗
║ MT_NEW() ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Merkle Tree Created ║
╚════════════════════════════╝
╔════════════════════════════╗
║ MT_INSERT(mt, leaf) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ New Leaf Added: 0x123abc ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ MT_INSERT(mt, 0x123abc) ║ ║ Leaf Added: 0x123abc ║
╚════════════════════════════╝ ╚════════════════════════════╝
State channel operations, including opening, updating, and closing a channel.
╔════════════════════════════╗
║ SC_OPEN(participants, state)║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ State Channel Opened ║
╚════════════════════════════╝
╔════════════════════════════╗
║ SC_UPDATE(sc, new_state, sigs)║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ State Updated ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ SC_OPEN([pk1, pk2], state) ║ ║ Channel Opened ║
╚════════════════════════════╝ ╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ SC_UPDATE(channel, new_state, sigs) ║ State Updated Successfully ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visual representation of zk-SNARK setup, proof generation, and verification.
╔════════════════════════════╗
║ SNARK_SETUP(circuit) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Proving Parameters: Setup ║
╚════════════════════════════╝
╔════════════════════════════╗
║ SNARK_PROVE(pp, witness) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ PROOF: zk_snark_proof ║
╚════════════════════════════╝
╔════════════════════════════╗
║ SNARK_VERIFY(pp, proof) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ VERIFICATION: SUCCESSFUL ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ SNARK_SETUP(circuit) ║ ║ Setup Completed ║
╚════════════════════════════╝ ╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ SNARK_PROVE(pp, witness) ║ ║ PROOF: zk_abc123 ║
╚════════════════════════════╝ ╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ SNARK_VERIFY(pp, proof) ║ ║ VERIFICATION: SUCCESSFUL ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visual representation of ring signature generation and verification.
╔════════════════════════════╗
║ RING_SIGN(sk, msg, ring) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ RING_SIG: signature_output ║
╚════════════════════════════╝
╔════════════════════════════╗
║ RING_VERIFY(msg, sig, ring)║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ VERIFICATION: SUCCESS ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ RING_SIGN(sk, msg, [pk1, pk2])║ ║ RING_SIG: ring_sig_123 ║
╚════════════════════════════╝ ╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ RING_VERIFY(msg, sig, [pk1, pk2])║ ║ VERIFICATION: SUCCESS ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visual representation of blind signature creation and verification.
╔════════════════════════════╗
║ BLIND_SIGN(sk, blinded_msg)║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ BLIND_SIG: blind_signature ║
╚════════════════════════════╝
╔════════════════════════════╗
║ BLIND_VERIFY(pk, msg, sig) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ VERIFICATION: SUCCESS ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ BLIND_SIGN(sk, blinded_msg)║ ║ BLIND_SIG: blind_sig_456 ║
╚════════════════════════════╝ ╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ BLIND_VERIFY(pk, msg, sig) ║ ║ VERIFICATION: SUCCESS ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing the generation of post-quantum keys.
╔════════════════════════════╗
║ PQ_KEYGEN(security_param) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ PK: public_key ║
║ SK: secret_key ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ PQ_KEYGEN(256) ║ ║ PK: pq_public_key ║
║ ║ ║ SK: pq_secret_key ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing post-quantum encryption and decryption processes.
╔════════════════════════════╗
║ PQ_ENC(pk, msg) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ CIPHER: Encrypted PQ Data ║
╚════════════════════════════╝
╔════════════════════════════╗
║ PQ_DEC(sk, cipher) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ PLAINTEXT: Decrypted PQ Msg║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ PQ_ENC(pq_public_key, msg) ║ ║ CIPHER: pq_encrypted_data ║
╚════════════════════════════╝ ╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ PQ_DEC(pq_secret_key, cipher)║ ║ PLAINTEXT: decrypted_msg ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing the setup phase for VDF.
╔════════════════════════════╗
║ VDF_SETUP(security_param) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ VDF_PP: Setup Parameters ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ VDF_SETUP(256) ║ ║ VDF_PP: vdf_params_256 ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing VDF evaluation.
╔════════════════════════════╗
║ VDF_EVAL(pp, input, time) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Output: Evaluated Result ║
║ Proof: VDF Proof ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ VDF_EVAL(vdf_params, input, 5)║ ║ Output: 12345, Proof: vdf_p1║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing the verification of the result of a VDF.
╔════════════════════════════╗
║ VDF_VERIFY(pp, input, output, proof)║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ VERIFICATION: SUCCESSFUL ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ VDF_VERIFY(vdf_params, input, output, proof)║ ║ VERIFICATION: SUCCESS ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing key generation for homomorphic encryption.
╔════════════════════════════╗
║ HE_KEYGEN(security_param) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ HE_PK: Public Key ║
║ HE_SK: Secret Key ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ HE_KEYGEN(128) ║ ║ HE_PK: he_public_key ║
║ ║ ║ HE_SK: he_secret_key ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing the encryption and decryption processes.
╔════════════════════════════╗
║ HE_ENC(pk, msg) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ CIPHER: Homomorphic Cipher ║
╚════════════════════════════╝
╔════════════════════════════╗
║ HE_DEC(sk, cipher) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ PLAINTEXT: Decrypted Result║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ HE_ENC(he_public_key, msg) ║ ║ CIPHER: he_ciphertext ║
╚════════════════════════════╝ ╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ HE_DEC(he_secret_key, cipher)║ ║ PLAINTEXT: decrypted_result║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing homomorphic addition and multiplication operations.
╔════════════════════════════╗
║ HE_ADD(pk, cipher1, cipher2)║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Result: Homomorphic Sum ║
╚════════════════════════════╝
╔════════════════════════════╗
║ HE_MULT(pk, cipher1, cipher2)║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Result: Homomorphic Product║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ HE_ADD(he_public_key, c1, c2)║ ║ Result: homomorphic_sum ║
╚════════════════════════════╝ ╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ HE_MULT(he_public_key, c1, c2)║ ║ Result: homomorphic_product ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visual representation of invariant checks in code execution.
╔════════════════════════════╗
║ INVARIANT(condition, msg) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ ASSERTION: Condition True ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ INVARIANT(x > 0, "x must > 0")║ ║ ASSERTION: TRUE ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing proof generation and verification.
╔════════════════════════════╗
║ PROVE(theorem) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ PROOF: Formal Proof ║
╚════════════════════════════╝
╔════════════════════════════╗
║ CHECK_PROOF(theorem, proof)║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ VERIFICATION: SUCCESS ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ PROVE("x + y = y + x") ║ ║ PROOF: formal_proof_123 ║
╚════════════════════════════╝ ╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ CHECK_PROOF("x + y = y + x", proof) ║ ║ VERIFICATION: SUCCESS ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing detailed error messages and stack traces for easier debugging.
╔════════════════════════════╗
║ ERROR: <error_message> ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Location: <file>:<line> ║
║ Callstack: [Function1, ║
║ Function2, ║
║ Function3] ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ ERROR: Divide by zero ║ ║ Location: main.rs:20 ║
╚════════════════════════════╝ ║ Callstack: [divide, main] ║
╚════════════════════════════╝
##### 31.2 **Debugging Information**
Visual representation of debug print statements and stack traces.
╔════════════════════════════╗
║ DEBUG_PRINT(expr) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Output: Value of expr ║
╚════════════════════════════╝
╔════════════════════════════╗
║ STACK_TRACE() ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Callstack: [Function1, ║
║ Function2, ║
║ Function3] ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ DEBUG_PRINT(x + y) ║ ║ Output: 10 ║
╚════════════════════════════╝ ╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ STACK_TRACE() ║ ║ Callstack: [func1, func2] ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing the process of importing functions from other languages using FFI.
╔════════════════════════════╗
║ FFI_IMPORT(language, func) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Imported Function: func ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ FFI_IMPORT("C", "math_func")║ ║ Imported Function: math_func║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing the process of exporting functions to other languages using FFI.
╔════════════════════════════╗
║ FFI_EXPORT(func, language) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Exported to: language ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ FFI_EXPORT(my_func, "Python")║ ║ Exported to Python: my_func ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing the serialization process where data structures are converted into byte arrays.
╔════════════════════════════╗
║ SERIALIZE(object) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Byte Stream: [0x45, 0x23] ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ SERIALIZE(my_obj) ║ ║ Byte Stream: [0x12, 0x34] ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing the deserialization process where byte streams are converted back into data structures.
╔════════════════════════════╗
║ DESERIALIZE(data, type) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Deserialized Object ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ DESERIALIZE([0x12, 0x34], T)║ ║ Deserialized: my_object ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing precondition checks before function execution.
╔════════════════════════════╗
║ PRE(condition, msg) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Check Passed: Continue ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ PRE(x > 0, "x must be > 0")║ ║ Check Passed: TRUE ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing postcondition checks after function execution.
╔════════════════════════════╗
║ POST(condition, msg) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Check Passed: Continue ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ POST(result != NULL, "result valid") ║ ║ Check Passed: TRUE ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing invariant checks to maintain consistency throughout the program execution.
╔════════════════════════════╗
║ INVARIANT(condition, msg) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Invariant Held: Continue ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ INVARIANT(balance >= 0, ║ ║ Invariant Held: TRUE ║
║ "Balance cannot be negative") ║ ╚════════════════════════════╝
╚════════════════════════════╝
Visualizing the execution of multiple tasks in parallel.
╔════════════════════════════╗
║ PAR_EXEC(tasks) ║
╚════════════════════════════╝
│
┌────┴─────┐
▼ ▼
╔════════════╗ ╔════════════╗
║ Task 1 ║ ║ Task 2 ║
╚════════════╝ ╚════════════╝
│ │
▼ ▼
╔════════════════════════════╗
║ Aggregated Results ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ PAR_EXEC([task1, task2]) ║ ║ Aggregated Results: [r1, r2]║
╚════════════════════════════╝ ╚════════════════════════════╝
Visualizing how expressions are lazily evaluated only when needed.
╔════════════════════════════╗
║ LAZY(expr) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Lazy Expression Created ║
╚════════════════════════════╝
╔════════════════════════════╗
║ FORCE(expr) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Evaluated: Result ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ LAZY(x + y) ║ ║ Lazy Expression Created ║
╚════════════════════════════╝ ╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ FORCE(x + y) ║ ║ Evaluated: Result: 10 ║
╚════════════════════════════╝ ╚════════════════════════════╝
Visual representation of memoization where the result of function calls is cached for future use.
╔════════════════════════════╗
║ MEMO(func) ║
╚════════════════════════════╝
│
▼
╔════════════════════════════╗
║ Cache Created ║
╚════════════════════════════╝
╔════════════════════════════╗
║ Call with Cached Result ║
╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ MEMO(expensive_computation)║ ║ Cache Created for Future Use║
╚════════════════════════════╝ ╚════════════════════════════╝
╔════════════════════════════╗ ──▶ ╔════════════════════════════╗
║ Call(expensive_computation)║ ║ Cached Result: 100 ║
╚════════════════════════════╝ ╚════════════════════════════╝
With these sections done, we are nearing the end of the core visual outputs that match the programming logic we've mapped out so far. Let me know if you'd like to continue or focus on specific remaining areas. We're ensuring every input is thoroughly matched with a visual counterpart!