Karel
Types
Functions
def north : {n : Int | n = 0}
def east : {n : Int | n = 1}
def south : {n : Int | n = 2}
def west : {n : Int | n = 3}
def world (width : Int | width > 0) (height : Int | height > 0) (x : Int | 0 ≤ x && x < width) (y : Int | 0 ≤ y && y < height) (facing : Int | 0 ≤ facing && facing < 4) : {
r : World | worldWidth r = width
&&
worldHeight r = height && markerLimit r = 10 && noWalls r && noMarkers r && robotX r = x && robotY r = y
}
def with_wall (w : World) (x : Int | 0 ≤ x && x < worldWidth w) (y : Int | 0 ≤ y && y < worldHeight w && (noMarkers w && (x ≠ robotX w || y ≠ robotY w) || wallAllowed w x y)) : {
r : World | worldWidth r = worldWidth w
&&
worldHeight r = worldHeight w
&&
markerLimit r = markerLimit w && noMarkers r = noMarkers w && robotX r = robotX w && robotY r = robotY w
}
def random_world (width : Int | width > 2) (height : Int | height > 2) (seed : Int) : {r : World | worldWidth r = width && worldHeight r = height && markerLimit r = 10}
def with_markers (w : World) (x : Int | 0 ≤ x && x < worldWidth w) (y : Int | 0 ≤ y && y < worldHeight w) (count : Int | 0 ≤ count && count ≤ markerLimit w && (noWalls w || clearCell w x y)) : {
r : World | worldWidth r = worldWidth w
&&
worldHeight r = worldHeight w
&&
markerLimit r = markerLimit w && noWalls r = noWalls w && robotX r = robotX w && robotY r = robotY w
}
def marker_count_at (w : World) (x : Int | 0 ≤ x && x < worldWidth w) (y : Int | 0 ≤ y && y < worldHeight w) : Int
def front_is_clear (w : World) : Bool
def left_is_clear (w : World) : Bool
def right_is_clear (w : World) : Bool
def markers_present (w : World) : Bool
def move (w : World) : World
def turn_left (w : World) : World
def turn_right (w : World) : World
def pick_marker (w : World) : World
def put_marker (w : World | markerCount w < markerLimit w) : World
def marker_count (w : World) : {n : Int | n = markerCount w && n ≥ 0}
def render (w : World) : String
def same_world (a : World) (b : World) : Bool
def example (initial : World) (expected : World) : Examples
def append_examples (a : Examples) (b : Examples) : Examples
def load_dataset (path : String) : Dataset
def dataset_size (dataset : Dataset) : {n : Int | n ≥ 0 && n = taskCount dataset}
def dataset_task (dataset : Dataset) (index : Int | 0 ≤ index && index < taskCount dataset) : Examples
def fitness (program : (w : World) → World) (examples : Examples) : Float
def require_finished (fuel : Int) (test : (w : World) → Bool) (w : World) : World
def repeat_tick (w : World) : World
def load_task_examples (path : String) : Examples
def robot_x (w : World) : {n : Int | n = robotX w && 0 ≤ n && n < worldWidth w}
def robot_y (w : World) : {n : Int | n = robotY w && 0 ≤ n && n < worldHeight w}
def direction (w : World) : {n : Int | 0 ≤ n && n < 4}
def width (w : World) : {n : Int | n = worldWidth w && n ≥ 0}
def height (w : World) : {n : Int | n = worldHeight w && n ≥ 0}
def no_markers_present (w : World) : Bool
def not_karel (test : (w : World) → Bool) (w : World) : Bool
def stay (w : World) : World
def sequence (first : (w : World) → World) (second : (w : World) → World) (w : World) : World
def repeat (count : Int) (step : (w : World) → World) (w : World) : World
def if_karel (test : (w : World) → Bool) (yes : (w : World) → World) (no : (w : World) → World) (w : World) : World
def when_karel (test : (w : World) → Bool) (step : (w : World) → World) (w : World) : World
def while_karel (fuel : Int) (test : (w : World) → Bool) (step : (w : World) → World) (w : World) : World
def marker_limit (w : World) : {n : Int | n = markerLimit w && n ≥ 0}
def cell_is_clear (w : World) (x : Int) (y : Int) : {b : Bool | b = clearCell w x y}
def can_add_wall (w : World) (x : Int) (y : Int) : {b : Bool | b = wallAllowed w x y}
Uninterpreted
Functions declared as def f ... = uninterpreted: only their signature is known to the verifier; they have no body.
def worldWidth : (w : World) → Int
def worldHeight : (w : World) → Int
def markerLimit : (w : World) → Int
def markerCount : (w : World) → Int
def taskCount : (ds : Dataset) → Int
def clearCell : (w : World) → (x : Int) → (y : Int) → Bool
def wallAllowed : (w : World) → (x : Int) → (y : Int) → Bool
def noWalls : (w : World) → Bool
def noMarkers : (w : World) → Bool
def robotX : (w : World) → Int
def robotY : (w : World) → Int