by Yu Feng
{ x=A ∧ y=B } ? { x=B ∧ y=A }
{ x = A ∧ y = B }
x := x XOR y; // S1
y := x XOR y; // S2
x := x XOR y; // S3
{ x = B ∧ y = A }
maxList :: xs:{List Int | len xs > 0} -> {v:Int | v ∈ xs && (∀y ∈ xs. v ≥ y)}
maxList xs =
case xs of
Cons h Nil -> h
Cons h t ->
let m = maxList t in
if h >= m then h else m
What are the cons of deductive synthesis?
// FlashFill's Domain Specific Language (DSL)
P ::= Concat(f₁, f₂, ..., fₖ) // Program is a concatenation of expressions
f ::= ConstStr(s) // Constant string literal
| SubStr(v, pₗ, pᵣ) // Substring from input column v
pₗ, pᵣ ::= Pos(v, R₁, R₂, k) // Position defined by regex match
| ConstPos(k)
// Example: Name formatting (Smith, J.)
Concat(
SubStr(v₂, ConstPos(0), ConstPos(∞)), // Last Name (column 2)
ConstStr(", "), // Constant string ", "
SubStr(v₁, ConstPos(0), ConstPos(1)), // First character of First Name (column 1)
ConstStr(".") // Constant string "."
)
(x + y) * 2 // Original expression
x * 2 + y * 2 // Distributive property
2 * x + 2 * y // Commutative property
2 * (x + y) // Factoring