Skip to content

Commit 054881a

Browse files
authored
Merge pull request #138 from arthuraa/fmap_rect
Add induction principle for fmap.
2 parents b6810d5 + 5551b66 commit 054881a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

finmap.v

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3423,6 +3423,28 @@ Notation "x .[& A ]" := (restrictf x A) : fmap_scope.
34233423
Notation "x .[\ A ]" := (x.[& domf x `\` A]) : fmap_scope.
34243424
Notation "x .[~ k ]" := (x.[\ [fset k]]) : fmap_scope.
34253425

3426+
Section FMapRect.
3427+
3428+
Variables (T : choiceType) (S : Type) (P : {fmap T -> S} -> Type).
3429+
3430+
Hypothesis P0 : P [fmap].
3431+
Hypothesis P1 : forall m, P m -> forall x y, x \notin domf m -> P m.[x <- y].
3432+
3433+
Lemma fmap_rect m : P m.
3434+
Proof.
3435+
move e: (domf m) => X.
3436+
elim/fset1U_rect: X => [|x X xX IH] in m e *.
3437+
by move/fmap_nil: e => ->.
3438+
have x_m : x \in domf m by rewrite e fset1U1.
3439+
pose y := m.[x_m].
3440+
have {}e: domf m.[~ x] = X by rewrite domf_rem e fsetU1K.
3441+
have -> : m = m.[~ x].[x <- y].
3442+
by rewrite -[LHS](setf_get [` x_m]) /= setf_rem1.
3443+
by apply: P1; rewrite ?e //; apply: IH.
3444+
Qed.
3445+
3446+
End FMapRect.
3447+
34263448
Section Cat.
34273449
Variables (K : choiceType) (V : Type).
34283450
Implicit Types (f g : {fmap K -> V}).

0 commit comments

Comments
 (0)