2023-07-18
Jo Devriendt
Performance
Simplicity
declare border: string, string -> bool.
define border as {("BE","NL"),("BE","FR"),("BE","LU"),("BE","DE"),
("LU","FR"),("LU","DE"),("NL","DE"),("FR","DE")} else false.
declare color: string -> {"r","g","b","y"}.
all[color(x)!=color(y) for x,y where border(x,y)].
vocabulary V {
type country := {BE,NL,FR,LU,DE}
border: country * country -> Bool
type rgby := {r,g,b,y}
color: country -> rgby
}
theory T:V {
! (x,z) in border: color(x)~=color(z).
}
structure S:V {
border := {(BE,NL),(BE,FR),(BE,LU),(BE,DE),(LU,FR),(LU,DE),(NL,DE),(FR,DE)}.
}
vocabulary V {
type digit := {0..9}
L: () -> digit
E: () -> digit
S: () -> digit
F: () -> digit
O: () -> digit
D: () -> digit
I: () -> digit
T: () -> digit
}
theory T:V {
L() * 1000 + E() * 100 + 11 * S() + F() * 1000 + O() * 110 + D() =
D() * 1000 + I() * 100 + E() * 10 + T().
L()~=E() & L()~=S() & L()~=F() & L()~=O() & L()~=D() & L()~=I() & L()~=T().
E()~=S() & E()~=F() & E()~=O() & E()~=D() & E()~=I() & E()~=T().
S()~=F() & S()~=O() & S()~=D() & S()~=I() & S()~=T().
F()~=O() & F()~=D() & F()~=I() & F()~=T().
O()~=D() & O()~=I() & O()~=T().
D()~=I() & D()~=O() & D()~=T().
I()~=O() & I()~=T().
O()~=T().
L()~=0 & F()~=0 & D()~=0.
}
structure S:V { }
declare L,E,S,F,O,D,I,T: -> {0..9}.
1000*L() + 100*E() + 10*S() + S() +
1000*F() + 100*O() + 10*O() + D() =
//---------------------------------
1000*D() + 100*I() + 10*E() + T() .
L()>0. F()>0. D()>0.
distinct(L(),E(),S(),F(),O(),D(),I(),T()).
Long term (2023+)
Short term (2023)
But ManyWorlds is "good enough" to be put to the test!
Translator FO(.) <-> MW
?
All functions are total.
Predicates are simply function symbols mapping to bool
(or {true, false})
declare border: string, string -> bool.
declare <id list> : <list of int/bool/string> -> <finite range>
Every symbol is a function symbol mapping to a finite range
declare color: string -> {"r","g","b","y"}.
declare L,E,S,F,O,D,I,T: -> {0..9}.
bool, int, string
true, false, -1, 0, 1, "", "Alice", ...
+, -, *, not, and, or, xor, =, !=, >=, >, <=, <,
... implies ..., ... if ... else ...
min, max, abs, distinct, same, count
<id> [<term> for <variable id list> where <term>]
all[color(x)!=color(y) for x,y where border(x,y)].
all[color(x)!=color(y) for x,y where border(x,y)].
sum[value(x) for x where Item(x) and inKnapsack(x)].
define <id or term> as <definition> else <default value>
All definitions will define total functions, so default is used to cover the remaining cases
define border as {("BE","NL"),("BE","FR"),("BE","LU"),("BE","DE"),
("LU","FR"),("LU","DE"),("NL","DE"),("FR","DE")} else false.
Enumeration:
Classic definition:
define fib(x) as
0 if x=0 else
1 if x=1 else
fib(x-1) + fib(x-2)
where x in {0..100} else 0.