Skip to content

Collaborating with partial solutions #183

@mfornet

Description

@mfornet

Each solutions involve:

  1. formalizing the statement
  2. writing the solution and
  3. proving its correctness.

Would you accept PRs that accept a subset of the above? More people could easily join the collaboration if 1) is done for every problem. Some people might be very good at providing smart solutions just 2), but get stuck at 3).

For example, for HumanEval0 we can have just 1) like

def has_close_elements_iff (solution : Array Float → Float → Bool) : Prop :=
    (numbers : Array Float) → (threshold : Float) →
        solution numbers threshold ↔ ∃ (i j : Fin numbers.size), i < j ∧ (numbers[i] - numbers[j]).abs < threshold

Then a solution could look like this:

def has_close_elements_sort (numbers : Array Float) (threshold : Float) : Bool :=
    -- fast solution that sorts the array first
    sorry

theorem has_close_elements_sort_correct : has_close_elements_iff has_close_elements_sort := by
    -- proof that the solution is correct
    sorry

One advantage of this approach, is that we can have multiple solutions to the same problem, with different algorithms and tradeoffs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions