Skip to content

Eliminate Option from total function result types #4756

Open
@tothtamas28

Description

@tothtamas28

Related

If a K function symbol production is marked total, the corresponding Lean definition should not have Option as its result type.

The key to this is generating theorem stubs that can be used to show absurdity of certain cases.

For the main def, it should be proved that alt least one of the rules apply. For a rule def, each application of a non-total function induces an obligation to prove definedness.

Motivating example:

def div (x y : Nat) : Option Nat := ...

theorem div_x_2_ne_none (x : Nat) : div x 2 ≠ none := sorry

def halve (x : Nat) : Nat :=
  match h0 : div x 2 with
  | some res => res
  | none => absurd h0 (div_x_2_ne_none x)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions