0

I am new to Isabelle and this is a simplification of my first program

theory Scratch
imports Main  
begin

  record  flow = 
    Src :: "nat"
    Dest :: "nat"

  record diagram = 
    DataFlows :: "flow set"
    Transitions :: "nat set"
    Markings :: "flow set"

  fun consume :: "diagram × (nat set) ⇒ (flow set)"
  where
    "(consume dia trans) = {n . n ∈ (Markings dia) ∧ (∃ t ∈ trans . (Dest n) = t)}"
end

The function give the error: Type unification failed: Clash of types "_ ⇒ " and " set"

Type error in application: operator not of function type

Operator:  consume dia :: flow set
Operand:   trans :: (??'a × ??'a) set ⇒ bool

What should I do for the the code to compile?

Johan
  • 575
  • 5
  • 21

1 Answers1

2

First of all, you give two parameters to your consume function, but the way you defined its type, it takes a single tuple. This is unusual and often inconvenient – defined curried functions instead, like this:

fun consume :: "diagram ⇒ (nat set) ⇒ (flow set)"

Also, trans is a constant; it is the property that a relation is transitive. You can see that by observing that trans is black to indicate that it is a constant and the other variable is blue, indicating that it is a free variable.

I therefore recommend using another name, like ts:

  where
    "consume dia ts = {n . n ∈ (Markings dia) ∧ (∃ t ∈ ts . (Dest n) = t)}"
Manuel Eberl
  • 7,858
  • 15
  • 24
  • Or you can reuse names by explicitly binding them using `!!`, e.g, `!!trans. consume dia trans = {n. n : Markings dia & (EX t : trans. Dest n = t)}`. – chris Oct 26 '15 at 10:59