robsimmons / l10

The L10 Logic Programming Language
l10.hyperkind.org
Other
11 stars 0 forks source link

Predecessor patterns for natural numbers #8

Open robsimmons opened 13 years ago

robsimmons commented 13 years ago

It should be possible to match against known natural numbers, as demonstrated in regression/match-nat.l10:

w: nat -> world.
w (X+5) <- w X.

The problem also manifests in examples/bulp/cyk-buggy.l10.

In Elton compiling this causes Invariant to be raised, in Smlten it fails silently, which is bad.

$ sml -m sml/smlten.cm
- Read.file "regression/match-nat.l10";
- Deduce.deduce [] (Symbol.symbol "w", [ Term.NatConst' 50 ]);
== Begin deduction ==
Scheduling... 1 stages scheduled.
Running at world w 50 -- 0 rules apply
   Iteration 1 -- 0 new fact(s)
== End deduction ==
val it = - : PredSet.set

Making this work will require that the mode checker do something similar to Plus that it does to Equals: check that one of the two numbers can be ground, and probably make sure that one goes as the first argument all the time. Pattern matching against this will amount, in Elton, to a check that the matched constant minus the known constant is greater than zero, and will then bind the smaller number to a new variable.