siddhartha-gadgil / LTS2019

Web page, code for "Logic, Types Spaces 2019" at IISc
http://math.iisc.ac.in/~gadgil/LTS2019/
MIT License
9 stars 13 forks source link

Connected components of a graph #14

Open siddhartha-gadgil opened 5 years ago

siddhartha-gadgil commented 5 years ago

Given a finite graph, return

rathivrunda commented 5 years ago

How do we define a matrix in Idris ?

anotherArka commented 5 years ago

I think the book by Manning has one definition.

siddhartha-gadgil commented 5 years ago

Yes, it is in the book by Manning, and is one step beyond the definition of Vectors, which you can see at https://github.com/idris-lang/Idris-dev/blob/master/libs/base/Data/Vect.idr. So we define Mat:(rows: Nat) ->(cols: Nat) -> (elem: Type) -> Type where the entries have type elem

The idea is to fix the number of rows, i.e. the codomain of the natural transformation, and have constructors for

By the way, if you are considering #12, it is worth doing the case of one equation over a field first, since there are cases with no solutions (and even with infinitely many)

shafilmaheenn commented 5 years ago

How exactly is a path defined? Can we repeat vertices and edges

siddhartha-gadgil commented 5 years ago

Yes, a path can have repeated vertices and edges. However, it is a theorem that there is a path between points p and q if and only if there is a simple path, i.e., one with no vertices or edges repeated. It may be worth proving this, i.e. mapping from a general path to a simple one with the same endpoints.

Note that first one must fix a definition of a graph. One way is with an incidence matrix. Another way, more common in at least topology related uses is to define a graph as

From these we can define a terminal vertex map t: E -> V. Then we can define a path from p to q as an inductive structure.

In this case, it may (or may not) be easier to use an incidence matrix (or Boolean relation) or some other definition instead.