Skip to content

Instantly share code, notes, and snippets.

View rodrigogribeiro's full-sized avatar

Rodrigo Geraldo Ribeiro rodrigogribeiro

View GitHub Profile
@rodrigogribeiro
rodrigogribeiro / factorial.org
Last active September 2, 2022 19:39
Código exemplo

Implementação de fatorial usando a linguagem C

Introdução

O objetivo destas notas é apresentar aos alunos o org-mode, um componente do GNU-Emacs que provê suporte a literate programming, isto é, desenvolvimento de programas e sua respectiva documentação em um único formato de arquivo.

@rodrigogribeiro
rodrigogribeiro / AgdaSolver.agda
Created July 20, 2022 21:29 — forked from andrejbauer/AgdaSolver.agda
How to use Agda ring solvers to prove equations?
{- Here is a short demonstration on how to use Agda's solvers that automatically
prove equations. It seems quite impossible to find complete worked examples
of how Agda solvers are used.
Thanks go to @anormalform who helped out with these on Twitter, see
https://twitter.com/andrejbauer/status/1549693506922364929?s=20&t=7cb1TbB2cspIgktKXU8rng
I welcome improvements and additions to this file.
This file works with Agda 2.6.2.2 and standard-library-1.7.1
module Data.Nat.Div.DivIntrinsic where
open import Basics.Admit
open import Data.Nat.Nat
open import Data.Nat.NatTheorems
open import Data.Product.Product
open import Data.Sigma.Sigma
open import Relation.Induction.Natural
open import Relation.Induction.WellFounded
open import Data.Empty using (⊥ ; ⊥-elim)
open import Data.List using (List ; _∷_ ; [] ; length ; _++_)
open import Data.Nat using (ℕ ; zero ; suc ; _<?_)
open import Data.Product using (_×_ ; proj₁ ; proj₂ ; _,_)
open import Data.Sum using (_⊎_ ; inj₁ ; inj₂ ; [_,_])
open import Relation.Binary.PropositionalEquality using (_≡_ ; refl)
open import Relation.Nullary
open import Relation.Unary
open import Data.Nat hiding (_⊔_ ; _⊓_)
open import Data.Bool
open import Data.Empty
open import Data.List renaming (_∷_ to _::_) hiding (drop)
open import Data.List.Membership.Propositional
open import Data.List.Relation.Unary.Any hiding (map)
open import Data.List.Relation.Unary.All renaming (lookup to Alookup) hiding (map)
open import Data.Maybe hiding (map)
open import Data.Product hiding (map)
open import Data.Sum hiding (map)
#lang brag
i-program : (i-statement)*
; statements syntax
@i-statement : i-assign | i-if | i-skip | i-while | i-print
i-assign : i-id /"=" i-exp /";"
@i-block : /"{" (i-statement)* /"}"
i-condition : /"(" i-exp /")"
open import Data.Bool
open import Data.Nat
open import Data.List renaming (_∷_ to _::_)
open import Data.List.Membership.Propositional
open import Data.List.Relation.Unary.Any
open import Data.List.Relation.Unary.All renaming (lookup to Alookup)
open import Data.Maybe
open import Data.Product
open import Data.Unit
\documentclass[9pt]{entcs}
\usepackage{entcsmacro}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsfonts}
\usepackage{proof}
\usepackage{mathtools}
module Teste where
next :: Int -> Int
next n
| even n = n `div` 2
| otherwise = 3 * n + 1
steps :: Int -> Int
module Teste where
next :: Int -> Int
next n
| even n = n `div` 2
| otherwise = 3 * n + 1
steps :: Int -> Int