Skip to content

Congruence rule in TFL depends on bound variable #681

Open
@mn200

Description

@mn200

In the following, valueOf extracts a value from a monad ('a M -> 'a). This is possible, for example, in a writer monad. In something like the option monad, you'd have SOME xxxx = m1 as the precondition to the equality on fm1 and fm2.

val bind_cong = store_thm(
  "bind_cong[defncong]",
  ``!m1 m2 fm1 fm2. (m1 = m2) /\ (!xxxx. xxxx = valueOf m1 ==> fm1 xxxx = fm2 xxxx) ==>
      (bind m1 fm1 = bind m2 fm2)``,
  rw[bind_def, valueOf_def] >>
  Cases_on `m1` >>
  Cases_on `r` >>
  fs[]);

Now, using xxxx below causes an error:

val fooM_def = Define`
    fooM b =
      do
        if b = 0 then return 0
        else do
             (* no problem if xxxx is replaced by x *)
               xxxx <- incM b;
               y <- decM b;
               fooM y;
             od
      od
`;

Discovered by Joseph Chan.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions