variable (python sample)

Tags: free-variable variable python sample

This page shows how to declare free-variables in a universe-of-discourse.

Usage 1

The preferred approach to declare a variable is to call the with_variable method on the instance of the UniverseOfDiscourse :

The scope of the variable is managed automatically.

u = pu.create_universe()

with u.with_variable() as x, u.with_variable() as y,
    ...
    # some formula elaboration code
    ...

Usage 2

If you want to manage the scope of your variables expressly, you may call the declare_variable method on the instance of the UniverseOfDiscourse :

u = pu.create_universe()

x = u.declare_variable()
y = u.with_variable()

...
# some theory derivation code
...

 phi.lock_variable_scope()

Sample code

Code output

𝖫𝖾𝗍 ⌜𝒰₇₆⌝ 𝖻𝖾 𝖺 𝑢𝑛𝑖𝑣𝑒𝑟𝑠𝑒-𝑜𝑓-𝑑𝑖𝑠𝑐𝑜𝑢𝑟𝑠𝑒.

𝑓(𝐱)
((𝑔(𝐱) + (𝑓(𝐱) + 𝑔(𝐲))) + 𝐱)
(𝑓(𝐱) + 𝐱)