<jupyter_start><jupyter_text>4. Holds when clauses for primitive typesA `Holds when` clause is a specific form of derivation rule that allows the programmer to express when instances of the type hold directly in terms of the fields of the instance, i.e. an instance `f(x=X,y=Y,z=Z)` can be said to hold when some expression `Expr` holds, where Expr can use the variables `x`, `y`, and `z` to refer to the fields `X`, `Y` and `Z`.As such, the following two declarations of `f` and `g` are equivalent.<jupyter_code>Fact x Identified by 1..3
Fact y Identified by 1..3
Fact z Identified by 1..3
Fact f Identified by x * y * z
  Derived from f(x,y,z) When x == y && y != z
Fact g Identified by x * y * z
  Holds when x == y && y != z<jupyter_output><empty_output><jupyter_text>Note that in the evaluation expression of a `Derived from` clause, parameters are not bound. That is, in the example above, `x`, `y` and `z` are bound by an implicit occurrence of `Foreach` as would any other variable occurring in the expression. Following these same semantics, a derivation rule can also be written for a primitive type.<jupyter_code>Fact even Identified by 1..6
  Derived from even When even % 2 == 0<jupyter_output><empty_output><jupyter_text>In previous versions of eFLINT however, it was not possible to write the equivalent definition with a `Holds when` clause containing the expression `even % 2 == 0` because `even` was considered unbound. This was the case because `even` is not a parameter of the type `even`...   Intead, in the new semantics of `Holds when` clauses for primitive types, the name of the defined type is considered to be bound to the instance `()`, where `T` is the name of the type (used as a primitive constructor) and `V` is any of the values from the domain of the type:<jupyter_code>Fact also-even Identified by 1..6
  Holds when also-even % 2 == 0<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08214849921011058, 'fraction_numerical': 0.008952080042127435, 'mean_word_length': 4.475504322766571, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '376551', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 573, 'n_tokens_neox': 546, 'n_words': 296, 'path': 'notebooks/eflint3-features/4_primitive_holds_when.ipynb', 'repo_name': 'leegbestand/eflint-jupyter', 'size': '1899'}