nunchaku-inria / nunchaku

Model finder for higher-order logic
https://nunchaku-inria.github.io/nunchaku/
BSD 2-Clause "Simplified" License
42 stars 3 forks source link

(co)inductive predicates #4

Closed c-cube closed 8 years ago

c-cube commented 8 years ago

keyword: pred/copred (?)

copred a : foo -> prop :=
  a x & b (f x) => a (s x);
  a 0
and b : bar -> prop := ....

Each rhs should start with the defined predicate and contain no other occurrence of the predicates being defined.

Flag well-founded (or variant wf-pred / wf-copred) as an option/attribute. For well-founded predicates, encoding straightforward (turn into a rec definition, then encoding of rec functions).

not well-founded: add an argument (of type nat) that decreases at each call:

pred even n :=
  even 0;
  even n => even n;
  even n => even (s (s n)).

# use even
p (even n0).

becomes, with an approximation of depth k:

wf-pred even k n :=
  even 0 _ = false;  # we start at 1
  even (s k) 0;
  even k n => even (s k) n;
  even k n => even (s k) (s (s n)).

val k0: nat.

# use even:
p (even k0 n0).

and then we can reverse the definition and turn it into a recursive function.

c-cube commented 8 years ago

polarity:

definition + - ±
wf-pred rec rec rec
pred unroll rec guard
copred rec co-unroll guard

where: