Skip to content
Snippets Groups Projects
Commit 1efc3af6 authored by Robbert Krebbers's avatar Robbert Krebbers
Browse files

Update `multiset_solver` documentation.

parent 99b2a184
No related branches found
No related tags found
1 merge request!231Many improvements to `multiset_solver`
...@@ -147,25 +147,35 @@ End basic_lemmas. ...@@ -147,25 +147,35 @@ End basic_lemmas.
(** We define a tactic [multiset_solver] that solves goals involving multisets. (** We define a tactic [multiset_solver] that solves goals involving multisets.
The strategy of this tactic is as follows: The strategy of this tactic is as follows:
1. Unfold all equalities ([=]), equivalences ([≡]), and inclusions ([⊆]) using 1. Turn all equalities ([=] and [≡]), equivalences ([≡]), inclusions ([⊆] and
the laws of [multiplicity] for the multiset operations. Note that strict [⊂]), and set membership relations ([∈]) into arithmetic (in)equalities
inclusion ([⊂]) is not supported. involving [multiplicity]. The multiplicities of [∅], [∪], [∩], [⊎] and [∖]
2. Use [naive_solver] to decompose the goal into smaller subgoals. are turned into [0], [max], [min], [+], and [-], respectively.
3. Instantiate all universally quantified hypotheses in the subgoals generated 2. Decompose the goal into smaller subgoals through intuitionistic reasoning.
by [naive_solver] to obtain goals that can be solved using [lia]. 3. Instantiate universally quantified hypotheses in hypotheses to obtain a
goal that can be solved using [lia].
Step (1) is implemented using a type class [MultisetUnfold] that hooks into 4. Simplify multiplicities of singletons [{[ x ]}].
the [SetUnfold] mechanism of [set_solver]. Since [SetUnfold] already propagates
through logical connectives, we obtain the same behavior for our multiset Step (1) and (2) are implemented using the [set_solver] tactic, which internally
solver. Note that no [MultisetUnfold] instance is defined for the (non-trivial) calls [naive_solver] for step (2). Step (1) is implemented by extending the
singleton [{[ y ]}] since the singleton receives special treatment in step (3). [SetUnfold] mechanism with a class [MultisetUnfold].
Step (3) is achieved using the tactic [multiset_instantiate], which instantiates Step (3) is implemented using the tactic [multiset_instantiate], which
universally quantified hypotheses [H : ∀ x : A, P x] in two ways: instantiates universally quantified hypotheses [H : ∀ x : A, P x] in two ways:
- If [P] contains a multiset singleton [{[ y ]}] it adds the hypothesis [H y]. - If [P] contains a multiset singleton [{[ y ]}] it adds the hypothesis [H y].
- If the goal or some hypothesis contains [multiplicity y X] it adds the - If the goal or some hypothesis contains [multiplicity y X] it adds the
hypothesis [H y]. hypothesis [H y].
Step (4) is implemented using the tactic [multiset_simplify_singletons], which
simplifies occurences of [multiplicity x {[ y ]}] as follows:
- First, we try to turn these occurencess into [1] or [0] if either [x = y] or
[x ≠ y] can be proved using [done], respectively.
- Second, we try to turn these occurences into a fresh [z ≤ 1] if [y] does not
occur elsewhere in the hypotheses or goal.
- Finally, we make a case distinction between [x = y] or [x ≠ y]. This step is
done last so as to avoid needless exponential blow-ups.
*) *)
Class MultisetUnfold `{Countable A} (x : A) (X : gmultiset A) (n : nat) := Class MultisetUnfold `{Countable A} (x : A) (X : gmultiset A) (n : nat) :=
{ multiset_unfold : multiplicity x X = n }. { multiset_unfold : multiplicity x X = n }.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment