Skip to content

Instantly share code, notes, and snippets.

@pcarbonn
Last active February 10, 2022 16:46
Examples for intensional paper
#! IDP-Z3 0.9.2
vocabulary {
type Severity := {0,1,2,3}
young: () β†’ 𝔹
temperature: () β†’ ℝ
coughing : () β†’ 𝔹
sneezing : () β†’ 𝔹
fever : () β†’ 𝔹
symptom : Concept[() β†’ 𝔹] β†’ 𝔹
severity : () β†’ Severity
furtherTest: () β†’ 𝔹
}
theory {
symptom := {`coughing, `sneezing, `fever}.
[Definition of fever]
{ [A young has fever above 37.2Β°]
fever() ← young() ∧ 37.2 < temperature().
[An adult has fever above 38Β°]
fever() ← Β¬young() ∧ 38.0 < temperature(). }
[The severity is the number of symptoms]
severity() = #{s ∈ symptom: $(s)()}.
[More tests are needed if there are more than 2 symptoms]
{ furtherTest() ← 2 ≀ severity(). }
severity()=0 ∨ severity()=1 ∨ severity()=2 ∨ severity()=3.
}
display {
goal_symbol := {`furtherTest}.
view()=expanded.
}
#! IDP-Z3 0.9.2
vocabulary {
type Country := {Belgium, France}
amount_thresholdEU, periodEU: () β†’ β„€
amount_threshold, period: Country β†’ β„€
obligation: Concept[Countryβ†’β„€] β†’ 𝔹
mapping: Concept[Country→℀] → Concept[()→℀]
}
theory {
obligation := {`amount_threshold, `period}.
mapping := {`amount_threshold β†’ `amount_thresholdEU,
`period β†’ `periodEU}.
βˆ€ o ∈ obligation: βˆ€c ∈ Country: $(o)(c) ≀ $(mapping(o))().
}
procedure main() {
pretty_print(model_expand(T))
}
#! IDP-Z3 0.9.2
vocabulary V {
type Patient := {Bob}
coughing : Patient β†’ 𝔹
sneezing : Patient β†’ 𝔹
fever : Patient β†’ 𝔹
highRisk : Patient β†’ 𝔹
riskFactor : Concept[Patient β†’ 𝔹] β†’ 𝔹
severity : Patient β†’ β„€
test : Patient β†’ 𝔹
}
theory T:V {
riskFactor := {`coughing, `sneezing, `fever, `highRisk}.
βˆ€x ∈ Patient: severity(x) = #{rf ∈ riskFactor: $(rf)(x)}.
βˆ€x ∈ Patient: test(x) ⇔ 3 ≀ severity(x).
}
procedure main() {
pretty_print(model_expand(T))
}
#! IDP-Z3 0.9.2
vocabulary {
type Node := {a}
g1, g2: Node β¨― Node β†’ 𝔹
TransClos: Concept[Node β¨― Node β†’ 𝔹] β¨― Node β¨― Node β†’ 𝔹
}
theory {
{βˆ€r ∈ Concept[Node β¨― Node β†’ 𝔹]: βˆ€x,y ∈ Node: TransClos(r, x, y) ← $(r)(x,y).
βˆ€r ∈ Concept[Node β¨― Node β†’ 𝔹]: βˆ€x,z ∈ Node: TransClos(r, x, z) ← βˆƒy ∈ Node: TransClos(r, x, y) ∧ TransClos(r, y, z).
}
}
procedure main() {
pretty_print(model_expand(T))
}
#! IDP-Z3 0.9.2
vocabulary V {
type Person := {Bob, Alice}
biologicalChildof, legalChildOf, feeds: Person β¨― Person β†’ 𝔹
childConcept: () β†’ Concept[Person β¨― Person β†’ 𝔹]
}
theory T:V {
childConcept() ∈ {`biologicalChildof, `legalChildOf}.
[Parents must feed their children]
βˆ€p1, p2 ∈ Person:
βˆ€y ∈ Concept[Person β¨― Person β†’ 𝔹]: y=childConcept() ∧ $(y)(p1, p2) β‡’
feeds(p1, p2).
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment