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

Field of rationals #26

Open siddhartha-gadgil opened 5 years ago

siddhartha-gadgil commented 5 years ago
SideArt commented 5 years ago

How do we cite other people's code when we use their functions? Is it enough to cite them in a comment above the function?

SideArt commented 5 years ago

Given a type and an element of that type 'g', is it possible to construct another type whose elements are identical to those of the initial type with 'g' removed?

siddhartha-gadgil commented 5 years ago

How do we cite other people's code when we use their functions? Is it enough to cite them in a comment above the function?

Yes, cite them and point to the original file.

siddhartha-gadgil commented 5 years ago

Given a type and an element of that type 'g', is it possible to construct another type whose elements are identical to those of the initial type with 'g' removed?

Given a: A, you may want to use the sigma type of pairs (x, pf) with x : A and pf : x = a -> Void

rathivrunda commented 5 years ago

Idris does not allow us to define custom equalities on types and refl is the only way you can prove an equality. Hence, we can never use the equality type for Rational numbers, as each element will always have to be equal and we won't be able to make any significant progress using just Refl. Proving its a field without using the equality type, would not be possible. How can we get past this?

siddhartha-gadgil commented 5 years ago

Equality is freely generated by reflexivity, which gives several properties of equality:

With all this, one can prove a lot. For me to answer more, you should narrow down to the simplest statement that you cannot prove.

siddhartha-gadgil commented 5 years ago

The main difficulty is proving that two proofs are equal. One approach (as Arka suggested) is to bypass this by changing the definition of rationals to just use successors of natural numbers

data Rats: Type where 
   Rat : (p : ZZ) -> (q : Nat) -> Rat

so that Rat p q is the rational number p/(q + 1)

siddhartha-gadgil commented 5 years ago

If you do use the definition of rationals as above you should modify all definitions, e.g.

add : Rats -> Rats -> Rats
add (Rat p1 q1) (Rat p2 q2) = Rat ((p1 * q2) + p1 + (p2 * q1) + p2) (q1 * q2 + q1 + q2)  
siddhartha-gadgil commented 5 years ago

Some code as an example is at https://github.com/siddhartha-gadgil/LTS2019/blob/master/Code/Q.idr - this was generated looking at required types, proving lemmas and applying functions. The auxiliary functions were defined looking up required types in atom.

There is no conceptual problem doing this, but it takes work and understanding.

siddhartha-gadgil commented 5 years ago

Workflow for proving equalities: