Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extending the type preservation check #189

Merged
merged 41 commits into from
Feb 21, 2020
Merged

Extending the type preservation check #189

merged 41 commits into from
Feb 21, 2020

Conversation

Gaspi
Copy link
Collaborator

@Gaspi Gaspi commented Sep 17, 2019

From the type checking of a LHS of a rule, several kind of constraints may be inferred

  1. First-order substitutions: X = t
  2. Higher-order substitutions: X x1 ... xn = t (under k>=n abstractions)
    where x1 ... xn are distinct locally bound variables
  3. (Yet) Unprocessed equalities: t = u (possibly under n abstractions)
  4. Unsatisfiable equalities

The constraints are then used to check convertibility of inferred type of RHS and LHS.
Expected behavior for these constraints are:

  1. Substitute X with t in other constraints and in both LHS and RHS expected types
  2. Substitute X a1 ... an with t{x1\a1, ..., xn\an} in other constraints and in both LHS and RHS expected types
    Note : what happens when several rules map the same variable ?
  3. Two possibilities:
    • Record and extend LHS/RHS conversion check to try and substitute in case of exact match (cf Jui-Hsuan internship)
    • Run Knuth-Bendix completion, then locally extend rewriting in the convertibility check (cf Jui-Hsuan internship)
  4. The pattern will never match a well-typed term. This is most likely a user error:
    -> raise a warning or fail

(1.) and (4.) are already handled in an acceptable way.
This PR should:

  • Confirm the SR checking criteria stated above (inputs are welcome)
  • Fix issue with (1.) where order of variable is relevant in the substitution (cf tests/OK/first_order_cstr1.dk)
  • Modify the SR checking algorithm (typing/pseudo_u to allow several successive passes of inferring from constraints / process constraints.
  • Implement (2.)
  • Implement at least the first solution of (3.)
  • Write tests for all implemented features

@Gaspi Gaspi added the WIP Work In Progress - Not ready to be merged yet label Nov 15, 2019
@Gaspi Gaspi changed the title Record constraints and precise Extending the type preservation check Dec 6, 2019
@fblanqui
Copy link
Member

fblanqui commented Dec 6, 2019

Better handling constraints means developing a (better) unification algorithm. Why doing this in Dedukti and not in Lambdapi?
Concerning the use of Knuth-Bendix completion, see http://rewriting.gforge.inria.fr/papers/sr.pdf and Deducteam/lambdapi#200 .

@Gaspi Gaspi removed the WIP Work In Progress - Not ready to be merged yet label Dec 13, 2019
@Gaspi Gaspi added Dedukti 2.7 WIP Work In Progress - Not ready to be merged yet and removed help wanted labels Feb 14, 2020
Copy link
Collaborator

@francoisthire francoisthire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds a lot of complexity in the understanding of the SR algorithm. I am not confident enough to judge this algorithm. However. probably some comments should be MADE in the Readme file.

@@ -60,7 +60,8 @@ let _ =
c : (confluence) notifies about information provided to the confluence
checker (when option --confluence used)
u : (rule) provides information about type checking of rules
t : (typing) provides information about type-checking of terms
t : (typing) provides information about type checking of terms
s : (SR) provides information about subject reduction checking of terms
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SR criterion here is for the rules, not terms in general, right?

@@ -92,6 +93,11 @@ let _ =
; ( "--type-lhs"
, Arg.Set Typing.fail_on_unsatisfiable_constraints
, " Forbids rules with untypable left-hand side" )
; ( "--sr-check"
, Arg.Int (fun i -> Srcheck.srfuel := i)
, "LVL Sets the level of subject reduction checking to LVL.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LVL Sets... it should be --sr-check right?

- Variables with DB index [k] < [n] are considered "locally bound" and are never substituted.
- Variables with DB index [k] >= [n] may be substituted if [k-n] is mapped in [sigma]
and if they occur applied to enough arguments (substitution's arity). *)
let apply_exsubst (subst:ex_substitution) (n:int) (te:term) : term*bool =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this function cannot be implemented by one of the subst function? Why this function is not in the module Subst?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I rephrase, why do we have two modules for substitution now? Why don't we keep only one module for substitutions?

Gaspi pushed a commit that referenced this pull request Feb 21, 2020
@Gaspi Gaspi merged commit fe64863 into master Feb 21, 2020
@Gaspi Gaspi deleted the cstr-recording branch February 21, 2020 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
behaviour improvement Dedukti 2.7 WIP Work In Progress - Not ready to be merged yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants